I am using the following
#chip 16F916, 20 'mhz
#config MCLRE=off, WDT=off
#define USART_BAUD_RATE 115200
#define USART_BLOCKING
InitUsart
On Interrupt UsartRX1Ready call get_data
lcdcon = 0
dir portc.7 in 'serial rx p18
dim temp as byte
dim loc as byte
sub get_data
If RCIF On Then serdata = RCREG
temp = serdata
epwrite loc, temp
loc = loc + 1
end sub
I can not get good communication at 115200 baud, i have heard there are some issues with the calculations in gcbasic for that speed, is this true? what fixes it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using 115200 with a PIC18F4455 and it seems to work fine.
Beware of EPWrites inside the interrupt service routine. Each one takes a couple ms to complete, and at this speed it could cause you to miss the next character.
Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Then perhaps this is your problem ( it was mine), the theoretical value toi SPBRG is 9.85, but this is "cutted" to 9, when it should be rounded to 10.
To fix this you can edit: GcBasic/include/lowlevel/usart.h line 89 and add a "+0.5"
'Get high and low bytes
SPBRGL_TEMP = Int(SPBRG_TEMP + 0.5) And 255
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using the following
#chip 16F916, 20 'mhz
#config MCLRE=off, WDT=off
#define USART_BAUD_RATE 115200
#define USART_BLOCKING
InitUsart
On Interrupt UsartRX1Ready call get_data
lcdcon = 0
dir portc.7 in 'serial rx p18
dim temp as byte
dim loc as byte
sub get_data
If RCIF On Then serdata = RCREG
temp = serdata
epwrite loc, temp
loc = loc + 1
end sub
I can not get good communication at 115200 baud, i have heard there are some issues with the calculations in gcbasic for that speed, is this true? what fixes it?
I'm using 115200 with a PIC18F4455 and it seems to work fine.
Beware of EPWrites inside the interrupt service routine. Each one takes a couple ms to complete, and at this speed it could cause you to miss the next character.
Joe
Have a look to the generated asm, at sub: INITUARST, it should be like this (for 115200 at 20 MHz):
;********************************************************************************
INITUSART
movlw 10
banksel SPBRG
movwf SPBRG
If you have:
;********************************************************************************
INITUSART
movlw 9
banksel SPBRG
movwf SPBRG
Then perhaps this is your problem ( it was mine), the theoretical value toi SPBRG is 9.85, but this is "cutted" to 9, when it should be rounded to 10.
To fix this you can edit: GcBasic/include/lowlevel/usart.h line 89 and add a "+0.5"
'Get high and low bytes
SPBRGL_TEMP = Int(SPBRG_TEMP + 0.5) And 255