TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320F28388D: 28388D串口接收无法进入中断的问题

Part Number:TMS320F28388D

我在TMS320F28388D controlCARD进行开发,将sci_ex2_loopback_interrupts.c的例程改为以下,但是无法进入接收中断,请问是为什么?

//###########################################################################
//
// FILE:sci_ex2_loopback_interrupts.c
//
// TITLE:  SCI Digital Loop Back with Interrupts.
//
//! \addtogroup driver_example_list
//! <h1> SCI Digital Loop Back with Interrupts </h1>
//!
//!  This test uses the internal loop back test mode of the peripheral.
//!  Other then boot mode pin configuration, no other hardware configuration
//!  is required. Both interrupts and the SCI FIFOs are used.
//!
//!  A stream of data is sent and then compared to the received stream.
//!  The SCI-A sent data looks like this: \n
//!  00 01 \n
//!  01 02 \n
//!  02 03 \n
//!  .... \n
//!  FE FF \n
//!  FF 00 \n
//!  etc.. \n
//!  The pattern is repeated forever.
//!
//!  \b Watch \b Variables \n
//!  - \b sDataA - Data being sent
//!  - \b rDataA - Data received
//!  - \b rDataPointA - Keep track of where we are in the data stream.
//!This is used to check the incoming data
//!
//
//###########################################################################
//
//
// $Copyright: $
//###########################################################################

//
// Included Files
//
#include "driverlib.h"
#include "device.h"

//
// Globals
//

//
// Send data for SCI-A
//
uint16_t sDataA[2];

//
// Received data for SCI-A
//
uint16_t rDataA[2];

//
// Used for checking the received data
//
uint16_t rDataPointA;

//
// Function Prototypes
//
__interrupt void sciaTXFIFOISR(void);
__interrupt void sciaRXFIFOISR(void);
void initSCIAFIFO(void);
void error(void);

//
// Main
//
void main(void)
{uint16_t i;//// Initialize device clock and peripherals//Device_init();//// Setup GPIO by disabling pin locks and enabling pullups//Device_initGPIO();//// GPIO28 is the SCI Rx pin.//GPIO_setMasterCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);//// GPIO29 is the SCI Tx pin.//GPIO_setMasterCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);//// Initialize PIE and clear PIE registers. Disables CPU interrupts.//Interrupt_initModule();//// Initialize the PIE vector table with pointers to the shell Interrupt// Service Routines (ISR).//Interrupt_initVectorTable();//// Interrupts that are used in this example are re-mapped to// ISR functions found within this file.//Interrupt_register(INT_SCIA_RX, sciaRXFIFOISR);
//Interrupt_register(INT_SCIA_TX, sciaTXFIFOISR);//// Initialize the Device Peripherals://initSCIAFIFO();//// Init the send data.  After each transmission this data// will be updated for the next transmission//for(i = 0; i < 2; i++){sDataA[i] = i;}rDataPointA = sDataA[0];Interrupt_enable(INT_SCIA_RX);
//Interrupt_enable(INT_SCIA_TX);Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);//// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)//EINT;ERTM;//// IDLE loop. Just sit and loop forever (optional)://for(;;);
}

//
// error - Function to halt debugger on error
//
void error(void)
{asm("ESTOP0"); // Test failed!! Stop!for (;;);
}

