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.
您好!
我根据 SCI-A 导入 UART 中断回送示例。 它工作正常。 我将转换为 SCI-C。当接收到数据时、不会在中断 矢量处到达数据。
I 为 SCI-C 设置中断组:
PieCtrlRegs.PIEIER8.bit.INTx5=1;
PieCtrlRegs.PIEIER8.bit.INTx6= 1;
我的代码如下所示。请帮我。
此致-
Sudip
#include "DSP28x_Project.h"//器件头文件和示例 include 文件
#define CPU_FREQ 60E6
#define LSPCLK_FREQ (CPU_FREQ/4)
#define SCI_FREQ 100E3
#define SCI_PRD ((LSPCLK_FREQ/(SCI_FREQ*8))-1)
//此文件中找到的函数的原型语句。
中断 void scicTxFifoIsr (void);
中断 void scicRxFifoIsr (void);
//全局变量
uint16 sdataA[2];//为 SCI-A 发送数据
uint16 rdataA[2];//针对 SCI-A 接收到的数据
uint16 RDATA_pointA;//用于检查接收到的数据
void main (void)
{
uint16 i;
InitSysCtrl();
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO39 = 0;//启用 GPIO39的上拉电阻器(SCIRXDC)
GpioCtrlRegs.GPBPUD.bit.GPIO42 = 0;//启用 GPIO42的上拉(SCITXDC)
GpioCtrlRegs.GPBQSEL1.bit.GPIO39 = 3;//异步输入 GPIO39 (SCIRXDC)
GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 2;//为 SCIRXDC 配置 GPIO39
GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 2;//为 SCITXDC 配置 GPIO42
EDIS;
Dint;
InitPieCtrl();
InitPieVectTable();
IER = 0x0000;
IFR = 0x0000;
EALLOW;//这是写入 EALLOW 受保护寄存器所必需的
PieVectTable.SCIRXINTC =&scicRxFifoIsr;
PieVectTable.SCITXINTC =&scicTxFifoIsr;
EDIS;//这是禁止写入 EALLOW 受保护寄存器所必需的
ScicRegs.SCICTL1.ALL = 0x0023;//从复位中撤回 SCI
ScicRegs.SCICTL2.bit.TXINTENA=1;
ScicRegs.SCICTL2.bit.RXBKINTENA=1;
ScicRegs.SCICCR.ALL = 0x0007;
ScicRegs.SCICCR.bit.LOOPBKENA =0;// 1;//启用回路
ScicRegs.SCILBAUD=0x00C2;
ScicRegs.SCIFFRX.ALL = 0x0022;
ScicRegs.SCIFFRX.bit.RXFIFORESET = 1;
ScicRegs.SCIFFRX.bit.RXFFIENA=1;
ScicRegs.SCIFFCT.ALL = 0x00;
ScicRegs.SCIFFTX.ALL = 0xC022;
ScicRegs.SCIFFTX.bit.TXFIFOXRESET = 1;
//////////////////////////////////////////////////////////////////////////////////////////////
对于(i = 0;i<2;i++)
{
sdataA[i]= i;
}
RDATA_pointA = sdataA[0];
//
//启用此示例所需的中断
//
PieCtrlRegs.PIECTRL.bit.ENPIE= 1;//启用 PIE 块
// PieCtrlRegs.PIEIER9.bit.INTx1= 1;// PIE 组9,INT1
// PieCtrlRegs.PIEIER9.bit.INTx2= 1;// PIE 组9,int2
PieCtrlRegs.PIEIER8.bit.INTx5=1;
PieCtrlRegs.PIEIER8.bit.INTx6= 1;
IER = 0x100;//启用 CPU INT
EINT;
//
//步骤6. 空闲循环。 只需坐下来循环(可选):
//
for (;;)
{
}
}
空错误(空)
{
asm (" ESTOP0");//测试失败!! 停下来!
适用于(;);
}
中断空 scicTxFifoIsr (空)
{
uint16 i;
for (i=0;i < 2;i++)
{
ScicRegs.SCITXBUF = sdataA[i];//发送数据
}
for (i= 0;i < 2;i++)//递增发送下一个周期的数据
{
sdataA[i]=(sdataA[i]+1)和0x00FF;
}
ScicRegs.SCIFFTX.bit.TXFFINTCLR = 1;//清除 SCI 中断标志
PieCtrlRegs.PIEACK.ALL |= 0x100;//发出 PIE ACK
}
中断空 scicRxFifoIsr (空)
{
uint16 i;
对于(I = 0;I < 2;I++)
{
rdataA[i]= ScicRegs.SCIRXBUF.all;//读取数据
}
for (i = 0;i < 2;i++)//检查接收到的数据
{
if (rdataA[i]!=((RDATA_pointA+I)& 0x00FF) error ();
}
RDATA_pointA =(RDATA_pointA+1)和0x00FF;
ScicRegs.SCIFFRX.bit.RXFFOVRCLR = 1;//清除溢出标志
ScicRegs.SCIFFRX.bit.RXFFINTCLR = 1;//清除中断标志
PieCtrlRegs.PIEACK.ALL |= 0x100;//发出 PIE ACK
}
您好、Sudip、
代码看起来不错。
[~ userid="452796" URL"μ C/support/microrims/c2000-microset-group/c2000-f/C2000-microset-forum/1103356/tms320f28055-sci-c-rx-interrupt-not working"下的数据在收到数据时、不会在中断 矢量处到达。 [/报价]您是否说 SCIRXBUF 中有数据、但中断永远不会发生? 是否发生 TX 中断?
此致、
Marlyn
您好、Marlyn、
感谢您的响应。是的、您答对了。当我发送数据时、它不是 TX 中断向量。当我通过 FTDI 从 PC 终端接收数据时、 指针不会到达 RX 中断函数/向量。但如果没有中断或仅轮询方法、回显字符就可以正常工作。
供参考、SCI-B 在单次触发模式下处理中断的过程相同。只是我更改了 PIE 矢量位。
仅 SCI-C 问题。
此致-
Sudip
Sudip、
感谢您的澄清。
[~ userid="452796" URL"μ C/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forume/1103356/tms320f28055-sci-c-rx-interrupt-not working/4089050#4089050"]供参考、SCI-B 在单次触发模式下处理中断的过程相同。只是我更改了 PIE 矢量位。
仅 SCI-C 问题。
[/报价]明天我将在硬件上测试此问题、以查看是否可以重复同样的问题。 我会尽快回复。
此致、
Marlyn
您好、Sudip、
今天我无法获得合适的硬件、但明天我将再次尝试、看看我是否可以控制 F2805x 器件。 我会随时向您提供最新信息。
此致、
Marlyn
好的、 Marlyn、没问题。
Sudip、
我目前无法去办公室。 希望在下周之前、我将能够购买合适的硬件。 我对我们一方迟迟未能确认这一问题表示歉意。
此致、
Marlyn
好的、没问题。 感谢您的回答。
您好、Sudip、
感谢您的耐心等待。 我仍在努力复制此问题、并将随时向您发布。
此致、
Marlyn
您好、 Marlyn、
好的。
尽快获得解决方案很好。我们仍然 在解决 这个问题的同一个位置。
此致、
Sudip
感谢您的 Sudip、我将优先考虑这一点。
此致、
Marlyn
您好、Sudip、
以下行需要按以下方式更改:
// Within main.c IER = 0x100; // Enable CPU INT -> IER = 0x80; // In the TX ISR PieCtrlRegs.PIEACK.all |= 0x100; // Issue PIE ACK -> PieCtrlRegs.PIEACK.all |= 0x80; // In the RX ISR PieCtrlRegs.PIEACK.all |= 0x100; // Issue PIE ack -> PieCtrlRegs.PIEACK.all |= 0x80;
在 PIE 中、SCI-C RX 和 TX 中断位于组8中、因此您需要更改代码中的这些位置以正确设置 IER 和 ACK。
此致、
Marlyn
您好、Marlyn、
非常感谢您的回答。
我按 您的要求进行了尝试。 但仍然是同一个问题。 当我发送时、它不会到达中断矢量来发送数据。
我有请求。 与 CCS 下的 SCIA 示例类似,您能否为我们提供 SCIC 的完整示例代码?。仅用于 TX/RX 演示。 这对我们这个 SCIC 中断问题的人来说非常好。
仅供参考、我们导入 SCIA 示例构建并运行、没有问题。
此致-
Sudip
您好、Sudip、
是的、我要连接适用于我的 SCI-C 的配置。 请进行测试。
// // Included Files // #include "DSP28x_Project.h" // Device Headerfile and Examples Include File #define CPU_FREQ 60E6 #define LSPCLK_FREQ (CPU_FREQ/4) #define SCI_FREQ 100E3 #define SCI_PRD ((LSPCLK_FREQ/(SCI_FREQ*8))-1) // Prototype statements for functions found within this file. interrupt void scicTxFifoIsr(void); interrupt void scicRxFifoIsr(void); void scic_fifo_init(void); void error(void); // Global variables Uint16 sdataA[2]; // Send data for SCI-C Uint16 rdataA[2]; // Received data for SCI-C Uint16 rdata_pointA; // Used for checking the received data Uint16 enteredRXISR; Uint16 enteredTXISR; void main(void) { Uint16 i; // // Step 1. Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the F2805x_SysCtrl.c file. // InitSysCtrl(); // // Step 2. Initialize GPIO: // This example function is found in the F2805x_Gpio.c file and // illustrates how to set the GPIO to it's default state. // InitGpio(); // Setup only the GP I/O only for SCI-A and SCI-B functionality // This function is found in F2805x_Sci.c // InitSciGpio(); // // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts // DINT; // // Initialize PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the F2805x_PieCtrl.c file. // InitPieCtrl(); // // Disable CPU interrupts and clear all CPU interrupt flags: // IER = 0x0000; IFR = 0x0000; // // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in F2805x_DefaultIsr.c. // This function is found in F2805x_PieVect.c. // InitPieVectTable(); // // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. // EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.SCIRXINTC = &scicRxFifoIsr; PieVectTable.SCITXINTC = &scicTxFifoIsr; EDIS; // This is needed to disable write to EALLOW protected registers // // Step 4. Initialize all the Device Peripherals: // scic_fifo_init(); // Init SCI-C // // Step 5. User specific code, enable interrupts: // // // Init send data. After each transmission this data // will be updated for the next transmission // for(i = 0; i<2; i++) { sdataA[i] = i; rdataA[i] = 0; } rdata_pointA = sdataA[0]; enteredRXISR = 0; enteredTXISR = 0; // // Enable interrupts required for this example // PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block //PieCtrlRegs.PIEIER9.bit.INTx1= 1; // PIE Group 9, INT1 //PieCtrlRegs.PIEIER9.bit.INTx2= 1; // PIE Group 9, INT2 PieCtrlRegs.PIEIER8.bit.INTx5=1; //SCI-C PieCtrlRegs.PIEIER8.bit.INTx6= 1; //SCI-C IER = 0x80; // Enable CPU INT EINT; // // Step 6. IDLE loop. Just sit and loop forever (optional): // for(;;); } void error(void) { asm(" ESTOP0"); // Test failed!! Stop! for (;;); } interrupt void scicTxFifoIsr(void) { enteredTXISR = enteredTXISR +1; Uint16 i; for(i= 0; i < 2; i++) { ScicRegs.SCITXBUF = sdataA[i]; // Send data } for(i= 0; i < 2; i++) //Increment send data for next cycle { sdataA[i] = (sdataA[i]+1) & 0x00FF; } ScicRegs.SCIFFTX.bit.TXFFINTCLR = 1; // Clear SCI Interrupt flag PieCtrlRegs.PIEACK.all |= 0x80; // Issue PIE ACK } interrupt void scicRxFifoIsr(void) { enteredRXISR = enteredRXISR + 1; Uint16 i; for(i = 0; i < 2; i++) { rdataA[i] = ScicRegs.SCIRXBUF.all; // Read data } for(i = 0; i < 2; i++) // Check received data { if(rdataA[i] != ((rdata_pointA+i) & 0x00FF)) error(); } rdata_pointA = (rdata_pointA+1) & 0x00FF; ScicRegs.SCIFFRX.bit.RXFFOVRCLR = 1; // Clear Overflow flag ScicRegs.SCIFFRX.bit.RXFFINTCLR = 1; // Clear Interrupt flag PieCtrlRegs.PIEACK.all |= 0x80; // Issue PIE ack } void scic_fifo_init() { ScicRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback // No parity,8 char bits, // async mode, idle-line protocol ScicRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK, // Disable RX ERR, SLEEP, TXWAKE ScicRegs.SCICTL2.bit.TXINTENA = 1; ScicRegs.SCICTL2.bit.RXBKINTENA = 1; SciaRegs.SCIHBAUD = SCI_PRD; ScicRegs.SCILBAUD = SCI_PRD; ScicRegs.SCICCR.bit.LOOPBKENA = 1; // Enable loop back ScicRegs.SCIFFTX.all = 0xC022; ScicRegs.SCIFFRX.all = 0x0022; ScicRegs.SCIFFCT.all = 0x00; ScicRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset ScicRegs.SCIFFTX.bit.TXFIFOXRESET = 1; ScicRegs.SCIFFRX.bit.RXFIFORESET = 1; } // // End of file. //
此致、
Marlyn
您好、Marlyn、
是的、最后、它按预期工作。
您的完整代码帮助我找到了问题(启用适当的中断组)。
非常感谢您的帮助和支持。
我有一个建议。如果 您的完整代码保存在串行端口示例下(在 Resource Explorer 中)、那将会很好。
此致-
Sudip