打印

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

[复制链接]
7898|16
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
raydead|  楼主 | 2014-7-14 23:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

使用control suite提供的28335例程v133 scia_loopback时,观察寄存器发现SCIA、SCIB、SCIC三个都在不断更新。运行一定时间后,程序暂停,弹出defaultlsr.c窗口。
这个例程理论上应该只有一个SCI在使用才对啊,而且这个暂停弹出窗口在其他SCI通信的程序中也会出现。
怎么解决?
怎么解释?
附上使用的control suite例程如下:
//###########################################################################
//
// FILE:    Example_2833xSci_FFDLB.c
//
// TITLE:   DSP2833x Device SCI FIFO Digital Loop Back Test.
//
// ASSUMPTIONS:
//
//    This program requires the DSP2833x header files.
//
//    This program uses the internal loop back test mode of the peripheral.
//    Other then boot mode pin configuration, no other hardware configuration
//    is required.
//
//    As supplied, this project is configured for "boot to SARAM"
//    operation.  The 2833x Boot Mode table is shown below.
//    For information on configuring the boot mode of an eZdsp,
//    please refer to the documentation included with the eZdsp,
//
//       $Boot_Table:
//
//         GPIO87   GPIO86     GPIO85   GPIO84
//          XA15     XA14       XA13     XA12
//           PU       PU         PU       PU
//        ==========================================
//            1        1          1        1    Jump to Flash
//            1        1          1        0    SCI-A boot
//            1        1          0        1    SPI-A boot
//            1        1          0        0    I2C-A boot
//            1        0          1        1    eCAN-A boot
//            1        0          1        0    McBSP-A boot
//            1        0          0        1    Jump to XINTF x16
//            1        0          0        0    Jump to XINTF x32
//            0        1          1        1    Jump to OTP
//            0        1          1        0    Parallel GPIO I/O boot
//            0        1          0        1    Parallel XINTF boot
//            0        1          0        0    Jump to SARAM            <- "boot to SARAM"
//            0        0          1        1    Branch to check boot mode
//            0        0          1        0    Boot to flash, bypass ADC cal
//            0        0          0        1    Boot to SARAM, bypass ADC cal
//            0        0          0        0    Boot to SCI-A, bypass ADC cal
//                                              Boot_Table_End$
//
// DESCRIPTION:
//
//    This test uses the loopback test mode of the SCI module to send
//    characters starting with 0x00 through 0xFF.  The test will send
//    a character and then check the receive buffer for a correct match.
//
//          Watch Variables:
//                LoopCount      Number of characters sent
//                ErrorCount     Number of errors detected
//                SendChar       Character sent
//                ReceivedChar   Character recieved
//
//
//###########################################################################
//
// Original Author: S.S.
//
// $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
// $Release Date: June 8, 2012 $
//###########################################################################


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

// Prototype statements for functions found within this file.
void scia_loopback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void error();
interrupt void scia_rx_isr(void);
interrupt void scia_tx_isr(void);

// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;

void main(void)
{
    Uint16 SendChar;
    Uint16 ReceivedChar;

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

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

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

// Disable and clear all CPU interrupts:
        DINT;
        IER = 0x0000;
        IFR = 0x0000;

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

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

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

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

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

    LoopCount = 0;
    ErrorCount = 0;

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

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

    // Send a character starting with 0
    SendChar = 0;

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

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

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

       // Move to the next character and repeat the test
       SendChar++;
       // Limit the character to 8-bits
       SendChar &= 0x00FF;
       LoopCount++;
    }

}


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

void error()
{

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

}

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

        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.all =0x0003;
        SciaRegs.SCICTL2.bit.TXINTENA =1;
        SciaRegs.SCICTL2.bit.RXBKINTENA =1;
    SciaRegs.SCIHBAUD    =0x0000;
    SciaRegs.SCILBAUD    =0x000F;
        SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
        SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
}

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

// Initalize the SCI FIFO
void scia_fifo_init()
{
    SciaRegs.SCIFFTX.all=0xE040;
    SciaRegs.SCIFFRX.all=0x204f;
    SciaRegs.SCIFFCT.all=0x0;

}






//===========================================================================
// No more.
//===========================================================================




相关帖子

沙发
raydead|  楼主 | 2014-7-15 18:55 | 只看该作者
自己附上解决方法吧。
首先,在确保仿真器接线正确后,信号下载线和28335都接上电源。这样再烧录就没有出现这样的情况了。

使用特权

