Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Hi D,Using the assembler editor you can make the task easier, because it tells you the records and the error percentage. If memory serves, I think that up to a 2% error rate is acceptable but it is recommended that it be <=1%.
; Compiled with: OshonSoft PIC18 Basic Compiler v4.61
; Microcontroller model: PIC18F46K22
; Clock frequency: 64.0MHz
;
ORG 0x000000
BSF RCON,IPEN
GOTO L0002
ORG 0x000008
RETFIE
ORG 0x000018
RETFIE
; User code start
L0002:
; 1: Define CLOCK_FREQUENCY = 64
; The value of 'CLOCK_FREQUENCY' is 64
; 2: Hseropen 9600
; exact baud rate achieved = 9598.08038; bit period = 104.1875µs; baud rate error = 0.01%
BSF TRISC,6
BSF TRISC,7
MOVLW 0x82
MOVWF SPBRG1
MOVLW 0x06
MOVWF SPBRGH1
CLRF BAUDCON1
BSF BAUDCON1,BRG16
MOVLW 0x24
MOVWF TXSTA1
MOVLW 0x90
MOVWF RCSTA1
; 3: End
L0003 BRA L0003
; Library code
L0001:
RETURN
; End of user code
L0004 BRA L0004
;
;
;
;
;
;
; End of listing
END
... and you still have problems so we can FINALLY put this nonsense to bed about baud rate accuracy that has totally side-tracked you from looking for the real isssue.I also have Crystals, that make the accuracy almost 0%.
If you have a lot of code in your ISR that could be an issue. Many people make the mistake of trying to process the uart data inside the ISR instead of using the interrupt for what it should be, which is to gather up the incoming bytes into a buffer.At the moment we are shortening and re-checking the INTERRUPTS to make them as short as poss
Hi C.. Remember waaayy back. I wrote a circular buffer for Oshonsoft. I think I gave you a copy.
Hi T,... and you still have problems so we can FINALLY put this nonsense to bed about baud rate accuracy that has totally side-tracked you from looking for the real isssue.
If you have a lot of code in your ISR that could be an issue. Many people make the mistake of trying to process the uart data inside the ISR instead of using the interrupt for what it should be, which is to gather up the incoming bytes into a buffer.
At 38400 baud you have roughly 250us between bytes. An easy way to check this is to set a pin high on entry to the ISR and set it low right before returning. Watch the pin with a scope/logic analyser to see how long your ISR is taking.
Hi R and D,Hi C.. Remember waaayy back. I wrote a circular buffer for Oshonsoft. I think I gave you a copy.
Hi T,You don't have to use ring buffers, it just usually makes the code easier.
As long as your mate is processing the chars in < 250us you shouldn't have much of a problem from that side of things.
You don't have to use ring buffers, it just usually makes the code easier.
You don't have to use ring buffers, it just usually makes the code timing easier.
Hi T,I should probably clarify this...
Adding circular buffers won't usually make the coding itself easier, it's just that if all the ISR has to do is add chars to the buffer with no/little processing then the ISR is simpler and faster. You still have to deal with processing things outside the ISR in your main program, which can actually make it a bit more complicated.
Hi R,Question:
If you are relying on someone else to do much of the programming anyway - why does the language matter???
If you had used C, far more people could help, using fully proven code, and the project could have been working long ago?
I would really like to use C++, no chance!
Hi N and D,Not a chance on an 18F PIC - C only.
Never say never, I did after MANY years, and numerous failed attempts.Hi N and D,
When I said "not a chance" I meant that there is no chance that I could learn C.
C.