> How can I do to make the line:
>
> SPBRG=FOSC/BAUD/16-1;
>
> assign the correct value to SPBRG in Hi-Tech Pic C Compiler?
>
> Actually it truncates the value of FOSC/BAUD/16, and I want the
> rounded value.
Alvaro:
SPBRG == (FOSC/BAUD/8 + 1)/2 - 1;
-Andy
=== Andrew Warren --- .....aiwKILLspam.....cypress.com
=== IPD Systems Engineering, CYSD
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation
The following works well for me, hope it works for you too (I'm sure
I originally got this from a Hi-Tech sample file but can't find it again
now). I put all the #defines in a header file serial.h and the init
routine and other serial stuff in serial.c. When I need to change
baud rate or crystal frequency for a project then I just need to edit
the values in the header file.
#define BAUD 2400 // Serial comms paramters for init
#define FOSC 1843200L
#define NINE_BITS 0 // Use 9bit comms? FALSE=8bit
#define HIGH_SPEED 0
#define DIVIDER ((int)(FOSC/(64UL * BAUD) -1)) // Divider for low speed
//#define DIVIDER ((int)(FOSC/(16UL * BAUD) -1)) // Divider for high speed