Thanks DT. I will follow your advice.
Thanks DT. I will follow your advice.
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
I am confused again. Funny how I never ran into this before...
The below only works at OSC 32 and below.
Why does it work above OSC 32 if it is DEFINED?Code:RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $20 ' Enable transmit, BRGH = 0 SPBRG = 225 ' 2400 Baud @ 0.0% SPBRGH = 4 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
But these work with the 202 Warning. 2400 BAUD will not work like this.
Work meaning it displays on a terminal.
Code:RUN: '9600 BAUD RCSTA=$90:TXSTA=$20:SPBRG=77 RCSTA.4 = 0 : RCSTA.4 = 1 HSEROUT ["HOWDY THERE",$d,$a] PAUSE 250 GOTO RUNSetupCode:RUN: '4800 BAUD RCSTA=$90:TXSTA=$20:SPBRG=155 RCSTA.4 = 0 : RCSTA.4 = 1 HSEROUT ["HOWDY THERE",$d,$a] PAUSE 250 GOTO RUN
Once a NEWBE always a NEWBECode:'4550 HSER TEST'18F4550'06/20/10 DEFINE OSC 48 @ __CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L @ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H @ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H @ __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H @ __CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L &_XINST_OFF_4L![]()
Dave
Always wear safety glasses while programming.
Dave, it's the same thing as from post #6.
If there is an HSERIN or HSEROUT anywhere in your program. PBP will initialize the USART at the beginning of the program, before jumping to user code.
If you don't set the defines, PBP defaults to 2400 baud and standard USART mode (8-bit BRG).
Anything above 32mhz, and 2400 baud is too slow for a standard USART. SPBRG ends up larger than 255, and throws an out of range warning.
If you define HSER_SPBRG, then PBP does not try to calculate SPBRG ... hence no warning.
If you define an HSER_BAUD that works at that OSC, it calculates a valid SPBRG and also doesn't give a warning.
Once you've made it past the Initialization, you can manually set the EUSART registers for whatever baud rate you want.
hth,
DT
Thanks again Darrel for your help.
This is the part that I was not getting
For some reason I thought PBP went line by line when compiling so I did not understand why setting the registers before HSERIN did not do the same as DEFINE XX.If there is an HSERIN or HSEROUT anywhere in your program. PBP will initialize the USART at the beginning of the program, before jumping to user code.
I am beginning to get it.![]()
Dave
Always wear safety glasses while programming.
Bookmarks