General discussion relating to the library modules supplied with the compiler
Moderators: David Barker, Jerry Messina
-
Jerry Messina
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Post
by Jerry Messina » Mon Feb 09, 2009 9:58 am
There appears to be a problem with the usart baud rate routine when using
the 16-bit BRG. The module assumes that the SPBRG/SPBRGH registers
are adjacent in the memory map, and there are a number of devices where
this isn't the case (such as the 18F6680 which I just tried!)
For me, changing the code from
Code: Select all
Public Sub SetBaudrate(pSPBRG As SPBRGRegister = br19200)
RCStatus = $90 // serial port enable, continuous receive
to
Code: Select all
public sub SetBaudrate(pSPBRG as word = br19200)
SPBRG = pSPBRG.byte0
SPBRGH = pSPBRG.byte1
RCStatus = $90 // serial port enable, continuous receive
cleared things up.
Jerry
-
RadioT
- Registered User
- Posts: 157
- Joined: Tue Nov 27, 2007 12:50 pm
- Location: Winnipeg, Canada
Post
by RadioT » Sun Nov 17, 2013 2:46 am
Four years after this post....I just found the same thing on the 18F87J11.
I had been setting SPBRGH1 and SPBRG1 separately, and just lately tried using the SetBaudrate in the USART1 module. It wouldn't work until I tried Jerry's fix.
-Tom