评论回复
板凳
zhangmangui| | 2014-7-15 21:51 | 只看该作者
参考代码
Mcbsp_spi_loopback.rar (392.98 KB)

使用特权

评论回复
地板
NWPU_CHEN| | 2014-7-16 15:13 | 只看该作者
raydead 发表于 2014-7-15 18:55
自己附上解决方法吧。
首先,在确保仿真器接线正确后,信号下载线和28335都接上电源。这样再烧录就没有出现 ...

你解释下为什么会出现这种情况

使用特权

评论回复
5
raydead|  楼主 | 2014-7-16 17:22 | 只看该作者
NWPU_CHEN 发表于 2014-7-16 15:13
你解释下为什么会出现这种情况

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

使用特权

评论回复
6
raydead|  楼主 | 2014-7-16 17:22 | 只看该作者
zhangmangui 发表于 2014-7-15 21:51
参考代码

嗯嗯,谢谢。
这个不是SPI通信的吗?

使用特权

评论回复
7
NWPU_CHEN| | 2014-7-17 08:53 | 只看该作者
raydead 发表于 2014-7-16 17:22
我怀疑是因为之前自己在仿真的时候,都只是单纯的仿真器给开发板供电,这个供电不足。后来是在仿真的时候 ...

仿真器能给开发板供电????

使用特权

评论回复
8
raydead|  楼主 | 2014-7-17 09:52 | 只看该作者
NWPU_CHEN 发表于 2014-7-17 08:53
仿真器能给开发板供电????

我用的这个可以。另外一块28335在仿真的时候就不用再接电源,直接仿真器供电就足够仿真(但是烧录flash不行),但是我手上的这一块28335就必须接电源才可以正常仿真

使用特权

评论回复
9
NWPU_CHEN| | 2014-7-17 10:57 | 只看该作者
raydead 发表于 2014-7-17 09:52
我用的这个可以。另外一块28335在仿真的时候就不用再接电源,直接仿真器供电就足够仿真(但是烧录flash不 ...

用的哪个公司的仿真器

使用特权

评论回复
10
raydead|  楼主 | 2014-7-17 11:54 | 只看该作者
NWPU_CHEN 发表于 2014-7-17 10:57
用的哪个公司的仿真器

自制的= =b,所以有很多不正规操作。
老师帮我们做的28027开发板,上面集成的仿真器,同时这个仿真器也可以外接别的开发板来使用。
是XDS100V1

使用特权

评论回复
11
NWPU_CHEN| | 2014-7-17 13:06 | 只看该作者
raydead 发表于 2014-7-17 11:54
自制的= =b,所以有很多不正规操作。
老师帮我们做的28027开发板,上面集成的仿真器,同时这个仿真器也可 ...

哦,怪不得呢

使用特权

评论回复
12
raydead|  楼主 | 2014-7-18 00:19 | 只看该作者
NWPU_CHEN 发表于 2014-7-17 13:06
哦,怪不得呢

嗯嗯

使用特权

评论回复
13
meng219902| | 2014-7-18 10:18 | 只看该作者
确实是供电问题,要要用2A的才可以,我有一次为了好看,用三星手机充电器做了一个供电电源,700mA,只运行一个CPLD还算正常,如果dsp+cpld同时运行,dsp就会跑飞的。。。我改用2A的电源供电就正常了

使用特权

评论回复
评分
参与人数 1威望 +2 收起 理由
raydead + 2
14
comeon201208| | 2014-7-20 17:31 | 只看该作者
SCI是一个全双工异步串行通信接口,它用于MCU与其他计算机之间进行通信。

使用特权

评论回复
15
comeon201208| | 2014-7-20 17:31 | 只看该作者
该通讯看着还是挺麻烦的啊,,

使用特权

评论回复
16
comeon201208| | 2014-7-20 17:31 | 只看该作者
SCI采用标准的NRZ数据格式。它由一个起始位(0),8或9个数据位和一个停止位(1)组成,数据位的位数由串行通信控制寄存器1(SCC1)的M位来选择。M=0,为8位;M=1,为9位。在允许检偶检验时,最高数据位将用作奇偶位。这样,M=0时数据为7位;M=1时为8位。

使用特权

评论回复
17
raydead|  楼主 | 2014-7-21 00:19 | 只看该作者
comeon201208 发表于 2014-7-20 17:31
SCI是一个全双工异步串行通信接口,它用于MCU与其他计算机之间进行通信。

SCI是一个单工,半双工,和全双工都有的吧。然后,我一般都没有使用检验奇偶位

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

47

帖子

0

粉丝