【新人求助】28335使用SCI通信的问题

2019-08-03 21:17发布

Capture.JPG
使用control suite提供的28335例程v133 scia_loopback时,观察寄存器发现SCIA、SCIB、SCIC三个都在不断更新。运行一定时间后,程序暂停,弹出defaultlsr.c窗口。
这个例程理论上应该只有一个SCI在使用才对啊,而且这个暂停弹出窗口在其他SCI通信的程序中也会出现。
怎么解决?
怎么解释?
附上使用的control suite例程如下:
  1. //###########################################################################
  2. //
  3. // FILE:    Example_2833xSci_FFDLB.c
  4. //
  5. // TITLE:   DSP2833x Device SCI FIFO Digital Loop Back Test.
  6. //
  7. // ASSUMPTIONS:
  8. //
  9. //    This program requires the DSP2833x header files.
  10. //
  11. //    This program uses the internal loop back test mode of the peripheral.
  12. //    Other then boot mode pin configuration, no other hardware configuration
  13. //    is required.
  14. //
  15. //    As supplied, this project is configured for "boot to SARAM"
  16. //    operation.  The 2833x Boot Mode table is shown below.
  17. //    For information on configuring the boot mode of an eZdsp,
  18. //    please refer to the documentation included with the eZdsp,
  19. //
  20. //       $Boot_Table:
  21. //
  22. //         GPIO87   GPIO86     GPIO85   GPIO84
  23. //          XA15     XA14       XA13     XA12
  24. //           PU       PU         PU       PU
  25. //        ==========================================
  26. //            1        1          1        1    Jump to Flash
  27. //            1        1          1        0    SCI-A boot
  28. //            1        1          0        1    SPI-A boot
  29. //            1        1          0        0    I2C-A boot
  30. //            1        0          1        1    eCAN-A boot
  31. //            1        0          1        0    McBSP-A boot
  32. //            1        0          0        1    Jump to XINTF x16
  33. //            1        0          0        0    Jump to XINTF x32
  34. //            0        1          1        1    Jump to OTP
  35. //            0        1          1        0    Parallel GPIO I/O boot
  36. //            0        1          0        1    Parallel XINTF boot
  37. //            0        1          0        0    Jump to SARAM            <- "boot to SARAM"
  38. //            0        0          1        1    Branch to check boot mode
  39. //            0        0          1        0    Boot to flash, bypass ADC cal
  40. //            0        0          0        1    Boot to SARAM, bypass ADC cal
  41. //            0        0          0        0    Boot to SCI-A, bypass ADC cal
  42. //                                              Boot_Table_End$
  43. //
  44. // DESCRIPTION:
  45. //
  46. //    This test uses the loopback test mode of the SCI module to send
  47. //    characters starting with 0x00 through 0xFF.  The test will send
  48. //    a character and then check the receive buffer for a correct match.
  49. //
  50. //          Watch Variables:
  51. //                LoopCount      Number of characters sent
  52. //                ErrorCount     Number of errors detected
  53. //                SendChar       Character sent
  54. //                ReceivedChar   Character recieved
  55. //
  56. //
  57. //###########################################################################
  58. //
  59. // Original Author: S.S.
  60. //
  61. // $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
  62. // $Release Date: June 8, 2012 $
  63. //###########################################################################


  64. #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

  65. // Prototype statements for functions found within this file.
  66. void scia_loopback_init(void);
  67. void scia_fifo_init(void);
  68. void scia_xmit(int a);
  69. void error();
  70. interrupt void scia_rx_isr(void);
  71. interrupt void scia_tx_isr(void);

  72. // Global counts used in this example
  73. Uint16 LoopCount;
  74. Uint16 ErrorCount;

  75. void main(void)
  76. {
  77.     Uint16 SendChar;
  78.     Uint16 ReceivedChar;

  79. // Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
  80. // This function is found in the DSP2833x_SysCtrl.c file.
  81.         InitSysCtrl();

  82. // Step 2. Select GPIO for the device or for the specific application:
  83. // This function is found in the DSP2833x_Gpio.c file.
  84. // InitGpio(); skip this as this is example selects the I/O
  85. // for SCI-A in this file itself
  86.    InitSciGpio();

  87. // Step 3. Initialize PIE vector table:
  88. // The PIE vector table is initialized with pointers to shell Interrupt
  89. // Service Routines (ISR).  The shell routines are found in DSP2833x_DefaultIsr.c.
  90. // Insert user specific ISR code in the appropriate shell ISR routine in
  91. // the DSP28_DefaultIsr.c file.

  92. // Disable and clear all CPU interrupts:
  93.         DINT;
  94.         IER = 0x0000;
  95.         IFR = 0x0000;

  96.       // Initialize Pie Control Registers To Default State:
  97.       // This function is found in the DSP2833x_PieCtrl.c file.
  98.           // InitPieCtrl();  PIE is not used for this example

  99.       // Initialize the PIE Vector Table To a Known State:
  100.       // This function is found in DSP2833x_PieVect.c.
  101.       // This function populates the PIE vector table with pointers
  102.       // to the shell ISR functions found in DSP2833x_DefaultIsr.c.
  103.           InitPieVectTable();

  104.       // Enable CPU and PIE interrupts
  105.       // This example function is found in the DSP2833x_PieCtrl.c file.
  106.       EnableInterrupts();

  107. // Step 4. Initialize all the Device Peripherals to a known state:
  108. // This function is found in DSP2833x_InitPeripherals.c
  109. // InitPeripherals(); skip this for SCI tests

  110. // Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:

  111.     LoopCount = 0;
  112.     ErrorCount = 0;

  113.     scia_fifo_init();           // Initialize the SCI FIFO
  114.     scia_loopback_init();  // Initalize SCI for digital loop back

  115.     // Note: Autobaud lock is not required for this example

  116.     // Send a character starting with 0
  117.     SendChar = 0;

  118. // Step 6. Send Characters forever starting with 0x00 and going through
  119. // 0xFF.  After sending each, check the recieve buffer for the correct value

  120.         for(;;)
  121.     {
  122.        scia_xmit(SendChar);
  123.        while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for RRDY/RXFFST =1 for 1 data available in FIFO

  124.        // Check received character
  125.        ReceivedChar = SciaRegs.SCIRXBUF.all;
  126.        if(ReceivedChar != SendChar) error();

  127.        // Move to the next character and repeat the test
  128.        SendChar++;
  129.        // Limit the character to 8-bits
  130.        SendChar &= 0x00FF;
  131.        LoopCount++;
  132.     }

  133. }


  134. // Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:

  135. void error()
  136. {

  137.       ErrorCount++;
  138. //    asm("     ESTOP0");  // Uncomment to stop the test here
  139. //    for (;;);

  140. }

  141. // Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
  142. void scia_loopback_init()
  143. {
  144.     // Note: Clocks were turned on to the SCIA peripheral
  145.     // in the InitSysCtrl() function

  146.         SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
  147.                                    // No parity,8 char bits,
  148.                                    // async mode, idle-line protocol
  149.         SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
  150.                                    // Disable RX ERR, SLEEP, TXWAKE
  151.         SciaRegs.SCICTL2.all =0x0003;
  152.         SciaRegs.SCICTL2.bit.TXINTENA =1;
  153.         SciaRegs.SCICTL2.bit.RXBKINTENA =1;
  154.     SciaRegs.SCIHBAUD    =0x0000;
  155.     SciaRegs.SCILBAUD    =0x000F;
  156.         SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
  157.         SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
  158. }

  159. // Transmit a character from the SCI'
  160. void scia_xmit(int a)
  161. {
  162.     SciaRegs.SCITXBUF=a;
  163. }

  164. // Initalize the SCI FIFO
  165. void scia_fifo_init()
  166. {
  167.     SciaRegs.SCIFFTX.all=0xE040;
  168.     SciaRegs.SCIFFRX.all=0x204f;
  169.     SciaRegs.SCIFFCT.all=0x0;

  170. }






  171. //===========================================================================
  172. // No more.
  173. //===========================================================================


复制代码

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
16条回答
raydead
2019-08-04 08:33
NWPU_CHEN 发表于 2014-7-16 15:13
你解释下为什么会出现这种情况

我怀疑是因为之前自己在仿真的时候,都只是单纯的仿真器给开发板供电,这个供电不足。后来是在仿真的时候,把开发板的电源也接上就没有出现过这样的问题了。仿真的结果也一切都正常了。

一周热门 更多>