请教各位老师F2812的FIFO问题
想完成的任务:上位机发送10个字节给DSP,DSP将接收到的数据存放在数组a[10]里,并将a[10]发送给上位机,再将数组a[10]中数据值加上0x10后发送给上位机。数据接收使用FIFO,数据发送是直接往SciaRegs.SCITXBUF中写值,没有使能发送FIFO功能及发送FIFO中断。
程序如下
#define ReceBufferLength 10 #define SendBufferLength 8
Uint16 DataReceived[ReceBufferLength];
//-------------------------------------------------- interrupt void ISR_SCIRXINTA(void);
void InitScia(void) { *UART_MODE = 0x44; EALLOW; GpioMuxRegs.GPFMUX.all = 0x0030;//设置GPIO为外设方式 EDIS;
SciaRegs.SCICCR.all = 0x0007; /*------------------------------------------------------------------------------- // Set SCICTL1.SW Reset 0 to reset the SCI module -------------------------------------------------------------------------------*/ SciaRegs.SCICTL1.all = 0x0003; SciaRegs.SCICTL2.all = 0x0002; /*------------------------------------------------------------------------------- // Band Rate = 9600, LSPCLK = 37.5M // BRR = LSPCLK / (band rate * 8) - 1 = 487(0x01E7H) -------------------------------------------------------------------------------*/ SciaRegs.SCIHBAUD = 0x0001; SciaRegs.SCILBAUD = 0x00E7; SciaRegs.SCICTL1.all = 0x0023; PieCtrl.PIEIER9.bit.INTx1 = 1;//允许接收中断 PieCtrl.PIEIER9.bit.INTx2 = 0;//禁止发送中断 }
void InitSciaFIFO(void) { SciaRegs.SCIFFTX.all = 0xe000; SciaRegs.SCIFFRX.all = 0x202a; SciaRegs.SCIFFCT.all = 0x000A; // Set the delay time as 10 clocks SciaRegs.SCIPRI.all = 0x0010; }
interrupt void ISR_SCIRXINTA(void) {
Uint16 i, j; for(i = 0; i < ReceBufferLength; i++) // 接收到的数据存入数组 { DataReceived = SciaRegs.SCIRXBUF.all & Factor_GetData; } for(j = 0; j < ReceBufferLength; j++) // 原值返回 { SciaRegs.SCITXBUF = DataReceived[j]; } for(j = 0; j < (ReceBufferLength); j++) // 原值加0x10返回 { SciaRegs.SCITXBUF = DataReceived[j] + 0x10; }
SciaRegs.SCIFFRX.bit.RXFIFORESET = 0; // Reset the FIFO receive stack SciaRegs.SCIFFRX.bit.RXFIFORESET = 1; // Enable the FIFO receive operation
PieCtrl.PIEACK.all|= PIEACK_GROUP9; }
发送的值是:00 01 02 03 04 05 06 07 08 09
理论上应该收到的是:00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19
但实际收到的是: 00 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19
01 02 03丢失了!
我还发现,如果把FIFO深度改为5,则正确,但是如果深度为5时,连续回送20个数据也会有数据丢失。只要回送的数据超过17个,则会有丢失,只有17个数据被送回。
请问,小弟的问题出在哪里?这个17是怎么回事?是哪个寄存器设的不对吗?请各位帮忙看看,非常感谢!!!
|