完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
下面是controlSUITE中的C2802X的SCI例程,我只是对中断函数稍作修改,屏蔽了loopback。为什么不能进收中断?求解,已经调了好几天了。没想到卡在这里。。。。
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File #define CPU_FREQ 60E6 // Default = 40 MHz. Change to 60E6 for 60 MHz devices #define LSPCLK_FREQ CPU_FREQ/4 #define SCI_FREQ 19.2E3 #define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1 // Prototype statements for functions found within this file. __interrupt void sciaTxFifoIsr(void); __interrupt void sciaRxFifoIsr(void); __interrupt void scibTxFifoIsr(void); __interrupt void scibRxFifoIsr(void); void scia_fifo_init(void); void scib_fifo_init(void); void error(void); // Global variables uint16_t sdataA[2]; // Send data for SCI-A uint16_t rdataA[2]; // Received data for SCI-A uint16_t rdata_pointA; // Used for checking the received data void main(void) [ uint16_t i; // WARNING: Always ensure you call memcpy before running any functions from RAM // InitSysCtrl includes a call to a RAM based function and without a call to // memcpy first, the processor will go "into the weeds" #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif // Step 1. Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the f2802x_SysCtrl.c file. InitSysCtrl(); // Step 2. Initalize GPIO: // This example function is found in the f2802x_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 f2802x_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 f2802x_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 f2802x_DefaultIsr.c. // This function is found in f2802x_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.SCIRXINTA = &sciaRxFifoIsr; PieVectTable.SCITXINTA = &sciaTxFifoIsr; EDIS; // This is needed to disable write to EALLOW protected registers // Step 4. Initialize all the Device Peripherals: // This function is found in f2802x_InitPeripherals.c // InitPeripherals(); // Not required for this example scia_fifo_init(); // Init SCI-A // 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; ] rdata_pointA = sdataA[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 IER = 0x100; // Enable CPU INT EINT; for(i=0; i< 2; i++) [ SciaRegs.SCITXBUF=sdataA; // Send data ] // Step 6. IDLE loop. Just sit and loop forever (optional): for(;;); ] void error(void) [ __asm(" ESTOP0"); // Test failed!! Stop! for (;;); ] __interrupt void sciaTxFifoIsr(void) [ uint16_t i; // for(i=0; i< 2; i++) // [ // SciaRegs.SCITXBUF=sdataA; // Send data // ] for(i=0; i< 2; i++) //Increment send data for next cycle [ sdataA = (sdataA+1) & 0x00FF; ] SciaRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear SCI Interrupt flag PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ACK ] __interrupt void sciaRxFifoIsr(void) [ uint16_t i; for(i=0; i< 2; i++) [ SciaRegs.SCITXBUF=sdataA; // Send data ] for(i=0;i<2;i++) [ rdataA=SciaRegs.SCIRXBUF.all; // Read data ] for(i=0;i<2;i++) // Check received data [ if(rdataA != ( (rdata_pointA+i) & 0x00FF) ) error(); ] rdata_pointA = (rdata_pointA+1) & 0x00FF; SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack ] void scia_fifo_init() [ SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback // No parity,8 char bits, // async mode, idle-line protocol SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK, // Disable RX ERR, SLEEP, TXWAKE SciaRegs.SCICTL2.bit.TXINTENA =1; SciaRegs.SCICTL2.bit.RXBKINTENA =1; SciaRegs.SCIHBAUD = 0x0000; SciaRegs.SCILBAUD = SCI_PRD; // SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back SciaRegs.SCIFFTX.all=0xC022; SciaRegs.SCIFFRX.all=0x0022; SciaRegs.SCIFFCT.all=0x00; SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1; SciaRegs.SCIFFRX.bit.RXFIFORESET=1; ] //=========================================================================== // No more. //=========================================================================== |
|
相关推荐
5 个讨论
|
|
bgcwer 发表于 2018-10-12 15:20 Hongguang, 看了你的代码,应该是 for(i=0;i<2;i++) // Check received data [ if(rdataA != ( (rdata_pointA+i) & 0x00FF) ) error(); ] 这个地方; 因为在主程序中,你发送的是: for(i=0; i< 2; i++) [ SciaRegs.SCITXBUF=sdataA; // Send data ] 实际第一次发送的是sdataA[1],跟后面接收中断中的数据对不上,建议仔细查下数据这块。 |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
586 浏览 0 评论
1643 浏览 0 评论
2082 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1534 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1374 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1784浏览 29评论
2811浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1743浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1655浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1673浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-10 13:53 , Processed in 0.654420 second(s), Total 44, Slave 37 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2410