-
GPIO端口配置如下:
InitSysCtrl();
InitSciaGpio();
scia_fifo_init(); // Initialize the SCI FIFO
scia_echoback_init(); // Initalize SCI for echoback
InitSciaGpio();
scia_fifo_init(); // Initialize the SCI FIFO
scia_echoback_init(); // Initalize SCI for echoback
void scia_echoback_init()
{
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.all =0x0003;
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
//CPU_FRQ_150MHZ
SciaRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 37.5MHz.
SciaRegs.SCILBAUD =0x00E7;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
// Initalize the SCI FIFO
void scia_fifo_init()
{
SciaRegs.SCIFFTX.all=0xE040;
SciaRegs.SCIFFRX.all=0x204f;
SciaRegs.SCIFFCT.all=0x0;
}
{
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.all =0x0003;
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
//CPU_FRQ_150MHZ
SciaRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 37.5MHz.
SciaRegs.SCILBAUD =0x00E7;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
// Initalize the SCI FIFO
void scia_fifo_init()
{
SciaRegs.SCIFFTX.all=0xE040;
SciaRegs.SCIFFRX.all=0x204f;
SciaRegs.SCIFFCT.all=0x0;
}
2. 配置SCIA收发中断的HWI
Hwi_Params scirxinta_hwiParams,scitxinta_hwiParams;
Error_Block eb_isr;
Error_init(&eb_isr);
Hwi_Params_init(&scirxinta_hwiParams);
scirxinta_hwiParams.arg = 10;
scirxinta_hwiParams.enableInt = FALSE;
//scirxinta_hwiParams.eventId = 96;
scirxinta_hwiParams.maskSetting = Hwi_MaskingOption_SELF;
scirxinta_hwi = Hwi_create(96, scirxinta_isr, &scirxinta_hwiParams, &eb_isr);
if (scirxinta_hwi == NULL) {
System_abort("scirxinta_hwi create failed");
System_flush();
}
Hwi_Params_init(&scitxinta_hwiParams);
scitxinta_hwiParams.arg = 10;
scitxinta_hwiParams.enableInt = FALSE;
//scitxinta_hwiParams.eventId = 97;
scitxinta_hwiParams.maskSetting = Hwi_MaskingOption_SELF;
scitxinta_hwi = Hwi_create(97, scitxinta_isr, &scitxinta_hwiParams, &eb_isr);
if (scitxinta_hwi == NULL) {
System_abort("scitxinta_hwi create failed");
System_flush();
}
/* enable both interrupts */
Hwi_enableInterrupt(96);
Hwi_enableInterrupt(97);
Error_Block eb_isr;
Error_init(&eb_isr);
Hwi_Params_init(&scirxinta_hwiParams);
scirxinta_hwiParams.arg = 10;
scirxinta_hwiParams.enableInt = FALSE;
//scirxinta_hwiParams.eventId = 96;
scirxinta_hwiParams.maskSetting = Hwi_MaskingOption_SELF;
scirxinta_hwi = Hwi_create(96, scirxinta_isr, &scirxinta_hwiParams, &eb_isr);
if (scirxinta_hwi == NULL) {
System_abort("scirxinta_hwi create failed");
System_flush();
}
Hwi_Params_init(&scitxinta_hwiParams);
scitxinta_hwiParams.arg = 10;
scitxinta_hwiParams.enableInt = FALSE;
//scitxinta_hwiParams.eventId = 97;
scitxinta_hwiParams.maskSetting = Hwi_MaskingOption_SELF;
scitxinta_hwi = Hwi_create(97, scitxinta_isr, &scitxinta_hwiParams, &eb_isr);
if (scitxinta_hwi == NULL) {
System_abort("scitxinta_hwi create failed");
System_flush();
}
/* enable both interrupts */
Hwi_enableInterrupt(96);
Hwi_enableInterrupt(97);
/* Runs when interrupt 96 occurs */
Void scirxinta_isr(UArg arg)
{
System_printf("enter scirxinta_hwi! \n");
System_flush();
int a,b;
a =1;
b = a + 2;
UInt16 tmp1,tmp2;
tmp1 = SciaRegs.SCIRXBUF.all;
LoopCount++;
}
/* Runs when interrupt 97 occurs */
Void scitxinta_isr(UArg arg)
{
System_printf("enter scitxinta_isr! \n");
System_flush();
int b;
b =1;
LoopCount++;
}
Void scirxinta_isr(UArg arg)
{
System_printf("enter scirxinta_hwi! \n");
System_flush();
int a,b;
a =1;
b = a + 2;
UInt16 tmp1,tmp2;
tmp1 = SciaRegs.SCIRXBUF.all;
LoopCount++;
}
/* Runs when interrupt 97 occurs */
Void scitxinta_isr(UArg arg)
{
System_printf("enter scitxinta_isr! \n");
System_flush();
int b;
b =1;
LoopCount++;
}
4. 同时,我配置了一个定时器中断,这个功能正常,可以进入中断函数
timerParams.period = 1000;
timer = Timer_create(Timer_ANY, hwiFxn, &timerParams, &eb_tm);
if (timer == NULL) {
System_abort("Timer create failed");
}
timer = Timer_create(Timer_ANY, hwiFxn, &timerParams, &eb_tm);
if (timer == NULL) {
System_abort("Timer create failed");
}
Void hwiFxn(UArg arg)
{
int b;
b =1;
LoopCount++;
}
{
int b;
b =1;
LoopCount++;
}