我的想法是通过FIFO接收中断,来触发发送中断,将从PC接收到得数据,再发送到PC。
不知道为什么总是触发不了SCI的发送中断,也接收到的不到数据。
#include "DSP28x_Project.h"
#include "string.h"
interrupt void scibTxFifoIsr(void);
interrupt void scibRxFifoIsr(void);
void scib_fifo_init(void);
char rdataB[8];
void main(void)
{
Uint16 i;
InitSysCtrl();
InitSciGpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.SCIRXINTB = &scibRxFifoIsr;
PieVectTable.SCITXINTB = &scibTxFifoIsr;
EDIS;
scib_fifo_init();
for(i = 0; i<8; i++)
{
rdataB[i] =0;
}
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEIER9.bit.INTx3=1;
PieCtrlRegs.PIEIER9.bit.INTx4=1;
IER = 0x100;
EINT;
for(;;);
}
interrupt void scibTxFifoIsr(void)
{
Uint16 i;
for(i=0; i< 8; i++)
{
ScibRegs.SCITXBUF=rdataB[i];
}
//ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;
PieCtrlRegs.PIEACK.all|=0x100;
}
当我将上面的TXFFINTCLR置1的时候,就会不停的发送0,不发送rdataB数组中的内容。下面的接收中断的中断级位设为8,我的想法是PC发送一个hellodsp,触发接收中断,在接收中断服务子程序中通过strncmp函数比对,通过TXFFINTCLR置1,使发送相应中断。然后在发送中断中在发送radaB数组,即在PC串口软件端显示hellodsp。
可不知道为什么总是进步了接收中断,rdataB数组里面也没有值…..求高工解答!
interrupt void scibRxFifoIsr(void)
{
Uint16 i;
for(i=0;i<8;i++)
{
//while(ScibRegs.SCIFFRX.bit.RXFFST!=1){}
rdataB[i]=ScibRegs.SCIRXBUF.all;
}
if(strncmp(rdataB,"hellodsp",8)==0)
{
//ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1;
ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;
}
//ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;
//ScibRegs.SCIFFRX.bit.RXFIFORESET=0;
//ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
ScibRegs.SCIFFRX.bit.RXFFOVRCLR=1;
ScibRegs.SCIFFRX.bit.RXFFINTCLR=1;
PieCtrlRegs.PIEACK.all|=0x100;
}
void scib_fifo_init()
{
ScibRegs.SCICCR.all =0x0007;
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.TXINTENA =1;
ScibRegs.SCICTL2.bit.RXBKINTENA =1;
ScibRegs.SCIHBAUD =0x0001;
ScibRegs.SCILBAUD =0x00E7;
ScibRegs.SCICCR.bit.LOOPBKENA =0;
ScibRegs.SCIFFTX.all=0xC028;
ScibRegs.SCIFFRX.all=0x0028;
ScibRegs.SCIFFCT.all=0x00;
ScibRegs.SCICTL1.all =0x0023;
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1;
ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
}
rui liu4:
回复 Jones Chen:
你好,我用的SCI FIFO中断,485通信,但是接收中断一直无法进入,求大神帮忙指导一下
我的想法是通过FIFO接收中断,来触发发送中断,将从PC接收到得数据,再发送到PC。
不知道为什么总是触发不了SCI的发送中断,也接收到的不到数据。
#include "DSP28x_Project.h"
#include "string.h"
interrupt void scibTxFifoIsr(void);
interrupt void scibRxFifoIsr(void);
void scib_fifo_init(void);
char rdataB[8];
void main(void)
{
Uint16 i;
InitSysCtrl();
InitSciGpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.SCIRXINTB = &scibRxFifoIsr;
PieVectTable.SCITXINTB = &scibTxFifoIsr;
EDIS;
scib_fifo_init();
for(i = 0; i<8; i++)
{
rdataB[i] =0;
}
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEIER9.bit.INTx3=1;
PieCtrlRegs.PIEIER9.bit.INTx4=1;
IER = 0x100;
EINT;
for(;;);
}
interrupt void scibTxFifoIsr(void)
{
Uint16 i;
for(i=0; i< 8; i++)
{
ScibRegs.SCITXBUF=rdataB[i];
}
//ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;
PieCtrlRegs.PIEACK.all|=0x100;
}
当我将上面的TXFFINTCLR置1的时候,就会不停的发送0,不发送rdataB数组中的内容。下面的接收中断的中断级位设为8,我的想法是PC发送一个hellodsp,触发接收中断,在接收中断服务子程序中通过strncmp函数比对,通过TXFFINTCLR置1,使发送相应中断。然后在发送中断中在发送radaB数组,即在PC串口软件端显示hellodsp。
可不知道为什么总是进步了接收中断,rdataB数组里面也没有值…..求高工解答!
interrupt void scibRxFifoIsr(void)
{
Uint16 i;
for(i=0;i<8;i++)
{
//while(ScibRegs.SCIFFRX.bit.RXFFST!=1){}
rdataB[i]=ScibRegs.SCIRXBUF.all;
}
if(strncmp(rdataB,"hellodsp",8)==0)
{
//ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1;
ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;
}
//ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;
//ScibRegs.SCIFFRX.bit.RXFIFORESET=0;
//ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
ScibRegs.SCIFFRX.bit.RXFFOVRCLR=1;
ScibRegs.SCIFFRX.bit.RXFFINTCLR=1;
PieCtrlRegs.PIEACK.all|=0x100;
}
void scib_fifo_init()
{
ScibRegs.SCICCR.all =0x0007;
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.TXINTENA =1;
ScibRegs.SCICTL2.bit.RXBKINTENA =1;
ScibRegs.SCIHBAUD =0x0001;
ScibRegs.SCILBAUD =0x00E7;
ScibRegs.SCICCR.bit.LOOPBKENA =0;
ScibRegs.SCIFFTX.all=0xC028;
ScibRegs.SCIFFRX.all=0x0028;
ScibRegs.SCIFFCT.all=0x00;
ScibRegs.SCICTL1.all =0x0023;
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1;
ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
}
zhao hj:
回复 rui liu4:
问下你的485通信弄好了吗?我不用中断可以通信,现在用FIFO中断,程序一直进去发送中断,你的EN怎样设置的?