- Joined
- Jan 22, 2008
- Messages
- 53,132
- Helped
- 14,792
- Reputation
- 29,871
- Reaction score
- 14,293
- Trophy points
- 1,393
- Location
- Bochum, Germany
- Activity points
- 301,165
Obviously, yes.Is it right ?
;PrePhase condition. Three bytes of 0x66 should be received consecutively from
;the preamble data before assuming it is safe to move to SyncPhase. Byte in error
;will be 0x69 or 0x99 so if these are found, reset the USART and try again.
RxFraming
sublw 0x66 ;set Z flag if correct phase
btfsc STATUS,Z ;skip if incorrect phase
goto CheckRxPreCount
banksel RCSTA
bcf RCSTA,CREN ;bad framing so reset USART
movf RCREG,W ;make sure RXREG and FIFO are cleared
movf RCREG,W
bsf RCSTA,CREN
clrf RxPreCount ;reset good frame counter
return
CheckRxPreCount
incf RxPreCount ;add to count of good frames
movlw 0x03 ;threshold for good frame counts
subwf RxPreCount,W ;check if enough frames seem valid
btfss STATUS,C ;skip if >= 3
return ;try again
clrf RxPhase
bsf RxPhase,SyncPhase ;move to next stage of checking
return
betwixt said:In my design, I send 20 bytes of 66h as preamble, this is to allow time for the receiver AGC to settle and the data slicer to adapt, then I send one byte of A6h to sync the data stream.
My receive code, which is called every time the UART receives a byte is:
Code:;PrePhase condition. Three bytes of 0x66 should be received consecutively from ;the preamble data before assuming it is safe to move to SyncPhase. Byte in error ;will be 0x69 or 0x99 so if these are found, reset the USART and try again. RxFraming sublw 0x66 ;set Z flag if correct phase ............... ........... Brian.[/quote] to reset the uart is very fast only a few machine cycle, it's to fast compare with the bit time (let's say at 9,6Kb), so if i don't put extra delay on it, i believe that after uart reset rutine, the uart find the new start bit right after an error byte (0x69 or 0x99) and than the uart will recieved the same error byte as previous byte do i have add some delay (1 bit time) before reseting the uart? sorry i submmited many post, while I'm learning and thinking , :D best regard davids
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?