This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049C: 使用sci的fifo进行串行数据的发送正常,接收异常?

Part Number: TMS320F280049C


#include "driverlib.h"
#include "device.h"
 
#ifdef _FLASH
// These are defined by the linker (see device linker command file)
extern uint16_t RamfuncsLoadStart;
extern uint16_t RamfuncsLoadSize;
extern uint16_t RamfuncsRunStart;
#endif
 
//
// Defines
//
// Define AUTOBAUD to use the autobaud lock feature
//#define AUTOBAUD
 
//
// Globals
//
uint16_t counter = 0;
unsigned char *msg;
//
// Function Prototypes
//
__interrupt void sciaTxISR(void);
__interrupt void sciaRxISR(void);
 
//
// Main
//
void main(void)
{
    //
    // Configure PLL, disable WD, enable peripheral clocks.
    //
    Device_init();
 
    //
    // Disable pin locks and enable internal pullups.
    //
    Device_initGPIO();
 
    //
    // GPIO28 is the SCI Rx pin.
    //
    GPIO_setMasterCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);            //选择指定GPIO28引脚,主核心为CPU1
    GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);                             //GPIO28配置为SCI的 RX接收引脚
    GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);       //GPIO28引脚 设置为输入
    GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);          //GPIO28引脚引脚类型 为浮动输入
    GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);    //GPIO28参数条件模式 为关闭同步
 
    //
    // GPIO29 is the SCI Tx pin.
    //
    GPIO_setMasterCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);            //选择指定GPIO29引脚,主核心为CPU1
    GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);                             //GPIO29配置为SCI的 TX发送引脚
    GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);      //GPIO29引脚 设置为输出
    GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);          //GPIO29引脚引脚类型 为推挽输出
    GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);    //GPIO29参数条件模式 为关闭同步
 
 
    //
    // Disable global interrupts.
    //
    DINT; //禁用全局中断
 
    //
    // Initialize interrupt controller and vector table.
    //
    Interrupt_initModule();                                                  //初始化PIE并清除PIE寄存器
    Interrupt_initVectorTable();                                             //用指向shell中断的指针初始化PIE向量表ISR服务程序
    IER = 0x0000;                                                            //中断使能寄存器 置0
    IFR = 0x0000;                                                            //中断标志寄存器 置0
 
 
    //
    // Map the ISR to the wake interrupt.
    //
    Interrupt_register(INT_SCIA_TX, sciaTxISR);//将中断函数与中断向量表映射
    Interrupt_register(INT_SCIA_RX, sciaRxISR);
 
    //
    // Initialize SCIA and its FIFO.
    //
    SCI_performSoftwareReset(SCIA_BASE);//软件重置初始化SCIA
 
    //
    // Configure SCIA for echoback.
    //
    SCI_setConfig(SCIA_BASE, 25000000, 9600, (SCI_CONFIG_WLEN_8 |
                                             SCI_CONFIG_STOP_ONE |
                                             SCI_CONFIG_PAR_NONE));//初始化
    SCI_resetChannels(SCIA_BASE);//通道重置
    SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF | SCI_INT_RXFF);//清除接收、发送中断寄存器标志位
    SCI_enableFIFO(SCIA_BASE);//使能FIFO
    SCI_enableModule(SCIA_BASE);//使能接收、发送、重启SCI
    SCI_performSoftwareReset(SCIA_BASE);//软件重置SCIA
 
 
    //
    // Set the transmit FIFO level to 0 and the receive FIFO level to 2.
    // Enable the TXFF and RXFF interrupts.
    //
    SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX0, SCI_FIFO_RX3);//FIFO深度设置
    SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXFF | SCI_INT_RXFF);//使能接收、发送中断寄存器标志位
 
    //
    // Send starting message.
    //
    msg = "\r\n\n\nHello World!\0";
    SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 17);
    msg = "\r\nYou will enter a character, and the DSP will echo it back!\0";
    SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 61);
 
    //
    // Clear the SCI interrupts before enabling them.
    //
    SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF | SCI_INT_RXFF);//清除接收、发送中断寄存器标志位
 
    //
    // Enable the interrupts in the PIE: Group 9 interrupts 1 & 2.
    //
    Interrupt_enable(INT_SCIA_RX);//使能外设中断RX、TX
    Interrupt_enable(INT_SCIA_TX);
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);//9号中断向量组的9.1、9.2号
 
    //
    // Enable global interrupts.
    //
    EINT;
 
    for(;;)
    {
    }
}
 
//
// sciaTxISR - Disable the TXFF interrupt and print message asking
//             for two characters.
 
__interrupt void
sciaTxISR(void)
{
    //
    // Disable the TXRDY interrupt.
    //
    SCI_disableInterrupt(SCIA_BASE, SCI_INT_TXFF);
 
 
    msg = "\r\nEnter two characters: \0";
    SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 25);
    //
    // Acknowledge the PIE interrupt.
    //
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
//
// sciaRxISR - Read two characters from the RXBUF and echo them back.
//
__interrupt void
sciaRxISR(void)
{
    uint16_t receivedChar1, receivedChar2, receivedChar3;//receivedChar4;
    //
    // Enable the TXFF interrupt again.
    //
    SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXFF);
    //
    // Read two characters from the FIFO.                      //读取三次sci
    //
    receivedChar1 = SCI_readCharBlockingFIFO(SCIA_BASE);
    receivedChar2 = SCI_readCharBlockingFIFO(SCIA_BASE);
    receivedChar3 = SCI_readCharBlockingFIFO(SCIA_BASE);
    //
    // Echo back the two characters.
    //
    msg = "  You sent: \0";
    SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 13);
    SCI_writeCharBlockingFIFO(SCIA_BASE, receivedChar1);         //发送三次读取到的数据
    SCI_writeCharBlockingFIFO(SCIA_BASE, receivedChar2);
    SCI_writeCharBlockingFIFO(SCIA_BASE, receivedChar3);
    //
    // Clear the SCI RXFF interrupt and acknowledge the PIE interrupt.
    //
    SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXFF);
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    counter++;
}
//
// End of File
//

1,上面是参考demo通过SCIA进行FIFO的数据收发,发现只能发送,但是接收不到数据,请问问题是出在哪儿?

2,请问下,FIFO发送,如何实现485的流控?