1.宏定义
//以下定义来自windows里的winbase.h并改造
#define CBR_110 11E1
#define CBR_300 3E2
#define CBR_600 6E2
#define CBR_1200 12E2
#define CBR_2400 24E2
#define CBR_4800 48E2
#define CBR_9600 96E2
#define CBR_14400 144E2
#define CBR_19200 192E2
#define CBR_38400 384E2
#define CBR_56000 56E3
#define CBR_57600 576E2
#define CBR_115200 1152E2
#define CBR_128000 128E3
#define CBR_256000 256E3
#define CPU_FREQ 150E6
#define LSPCLK_FREQ CPU_FREQ/4
#define SCI_FREQ CBR_38400//波特率38400
#define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1//此法在头文件中应用时不清晰
//以下由菜农改编
#define SCI_BAUD(baud) (LSPCLK_FREQ/(baud*8))-1
2.设置波特率
SciaRegs.SCIHBAUD = 0x0000;
SciaRegs.SCILBAUD = SCI_PRD;//实际的BaudRate在头文件中
//或 SciaRegs.SCILBAUD = SCI_BAUD(CBR_38400);//此法较清晰,BaudRate=38400 |