PS2
Joined: 05 Mar 2008 Posts: 1
|
PIC18F2525 BRG16 / SPBRG UART PROBLEM |
Posted: Wed Mar 05, 2008 8:06 am |
|
|
Hello,
I made a modbus slave that works correctly at 9600 baud with a 10MHz
crystal. When using a 20MHz crystal arise problems, it works with some
equipments, like a PC, but not with a modbus master built with a
PIC18F4620 (at 20MHz).
I thought it was a problem of baud generator, so, after trying with and
without BRGH1OK switch, I tried to set it by myself, using this parameters
SYNC=0; BRG16=1; SPBRG=520 (SPBRGH=2; SPBRG=8). The values
were calculated using the free program downloaded from micromagic systems.
The map register for PIC18F2525 I used is:
#byte SPBRGH = 0xFB0 // USART baud rate generator high byte
#byte SPBRG = 0xFAF // USART baud rate generator low byte
#bit BRG16 = 0xFAA.3 // 16bit baud rate enable bit (1-16bit, 0-8bit)
#bit SYNC = 0xFAC.4 // USART Mode Select bit (1-sync, 0-async)
Once assigned the values, on the compiler/IDE peripheral window all
the values are set to 0, but appears some register as SPBRG2 that
should be relate to a second UART that shouldn't exist on a PIC18F2525.
What was wrong? It seems as the compiler ignores the registers.
Every help will be appreciated,
thanks in advance |
|