//
// sciaTXFIFOISR - SCIA Transmit FIFO ISR
//
__interrupt void sciaTXFIFOISR(void)
{uint16_t i;SCI_writeCharArray(SCIA_BASE, sDataA, 2);//// Increment send data for next cycle//for(i = 0; i < 2; i++){sDataA[i] = (sDataA[i] + 1) & 0x00FF;}SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF);//// Issue PIE ACK//Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}

//
// sciaRXFIFOISR - SCIA Receive FIFO ISR
//
__interrupt void sciaRXFIFOISR(void)
{uint16_t i;SCI_readCharArray(SCIA_BASE, rDataA, 2);//// Check received data//
//for(i = 0; i < 2; i++)
//{
//if(rDataA[i] != ((rDataPointA + i) & 0x00FF))
//{
//error();
//}
//}rDataPointA = (rDataPointA + 1) & 0x00FF;SCI_clearOverflowStatus(SCIA_BASE);SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXFF);//// Issue PIE ack//Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}

//
// initSCIAFIFO - Configure SCIA FIFO
//
void initSCIAFIFO()
{//// 8 char bits, 1 stop bit, no parity. Baud rate is 9600.//SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |SCI_CONFIG_STOP_ONE |SCI_CONFIG_PAR_NONE));SCI_enableModule(SCIA_BASE);SCI_disableLoopback(SCIA_BASE);SCI_resetChannels(SCIA_BASE);SCI_enableFIFO(SCIA_BASE);//// RX and TX FIFO Interrupts Enabled//SCI_enableInterrupt(SCIA_BASE, SCI_INT_RXFF);SCI_disableInterrupt(SCIA_BASE, SCI_INT_RXERR);//// The transmit FIFO generates an interrupt when FIFO status// bits are less than or equal to 2 out of 16 words// The receive FIFO generates an interrupt when FIFO status// bits are greater than equal to 2 out of 16 words//SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX2, SCI_FIFO_RX2);SCI_performSoftwareReset(SCIA_BASE);

//SCI_resetTxFIFO(SCIA_BASE);SCI_resetRxFIFO(SCIA_BASE);
}

//
// End of file
//

Green Deng:

烦请标明例程中具体修改的点有哪些。

,

user6327524:

//###########################################################################
//
// FILE:sci_ex2_loopback_interrupts.c
//
// TITLE:SCI Digital Loop Back with Interrupts.
//
//! \addtogroup driver_example_list
//! <h1> SCI Digital Loop Back with Interrupts </h1>
//!
//!This test uses the internal loop back test mode of the peripheral.
//!Other then boot mode pin configuration, no other hardware configuration
//!is required. Both interrupts and the SCI FIFOs are used.
//!
//!A stream of data is sent and then compared to the received stream.
//!The SCI-A sent data looks like this: \n
//!00 01 \n
//!01 02 \n
//!02 03 \n
//!.... \n
//!FE FF \n
//!FF 00 \n
//!etc.. \n
//!The pattern is repeated forever.
//!
//!\b Watch \b Variables \n
//!- \b sDataA - Data being sent
//!- \b rDataA - Data received
//!- \b rDataPointA - Keep track of where we are in the data stream.
//!This is used to check the incoming data
//!
//
//###########################################################################
//
//
// $Copyright: $
//###########################################################################//
// Included Files
//
#include "driverlib.h"
#include "device.h"//
// Globals
////
// Send data for SCI-A
//
uint16_t sDataA[2];//
// Received data for SCI-A
//
uint16_t rDataA[2];//
// Used for checking the received data
//
uint16_t rDataPointA;//
// Function Prototypes
//
__interrupt void sciaTXFIFOISR(void);
__interrupt void sciaRXFIFOISR(void);
void initSCIAFIFO(void);
void error(void);//
// Main
//
void main(void)
{uint16_t i;//// Initialize device clock and peripherals//Device_init();//// Setup GPIO by disabling pin locks and enabling pullups//Device_initGPIO();//// GPIO28 is the SCI Rx pin.//GPIO_setMasterCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);//// GPIO29 is the SCI Tx pin.//GPIO_setMasterCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);//// Initialize PIE and clear PIE registers. Disables CPU interrupts.//Interrupt_initModule();//// Initialize the PIE vector table with pointers to the shell Interrupt// Service Routines (ISR).//Interrupt_initVectorTable();//// Interrupts that are used in this example are re-mapped to// ISR functions found within this file.//Interrupt_register(INT_SCIA_RX, sciaRXFIFOISR);
//注释掉Interrupt_register(INT_SCIA_TX, sciaTXFIFOISR);//// Initialize the Device Peripherals://initSCIAFIFO();//// Init the send data.After each transmission this data// will be updated for the next transmission//for(i = 0; i < 2; i++){sDataA[i] = i;}rDataPointA = sDataA[0];Interrupt_enable(INT_SCIA_RX);
//注释掉Interrupt_enable(INT_SCIA_TX);Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);//// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)//EINT;ERTM;//// IDLE loop. Just sit and loop forever (optional)://for(;;);
}//
// error - Function to halt debugger on error
//
void error(void)
{asm("ESTOP0"); // Test failed!! Stop!for (;;);
}//
// sciaTXFIFOISR - SCIA Transmit FIFO ISR
//
__interrupt void sciaTXFIFOISR(void)
{uint16_t i;SCI_writeCharArray(SCIA_BASE, sDataA, 2);//// Increment send data for next cycle//for(i = 0; i < 2; i++){sDataA[i] = (sDataA[i] + 1) & 0x00FF;}SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF);//// Issue PIE ACK//Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}//
// sciaRXFIFOISR - SCIA Receive FIFO ISR
//
__interrupt void sciaRXFIFOISR(void)
{uint16_t i;SCI_readCharArray(SCIA_BASE, rDataA, 2);//// Check received data//
//for(i = 0; i < 2; i++)
//{
//if(rDataA[i] != ((rDataPointA + i) & 0x00FF))
//{
//error();
//}
//}rDataPointA = (rDataPointA + 1) & 0x00FF;SCI_clearOverflowStatus(SCIA_BASE);SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXFF);//// Issue PIE ack//Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}//
// initSCIAFIFO - Configure SCIA FIFO
//
void initSCIAFIFO()
{//// 8 char bits, 1 stop bit, no parity. Baud rate is 9600.//SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |SCI_CONFIG_STOP_ONE |SCI_CONFIG_PAR_NONE));SCI_enableModule(SCIA_BASE);SCI_disableLoopback(SCIA_BASE); //将enable 改为 disableSCI_resetChannels(SCIA_BASE);SCI_enableFIFO(SCIA_BASE);//// RX and TX FIFO Interrupts Enabled//SCI_enableInterrupt(SCIA_BASE, SCI_INT_RXFF);//去掉| SCI_INT_TXFFSCI_disableInterrupt(SCIA_BASE, SCI_INT_RXERR);//// The transmit FIFO generates an interrupt when FIFO status// bits are less than or equal to 2 out of 16 words// The receive FIFO generates an interrupt when FIFO status// bits are greater than equal to 2 out of 16 words//SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX2, SCI_FIFO_RX2);SCI_performSoftwareReset(SCIA_BASE);//注释掉SCI_resetTxFIFO(SCIA_BASE);SCI_resetRxFIFO(SCIA_BASE);
}//
// End of file
//

好的好的,具体如上,主要是将Loopback功能取消了,然后注释掉了发送中断相关的指令,具体已在代码中中文备注

,

user6327524:

您好,问题解决了,是我在硬件上没有将S1置为ON的状态

,

Green Deng:

好的,感谢反馈

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F28388D: 28388D串口接收无法进入中断的问题
分享到: 更多 (0)