Перейти к содержанию

Ростик

Members
  • Постов

    330
  • Зарегистрирован

  • Посещение

Сообщения, опубликованные Ростик

  1. Он итак 4*11. 12 просто весит, 11 это когда с держурным режимом, можешь тоже оставить, общий контакт, он всегда общий и замыкаеться со всеми общими, на то он и общий. А 44 вата не сделаешь, и так уже все в мосту работает, найди усил получше, это кусок Г.

  2. Продолжение кода:

    ; call readbuf
     ;
    warm  ; divert to diag code if the diag button
     ; is pressed on startup
    
    	movlw 0x1b; 27xbit1
    	movwf count2
    warmup		call bit1
    	decfsz count2,F
    	goto warmup
    
    	btfss DIAGBUTTON
    	goto diag_code
    
    loop  ; output (min 11) header bits to 
     ; quit false rxbuf (resync)
    
    	movlw 0x1b; 27xbit1
    	movwf count2
    w_head		call bit1
    	decfsz count2,F
    	goto w_head
    
     ; store key states into buffer data
    	movlw kmask1
    	andwf kport1, W
    	movwf bdata
    
    	movlw kmask2
    	andwf kport2, W
    	movwf bdata+1
    
     ; send out buffer
    outbuf		movlw 0x10; 16xbit1, 1xbit0
    
    header		movwf count2
    head0		call bit1
    	decfsz count2,F
    	goto head0
    	call bit0
    
    	movlw buffer
    	movwf FSR
    	movlw 0x04
    	movwf count1
    	clrf sum
     ;
    outbu0		movf INDF,W
    	addwf sum,F
    	movf INDF,W
    	call outbyte
    	incf FSR,F
    	decfsz count1,F
    	goto outbu0
    	movf sum,W
    	call outbyte
     ; buffer is sent
    
    	goto loop
     ;
    	dw 0xfff
    
    outbyte_1	movwf bt
    	movlw 8
    	movwf count2
    outby0		rlf bt,F
    	btfsc STATUS,C
    	goto outby1
    	call bit0
    	goto outby2
    outby1		call bit1
    outby2		decfsz count2,F
    	goto outby0
     ;
    	call bit1
     ; and bit0
    
    bit0_1		movlw TXHIGH; HIGH
    	movwf txport
    
    ndelaya0	movlw delayconst
    	movwf ncnt
    ndelaya1	decfsz ncnt, F
    	goto ndelaya1
    
    	movlw TXLOW; to LOW transition
    	movwf txport
    
    ndelayb0	movlw delayconst
    	movwf ncnt
    ndelayb1	decfsz ncnt, F
    	goto ndelayb1
    
    	return
    
    	dw 0xfff
    
    bit1_1		movlw TXLOW; LOW
    	movwf txport
    
    ndelayc0	movlw delayconst
    	movwf ncnt
    ndelayc1	decfsz ncnt, F
    	goto ndelayc1
    
    	movlw TXHIGH; to HIGH transition
    	movwf txport
    
    ndelaye0	movlw delayconst
    	movwf ncnt
    ndelaye1	decfsz ncnt, F
    	goto ndelaye1
    
    	return
    	dw 0xfff
    
    readbuf_1;read data into buffer
    	movlw buffer
    	movwf FSR
    	clrf count1
    readbu0		movf count1, W
    	call table
    	movwf INDF
    	incf FSR,F
    	incf count1,F
    
    	movlw 0x04
    	subwf count1, W
    	bnz readbu0
    
    	return
    
    diag_code_1; send out bit patterns
    	call bit0
    	call bit0
    	btfss DIAGBUTTON
    	call bit1
    	goto diag_code
    
    	end

  3. Ктото собирал вот это устройство? Немного смущает программа вот отрывок:

    ;define F84
    #define C505
    ;define TXINV
    ;invert TX output so inactive is HIGH?
    
    #ifdef F84
    list	  p=16F84			; list directive to define processor
    #include <p16F84.inc>		; processor specific variable definitions
    
    __CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
    ;WDT=watchdog, PWRTE=power on timer, XT= crystal osc
    
    freemem EQU 0x10
    txbit	EQU 1
    txport	EQU PORTA
    
    kmask1	EQU 0x02
    kport1	EQU PORTA
    kmask2	EQU 0xf0
    kport2	EQU PORTB
    #define DIAGBUTTON PORTA, 1
    
    #endif
    #ifdef C505
    list	p=16c505
    #include <p16C505.inc>
    
    __CONFIG   _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC_RB4EN
    
    freemem EQU 0x08
    txbit	EQU 8
    txport	EQU PORTC
    
    kmask1	EQU 0x3f
    kport1	EQU PORTB
    kmask2	EQU 0x37
    kport2	EQU PORTC
    #define DIAGBUTTON PORTC, 2
    
    #endif
    
    #ifndef TXINV
    #define TXLOW 0
    #define TXHIGH txbit
    #else
    #define TXLOW txbit
    #define TXHIGH 0
    #endif
    
    ;***** VARIABLE DEFINITIONS
    
    count1		EQU	freemem
    count2		EQU	freemem+1
    ncnt		EQU	freemem+2; ndelay counter
    bt		EQU	freemem+3
    sum		EQU	freemem+4
    buffer		EQU	freemem+5
    bdevid		EQU	buffer ; 2 byte DEVID
    bdata		EQU	buffer+2; 'real' data
    
    delayconst	EQU	.202; ~625 usec @4MHz, half_frame delay
    
    ;**********************************************************************
    #ifdef F84
    	ORG	 0x000			; processor reset vector
    	  goto	main			 ; go to beginning of program
    	nop
    	nop
    	nop
    
    ;ORG	 0x004			; interrupt vector location
    	retfie
    #endif
    
    #ifdef C505
    	ORG	0x000
    	movwf	OSCCAL
    ;C505 HARDWARE INIT
    	clrf	PORTB; clear all I/O pins
    	clrf	PORTC
    	movlw	kmask1;keys are IN, TX out
    	TRIS	kport1; I/O directions
    	movlw	kmask2
    	TRIS	kport2
    
    	movlw	0
    	OPTION
    ;-RBWU wakeup ENA
    ;-RBPU pullup ENA on GP0,1,3
    ;T0CS disable: enablings implicitly sets RC5 dir as input!
    
    	goto	main
    #endif
    
    table		addwf PCL, F
    devid		dt 0x9a, 0xe9, 0, 0x5a
    
    ; jump table for the C505
    bit0		goto bit0_1
    bit1		goto bit1_1
    readbuf		goto readbuf_1
    outbyte		goto outbyte_1
    diag_code	goto diag_code_1
    
    	FILL 0xfff, 0xec
    ; fill up to 0100
    
    main		
    #ifdef F84
    ;F84 HARDWARE INIT
    	clrf PORTA
    	clrf PORTB
    
    	MOVLW kmask1
    	TRIS kport1
    	MOVLW kmask2
    	TRIS kport2
    
    	movlw 0x3
    	OPTION; pres 1:16, B4-B7 PU ena
    #endif

    смущает как настроины порты на С505 все норм 11 на ввод другие а один на вывод, а для Ф84 получается так - это для порта Б 11110000, а для порта А 00010, тоесть всего 8 каналов на ввод. Подскажите плих в чем дело. Сказано что устройство на 11 команд!!1

  4. Я чет не понял. Ты же Dsb собираешь, то как ты собираешся его принимать на фм, это же две разные модуляции!!!

    там сказано:

    В заключение необходимо отметить, что модулятор можно использовать для получения не только DSB сигнала, но и обычного амплитудномодулированного, сильно разбалансировав его конденсатором С1 и. таким образом, восстановив несущую. В этом случае можно получить очень глубокую AM (практически 100%) с малыми искажениями.

    собирай АМ примник!!!

    И вообще че ты мозги паришь, тут есть отличные жуки, поюзай форум.

  5. Спасибо всем за советы, но я нашел устройство полностью. Помогите пожалуйста разобраться с програмой. Что сдесь надо у брать, а что добавить, что бы работало на f84.

    ;**********************************************************************
    ;																	 *
    ;	Filename:		mtx-014.asm									   *
    ;	Date:															*
    ;	File Version:													*
    ;																	 *
    ;	Author:		el@jap.hu										 *
    ;				   http://jap.hu/									*
    ;**********************************************************************
    ;	Notes:
    ;
    ;RF transmitter prot.v4 (Manchester)
    ;supposed crystal freq is 4MHz
    ;frequency is 400/800 Hz
    ; delay times = 625 usec, 625 usec
    ;**********************************************************************
    ;v2 HISTORY
    ;
    ;002-19991227
    ;low power standby mode, no POWER switch needed
    ;transmit portb4-7 buttons state if any is pressed
    ;sleep until a change occurs on the port
    ;
    ;003-19991227
    ;code is compilable for both the F84 and the C508
    ;call depth is reduced to 2 (hopefully every place)
    ;this is the working version!
    ;
    ;004-19991228
    ;experimental version only sending bit patterns by itself
    ;
    ;005-20000316
    ;no sleep, 12c509a
    ;
    ;**********************************************************************
    ;v3 HISTORY
    ;
    ;006-20001223
    ;new prot. v3: less bytes to transmit (-5) & at lower speed
    ;wake-up logic enabled
    ;
    ; header: 8xbit0, 1xbit1
    ; devid : 2xbyte
    ; data  : 1xbyte
    ; chksum: 1xbyte
    ;
    ;007-20001225
    ;one-button version, transmit number of times the button is pressed
    ;transmit a signal three times
    ;
    ;008-20001225
    ;same as 007, except a new DEFINE TXINV invert TX output
    ;
    ;009-20001226
    ;new output for ASK modulation
    ;
    ;010-20001227
    ;adaption for the 12c509a
    ;
    ;011-20010109
    ;manchester coded output
    ;
    ;012-20010113
    ;continous modulation out (output 1-bits while idle)
    ;one button only, planning 5 for the final version
    ;
    ; header : 8xbit1, 1xbit0
    ; bytes : 8xbitX, 1xbit1, 1xbit0
    ;
    ;013-20010113
    ;packet struct: +1 byte, new devid: 9ae6
    ;should send 5 button states
    ;
    ;014-20010121
    ;packet struct is the same, two-port version for 16C505
    ;continous keymask sending (13 sends bit1-s only)
    ;new devid 9ae9
    ;
    ;**********************************************************************
    
    ;define F84
    #define C505
    ;define TXINV
    ;invert TX output so inactive is HIGH?
    
    #ifdef F84
    list	  p=16F84			; list directive to define processor
    #include <p16F84.inc>		; processor specific variable definitions
    
    __CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
    ;WDT=watchdog, PWRTE=power on timer, XT= crystal osc
    
    freemem EQU 0x10
    txbit	EQU 1
    txport	EQU PORTA
    
    kmask1	EQU 0x02
    kport1	EQU PORTA
    kmask2	EQU 0xf0
    kport2	EQU PORTB
    #define DIAGBUTTON PORTA, 1
    
    #endif
    #ifdef C505
    list	p=16c505
    #include <p16C505.inc>
    
    __CONFIG   _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC_RB4EN
    
    freemem EQU 0x08
    txbit	EQU 8
    txport	EQU PORTC
    
    kmask1	EQU 0x3f
    kport1	EQU PORTB
    kmask2	EQU 0x37
    kport2	EQU PORTC
    #define DIAGBUTTON PORTC, 2
    
    #endif
    
    #ifndef TXINV
    #define TXLOW 0
    #define TXHIGH txbit
    #else
    #define TXLOW txbit
    #define TXHIGH 0
    #endif
    
    ;***** VARIABLE DEFINITIONS
    
    count1		EQU	freemem
    count2		EQU	freemem+1
    ncnt		EQU	freemem+2; ndelay counter
    bt		EQU	freemem+3
    sum		EQU	freemem+4
    buffer		EQU	freemem+5
    bdevid		EQU	buffer ; 2 byte DEVID
    bdata		EQU	buffer+2; 'real' data
    
    delayconst	EQU	.202; ~625 usec @4MHz, half_frame delay
    
    ;**********************************************************************
    #ifdef F84
    	ORG	 0x000			; processor reset vector
    	  goto	main			 ; go to beginning of program
    	nop
    	nop
    	nop
    
    ;ORG	 0x004			; interrupt vector location
    	retfie
    #endif
    
    #ifdef C505
    	ORG	0x000
    	movwf	OSCCAL
    ;C505 HARDWARE INIT
    	clrf	PORTB; clear all I/O pins
    	clrf	PORTC
    	movlw	kmask1;keys are IN, TX out
    	TRIS	kport1; I/O directions
    	movlw	kmask2
    	TRIS	kport2
    
    	movlw	0
    	OPTION
    ;-RBWU wakeup ENA
    ;-RBPU pullup ENA on GP0,1,3
    ;T0CS disable: enablings implicitly sets RC5 dir as input!
    
    	goto	main
    #endif
    
    table		addwf PCL, F
    devid		dt 0x9a, 0xe9, 0, 0x5a
    
    ; jump table for the C505
    bit0		goto bit0_1
    bit1		goto bit1_1
    readbuf		goto readbuf_1
    outbyte		goto outbyte_1
    diag_code	goto diag_code_1
    
    	FILL 0xfff, 0xec
    ; fill up to 0100
    
    main		
    #ifdef F84
    ;F84 HARDWARE INIT
    	clrf PORTA
    	clrf PORTB
    
    	MOVLW kmask1
    	TRIS kport1
    	MOVLW kmask2
    	TRIS kport2
    
    	movlw 0x3
    	OPTION; pres 1:16, B4-B7 PU ena
    #endif
    	call readbuf
    ;
    warm	; divert to diag code if the diag button
    ; is pressed on startup
    
    	movlw 0x1b; 27xbit1
    	movwf count2
    warmup		call bit1
    	decfsz count2,F
    	goto warmup
    
    	btfss DIAGBUTTON
    	goto diag_code
    
    loop	; output (min 11) header bits to 
    ; quit false rxbuf (resync)
    
    	movlw 0x1b; 27xbit1
    	movwf count2
    w_head		call bit1
    	decfsz count2,F
    	goto w_head
    
    ; store key states into buffer data
    	movlw kmask1
    	andwf kport1, W
    	movwf bdata
    
    	movlw kmask2
    	andwf kport2, W
    	movwf bdata+1
    
    ; send out buffer
    outbuf		movlw 0x10; 16xbit1, 1xbit0
    
    header		movwf count2
    head0		call bit1
    	decfsz count2,F
    	goto head0
    	call bit0
    
    	movlw buffer
    	movwf FSR
    	movlw 0x04
    	movwf count1
    	clrf sum
    ;
    outbu0		movf INDF,W
    	addwf sum,F
    	movf INDF,W
    	call outbyte
    	incf FSR,F
    	decfsz count1,F
    	goto outbu0
    	movf sum,W
    	call outbyte
    ; buffer is sent
    
    	goto loop
    ;
    	dw 0xfff
    
    outbyte_1	movwf bt
    	movlw 8
    	movwf count2
    outby0		rlf bt,F
    	btfsc STATUS,C
    	goto outby1
    	call bit0
    	goto outby2
    outby1		call bit1
    outby2		decfsz count2,F
    	goto outby0
    ;
    	call bit1
    ; and bit0
    
    bit0_1		movlw TXHIGH; HIGH
    	movwf txport
    
    ndelaya0	movlw delayconst
    	movwf ncnt
    ndelaya1	decfsz ncnt, F
    	goto ndelaya1
    
    	movlw TXLOW; to LOW transition
    	movwf txport
    
    ndelayb0	movlw delayconst
    	movwf ncnt
    ndelayb1	decfsz ncnt, F
    	goto ndelayb1
    
    	return
    
    	dw 0xfff
    
    bit1_1		movlw TXLOW; LOW
    	movwf txport
    
    ndelayc0	movlw delayconst
    	movwf ncnt
    ndelayc1	decfsz ncnt, F
    	goto ndelayc1
    
    	movlw TXHIGH; to HIGH transition
    	movwf txport
    
    ndelaye0	movlw delayconst
    	movwf ncnt
    ndelaye1	decfsz ncnt, F
    	goto ndelaye1
    
    	return
    	dw 0xfff
    
    readbuf_1;read data into buffer
    	movlw buffer
    	movwf FSR
    	clrf count1
    readbu0		movf count1, W
    	call table
    	movwf INDF
    	incf FSR,F
    	incf count1,F
    
    	movlw 0x04
    	subwf count1, W
    	bnz readbu0
    
    	return
    
    diag_code_1; send out bit patterns
    	call bit0
    	call bit0
    	btfss DIAGBUTTON
    	call bit1
    	goto diag_code
    
    	end

    а тут что-бы работало на f628

    ;**********************************************************************
    ;																	 *
    ;	Filename:		mrx-009.asm									   *
    ;	Date:															*
    ;	File Version:													*
    ;																	 *
    ;	Author:		el@jap.hu										 *
    ;				   http://jap.hu/									*
    ;**********************************************************************
    ;NOTES
    ;
    ; Manchester decoding routine
    ;
    ; supposed crystal freq is 4MHz
    ; T ~= 620 usec (half bit)
    ;
    ;**********************************************************************
    ;HISTORY
    ;
    ;000-20010108
    ;initial version, for MPSIM debugging - simple bit decoding tested
    ; - behaviour on errors is not tested
    ;
    ;001-20010108
    ;to be linked with other external sources
    ;
    ;002-20010109
    ;protocol decoding tested
    ;
    ; header = 16xbit1, 1xbit0 (min/max n. of bit1s in header reqs are not yet checked)
    ; byte = 8xbitX, 1xbit1, 1xbit0
    ;
    ; if not in header, max 9xbit1 or 9xbit0 can be received (which can't be sync'ed to)
    ;
    ;003-20010110
    ;radio receiving tested OK - debug info on LCD
    ; counting 0-4 encoding errors/rcvd packets, displaying protocol errors
    ;
    ;004-20010113
    ; same algorythm without using TMR0
    ; (whis is reserved for measuring timeouts)
    ;
    ;005-20010113
    ;debug on LED. 0=OK, other=error. Point shows validity
    ;
    ;006-20010113
    ;same as 005, plus check buffer checksum and devid
    ;
    ;007-20010113
    ;raw OUT, 5-byte buffer, adapt to C508
    ;
    ;008-20010121
    ;monitor version with LCD
    ;
    ;009-20010123
    ;raw OUT for the 16C505. Based on 007
    ;corresponding transmitter is mtx(014) for the 16C505,
    ; which sends the following format:
    ; data0 -  -  B5 B4 B3 B2 B1 B0
    ; data1 -  -  C5 C4 -  C2 C1 C0
    ;
    ;this is mapped into the 16C620A pins as
    ; PB7-0 C5 C4 B5 B4 B3 B2 B1 B0
    ; PA2-0 -  -  -  V  -  C2 C1 C0
    ;
    ;PA3 shows output validity.
    ;**********************************************************************
    ;define F628
    #define C620
    
    ; the only difference btw. generated C620 & F628 code is the fuse config
    
    #ifdef F628
    #define X62X
    list	  p=16F628			; list directive to define processor
    __CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC & _LVP_OFF
    ;WDT=watchdog, PWRTE=power on timer, XT=external crystal osc
    #include <p16F628.inc>		; processor specific variable definitions
    #endif
    
    #ifdef C620
    #define X62X
    list	  p=16c620a			; list directive to define processor
    __CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
    ;WDT=watchdog, PWRTE=power on timer, XT=external crystal osc
    #include <p16c620a.inc>		; processor specific variable definitions
    #endif
    
    #ifdef X62X
    #define RXBIT PORTA, 4
    #endif
    
    #ifdef C508
    list	p=12c508
    #include <p12C508.inc>
    
    __CONFIG   _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC
    
    #define RXBIT GPIO, 3
    #endif
    
    ;***** VARIABLES
    #define IF_SHORT flags, 0
    #define FIRST_HALF flags, 1
    #define HEADER flags, 2
    #define VALID flags, 7
    
    if_short_val	EQU	1; bit value of IF_SHORT flag
    first_half_val	EQU	2; bit value of FIRST_HALF flag
    
    #ifdef X62X
    .mainda UDATA 0x20
    #endif
    
    #ifdef C508
    .mainda UDATA 0x07
    #endif
    
    bitcnt		res	1
    tmrval		res	1; timer value
    bt		res	1; receive byte buffer
    flags		res	1; decode logic status
    btcnt		res	1; byte counter
    agetmr		res	1; age out timer
    buffer		res	4; receive packet buffer
    bsum		res	1; receive buffer, checksum
    
    
    ;***** CONSTANT VALUES
    hdrcntmin	EQU	0x0c
    hdrcntmax	EQU	0x10
    
    min_t		EQU	.34
    min_2t		EQU	.104
    max_2t		EQU	.174
    
    age_max		EQU	.15; age out last valid packet
    packet_len	EQU	5; packet length, check var. alloc!
    devid1		EQU	0x9a
    devid2		EQU	0xe9
    
    #ifdef X62X
    vectors		CODE 0
    	  goto	main	; go to beginning of program
    	nop
    	nop
    	nop
    			; interrupt vector location
    	retfie
    
    prog		CODE 5
    #endif
    
    #ifdef C508
    	CODE 0
    	movwf OSCCAL
    	goto hwinit_508
    #endif
    
    mp_receive; receive a full manchester-encoded packet
    
    s3	; set flags: first_half=1, if_short=0
    	bsf FIRST_HALF
    s4		bcf IF_SHORT
    
    s5	; init before the received packet
    
    ; set FSR to buffer start
    	movlw buffer
    	movwf FSR
    ; set byte counter
    	movlw packet_len; bytes / packet
    	movwf btcnt
    ; set header receive mode
    	bsf HEADER
    	clrf bitcnt; counting bit1-s in this mode
    
    s2	; wait for a pulse
    	btfss RXBIT
    	goto s2
    
    s6	; wait for end of (short) pulse up to min_2t
    	clrf tmrval
    s6_w		btfss RXBIT
    	goto s7; goto s7 at end of pulse
    
    	incf tmrval, F
    	nop
    	movlw min_2t
    	subwf tmrval, W
    	btfss STATUS, C
    	goto s6_w
    
    ; timeout, exit
    	retlw 1; illegal startbit
    
    s7	; start timer
    	clrf tmrval
    
    s8	; if (if_short & rxbit) goto s9
    ; if (!if_short & !rxbit) goto s9
    ; goto s10
    
    	btfsc IF_SHORT
    ; if_short = 1
    	goto s8_ss1
    
    s8_ss0	; if_short = 0
    	btfsc RXBIT
    	goto s10; rxbit = 1, goto s10
    
    s9_ss0	; if (timer > max_2t) exit - else goto s8
    	movlw max_2t
    	subwf tmrval, W
    	btfsc STATUS, C
    	retlw 2; signal too long
    
    	incf tmrval, F
    	goto s8_ss0
    
    s8_ss1	; if_short = 1
    	btfss RXBIT
    	goto s10; rxbit = 0, goto s10
    
    s9_ss1	; if (timer > max_2t) exit - else goto s8
    	movlw max_2t
    	subwf tmrval, W
    	btfsc STATUS, C
    	retlw 2; signal too long
    
    	incf tmrval, F
    	goto s8_ss1
    
    s10	; invert if_short
    	movlw if_short_val
    	xorwf flags, F
    
    s11	; if (timer < min_t) exit
    	movlw min_t
    	subwf tmrval, W
    	btfss STATUS, C
    	retlw 3; signal too short
    
    s12	; if (timer < min_2t) goto s14
    	movlw min_2t
    	subwf tmrval, W
    	btfss STATUS, C
    	goto s14
    
    s13	; if (first_half = 0) goto s16 - else exit
    	btfss FIRST_HALF
    	goto s16
    	retlw 4; no mid-frame transition/out of sync
    
    s14	; invert first_half
    	movlw first_half_val
    	xorwf flags, F
    
    s15	; if (first_half = 1) goto 7
    	btfsc FIRST_HALF
    	goto s7
    
    s16	; if_short is a decoded bit. Handle here
    	btfss HEADER
    	goto s16_not_header
    
    ; header receiving mode
    	btfss IF_SHORT
    	goto s16_header_end
    
    ; header bit is 1
    	btfss bitcnt, 4; inc up to 16
    	incf bitcnt, F ; 16 is enough...
    
    	call age; age out even if never leaving this loop
    #ifdef NOMAXHDR
    ; test for max header length
    	movlw hdrcntmax
    	subwf bitcnt, W
    	btfss STATUS, C
    #endif
    	goto s7; loop back
    	retlw 9; header too long
    
    s16_header_end; header ends indicated by a 0
    	bcf HEADER
    
    ; test for min header length
    	movlw hdrcntmin
    	subwf bitcnt, W
    	btfss STATUS, C
    	retlw 0x0a; header too short
    
    next_byte	movlw 0x0a
    	movwf bitcnt
    	goto s7; loop back
    
    s16_not_header; receiving bytes
    	decf bitcnt, F
    	bz s16_s4; if (bitcnt = 0) check for a byte-sep 1
    
    ; if (bitcnt = 1) check for a byte-separator 0
    	movlw 1
    	xorwf bitcnt, W
    	bnz s16_s2
    
    ; test for a byte separator 1
    	btfsc IF_SHORT
    	goto s7
    	retlw 7; byte-ending 1 not present
    
    s16_s2	; bit is data
    
    	rrf flags, W
    	rlf bt, F
    	goto s7
    
    s16_s4	; check for a byte-separator 0
    	btfsc IF_SHORT
    	retlw 8; byte-ending 0 not present
    
    ; OK, received byte is sane, store in buffer
    	movf bt, W
    	movwf INDF
    	incf FSR, F
    
    	decfsz btcnt, F
    	goto next_byte
    
    	retlw 0; OK, buffer received
    
    chk_buf	; check buffer sanity by chksum
    	movlw buffer
    	movwf FSR
    	movlw (packet_len-1); number of bytes w/o the chksum byte
    	movwf btcnt
    	clrw
    
    chk0		addwf INDF, W
    	incf FSR, F
    	decfsz btcnt, F
    	goto chk0
    ;chksum is now in W
    
    	subwf bsum, W
    	bnz chk_err
    	retlw 0; result is in Z
    chk_err		retlw 0x0c; checksum error
    
    chk_devid;check if the device id is the same
    ; (first two bytes)
    
    	movlw devid1
    	subwf buffer, W
    	bnz chk_err2
    
    	movlw devid2
    	subwf (buffer+1), W
    	bnz chk_err2
    
    	retlw 0; OK
    chk_err2	retlw 0x0d; devid error
    
    #ifdef C508
    hwinit_508;C508 HARDWARE INIT
    	clrf GPIO
    	clrw; movlw 0x08
    	tris GPIO; all except GP3 is output
    	clrwdt
    	movlw 0x47; no pullup on GP3 (1&0 outputs)
    	option
    #endif
    
    main
    #ifdef X62X
    ;X62X HARDWARE INIT
    	clrf PORTA;set output levels
    	clrf PORTB
    
    	movlw 0x10; PORTA4 is input
    	TRIS PORTA
    
    	MOVLW 0; PORTB outputs
    	TRIS PORTB
    
    	clrwdt; changing default presc. assignment
    	movlw 0x87; prescaler 1:256 assigned to TMR0
    	OPTION	; T0CS selects internal CLK
    
    	movlw 7
    	movwf CMCON; disable analog comparators
    #endif
    
    	clrf TMR0
    	call age_clr; no valid packet
    
    loop		call age
    	call mp_receive
    	andlw 0xff
    	bnz l_skip
    	call chk_buf
    	andlw 0xff
    	bnz l_skip
    	call chk_devid
    
    l_skip		movwf bt; 0=OK, other=error
    
    	movf bt, F
    	btfss STATUS, Z
    	goto loop
    
    ; rx was OK, turn on outputs
    ; buffer+2, buffer+3 contains state information
    
    ; set PA0-PA2 from C0, C1, C2
    ; set PA3 as High (valid output)
    	movf buffer+3, W
    	andlw 0x7
    	xorlw 0x0f
    	movwf PORTA
    
    ; shift C4, C5 to bit#6, bit#7
    	rlf buffer+3, F
    	rlf buffer+3, F
    	movlw 0x3f
    	iorwf buffer+3, F
    
    ; glue together C4, C5 with B0-B5
    	movlw 0xc0
    	iorwf buffer+2, W
    	andwf buffer+3, W
    	xorlw 0xff
    	movwf PORTB
    
    ; set age timer
    	call age_set
    
    	goto loop
    
    age	; time out last packet
    	btfss TMR0, 7
    	return
    
    	clrf TMR0
    	decfsz agetmr, F
    	return
    
    age_clr	; age out
    	bcf VALID
    	movlw age_max
    	movwf agetmr
    
    	clrf PORTA; clear all outputs
    	clrf PORTB
    	return
    
    age_set	; validate now
    	bsf VALID
    	movlw age_max
    	movwf agetmr
    
    ; show validity here
    	return
    
    	end

    схемы соответственно

    post-14370-1242901493_thumb.jpg

    post-14370-1242901503_thumb.jpg

  6. Ясно, по крайней мере вы мне объеснили почему так (с битом защиты), так и я что-то узнал и к вам уважение, мой ответ не легкомысленый, я же сказал подробностей не знаю, если бы я в этом уверен был, тогда можно считать легкомысленым. Форумы для того и существуют что-бы больше узнавать, так что лучше, если человек чегото не знает, объеснить ему, а не нападать, вам же 49 лет, не мне вам объеснять, я еще молодой мне много предстоит узнать еще........

  7. Му504, во первых на эту тему никто не давал ответа, поэтому я ответил, что знал <_< , а если вы сильно продвинутый проффесионал, то ненужно нападать на людей которые меньше вас знают, этим вы вызываете сильную неприязнь, и между прочим не только в этой теме вы так общаетесь.

  8. Привет всем. Собираю устройство радиоуправления на пике, нужен совет какой передатчик лучше использовать, я не имею в виду не дальность, мне нужно узнать о критичности их использование, дают ли они какие то помехи в микроконтроллер, как, что на, что влияет, какими характеристиками должен обладать передатчик, какую модуляцию лучше всего использовать. схема кодера на пике, и передатчика который я решил поставть внизу, почему решил такой передатчик, потомучто схемку когдато собирал для жука, мощная и стабильная к помехам, а подойдет ли она к контроллеру. Помогите плиз.

    post-14370-1242233623_thumb.jpg

    post-14370-1242234162_thumb.jpg

  9. Не одна микруха такой процес на лету делать не будет, очень сложные алгоритмы обработки, ты посмотри когда компьютер это сделает сколько ресурсов уходит, а ты предлагаешь микрухой. И вообще зачем тебе для видеонаблюдения поток ХД, и интерестно через какой канал связи ты это передаешь передавать??? И какой девайс генерирует поток ХД???

  10. а смысл от знаний без практики?))

    Вот что ты этим хотел сказать??? Я что сказал, что мне практика не нужна??? в детстве до класа 10 я очень сильно занимался электроникой, потом это покинул, начел больше учиться теории, постопил на компьюторщика, и там очень хорошо изучил микросхемотехнику и програмирование, немного мк прошли, но практики не было, сейчас начинаю все догонять!!!! Так, что не надо тут наежать!!!

×
×
  • Создать...