Other Parts Discussed in Thread: C2000WARE
In SCI_LOOPBACK_INTERRUPTS example for F28075 from C2000Ware V1.00 "Example_2807xSci_FFDLB_int.c" the SCI baud rate initialized as follows:
.
.
.
//
// Defines
//
#define CPU_FREQ 60E6
#define LSPCLK_FREQ CPU_FREQ/4
#define SCI_FREQ 100E3
#define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1
.
.
.
SciaRegs.SCIHBAUD.all = 0x0000;
SciaRegs.SCILBAUD.all = SCI_PRD;
.
.
.
The above code in some cases with low baud rate that SCI_PRD becomes greater than 8bit does not work. The upper 8bit should be loaded to SCIHBAUD:
SciaRegs.SCIHBAUD.all = SCI_PRD>>8;
SciaRegs.SCILBAUD.all = SCI_PRD;
Another issue is that as a general rule in C programming, the whole define expression specially when contains + or - operators should be enclosed in parentheses:
#define SCI_PRD ((LSPCLK_FREQ/(SCI_FREQ*8))-1)
although the original code works fine, if for example you want to quickly double the period you will not get the expected result:
SciaRegs.SCILBAUD.all = SCI_PRD *2;
without parentheses the above expands to:
SciaRegs.SCILBAUD.all = (LSPCLK_FREQ/(SCI_FREQ*8))-1*2; //only doubles -1
I noticed the same issues exists in many other Piccolo example codes.
MHG