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.

[参考译文] TMS320F28335:如何将 RS232电缆与此 DSP 配合使用

Guru**** 2394295 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1045074/tms320f28335-how-do-i-use-rs232-cable-with-this-dsp

器件型号:TMS320F28335

您好、SIR/MDM、

我尝试使用 RS232电缆通过 SCI-A (P12)和 SCI-B (J12)发送和接收数据。
但是、寄存器似乎不会接收或发送任何形式的数据。 我使用的是 F28335 eZdsp。
任何人都能就我必须对硬件和软件执行的操作发送一些帮助?
(我正在尝试运行 example_2833xSci_Echoback)

Rgds、
Marcus

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marcus、

     example_2833xSci_Echoback 旨在与 SCI-A 和 PC 一起运行。 您在终端中看到了什么吗? 您是否使用了正确的 COM 端口?  

    此致、

    Marlyn

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marlyn、

    很抱歉、我没有注意该示例、Example_2833xSCi_Autobaud 程序怎么样? 它指示将其连接到 GPIO 引脚、但我如何使用 RS232电缆实现这一目的?

    最佳 Rgds、
    Marcus

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marcus、

    要将 SCI-A (RS232连接)与 SCI-B (接头引脚)连接、您可能需要剥离 RS232电缆并自行形成连接。  

    您的最终目标是在 SCI-A 和 SCI-B 之间进行通信、还是与另一个器件进行通信?

    此致、

    Marlyn

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marlyn、
    是的、我的最终目标是 SCI-A 和 SCI-B 之间的通信 我已经有一个 RS232连接器和一个用于连接的5x2引脚接头、但我不确定如何配置软件。
    我是否必须配置 SCI.c 文件或其他相关文件?

    最佳 Rgds、
    Marcus

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marcus、  

    要开始使用软件、您可以查看  Example_2833xSCi_Autobaud 程序。 此示例专为 F28335 controlCARD 等其他硬件评估模块而设计、因此它引用了 GPIO。 只要在 SCI-A 和 SCI-B 之间有正确的连接(看起来就像您那样)、该示例就应该起作用。 当您运行该示例时会发生什么情况?

    此致、

    Marlyn

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marlyn、

    当示例位于调试终端中时、"Registers"页面不显示 SCIA 和 SCIB 的 Tx 和 Rx 移动。
    是否要检查 eZdsp F28335 J12、即 SCIB GPIO 引脚为9和11?

    最佳 Rgds、
    Marcus

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marcus、

    是的、如果 SW2仍处于默认状态、SCIB 应为 GPIO 9/11。 该示例使用 GPIO 18/19、对于 SCIB、您必须将其更改为 GPIO 9和11。 这可以在 InitScibGpio()函数中完成。

    此致、

    Marlyn

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marlyn、

    我已经按照您所提到的那样进行了配置、但是当我尝试运行程序时、它会直接将我带到那里  

    空错误()

    错误计数++;
    _asm (" ESTOP0");//取消注释以在此处停止测试
    适用于(;);


    此问题是否有任何解决方法?

    最佳 Rgds、
    Marcus

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    //###########################################################################
    // Description:
    //! \addtogroup f2833x_example_list
    //! <h1>SCI Autobaud (sci_autobaud)</h1>
    //!
    //! This test will perform autobaud lock at a variety of baud rates, including
    //! very high baud rates.
    //!
    //! For this test to properly run, connect the SCI-A pins to the
    //! SCI-B pins without going through a transceiver.
    //! At higher baud rates, the slew rate of the incoming data bits can be
    //! affected by transceiver and connector performance. This slew rate may
    //! limit reliable autobaud detection at higher baud rates.
    //!
    //! SCIA: Slave, autobaud locks, receives characters and
    //! echos them back to the host.  Uses the RX interrupt
    //! to receive characters.
    //!
    //! SCIB: Host, known baud rate, sends characters to the slave
    //! and checks that they are echoed back.
    //!
    //! \b External \b Connections \n
    //! - SCITXDA is on GPIO29
    //! - SCIRXDB is on GPIO19 - 11
    //! - SCIRXDA is on GPIO28
    //! - SCITXDB is on GPIO18 - 9
    //! - Connect GPIO29 to GPIO19 - Changed 19 to 11
    //! - Connect GPIO28 to GPIO18 - Changed 18 to 9
    //!
    //! \b Watch \b Variables \n
    //! - BRRVal            - current BRR value used for SCIB
    //! - ReceivedAChar     - character received by SCIA
    //! - ReceivedBChar     - character received by SCIB
    //! - SendChar          - character being sent by SCIB
    //! - SciaRegs.SCILBAUD - SCIA baud register set by autobaud lock
    //! - SciaRegs.SCIHBAUD - SCIA baud register set by autobaud lock
    //
    //
    //###########################################################################
    // $TI Release: F2833x/F2823x Header Files and Peripheral Examples V142 $
    // $Release Date: November  1, 2016 $
    // $Copyright: Copyright (C) 2007-2016 Texas Instruments Incorporated -
    //             http://www.ti.com/ ALL RIGHTS RESERVED $
    //###########################################################################
    
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    #include "DSP2833x_Gpio.h"
    #define BAUDSTEP 100            // Amount BRR will be incremented between each
                                    // autobaud lock
    
    // Prototype statements for functions found within this file.
    void scia_init(void);
    void scib_init(void);
    void scia_xmit(int a);
    void scib_xmit(int a);
    void scia_AutobaudLock(void);
    void error();
    __interrupt void rxaint_isr(void);
    
    // Global counts used in this example
    Uint16 LoopCount;
    //Uint16 xmitCount;
    Uint16 ReceivedCount;
    Uint16 ErrorCount;
    Uint16 SendChar;
    Uint16 ReceivedAChar;   // scia received character
    Uint16 ReceivedBChar;   // scib received character
    Uint16 BRRVal;
    Uint16 Buff[10] = {0x55, 0xAA, 0xF0, 0x0F, 0x00, 0xFF, 0xF5, 0x5F, 0xA5, 0x5A};
    
    void main(void)
    {
       Uint16 i;
    
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP2833x_SysCtrl.c file.
       InitSysCtrl();
    
    // Step 2. Initialize GPIO:
    // This example function is found in the DSP2833x_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
       //InitGpio();  // Skipped for this example
    
       InitSciGpio();
       //InitScibGpio();
    
    
    // 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 DSP2833x_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 DSP2833x_DefaultIsr.c.
    // This function is found in DSP2833x_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 = &rxaint_isr;
       EDIS;       // This is needed to disable write to EALLOW protected register
    
    // Step 4. Initialize all the Device Peripherals:
    // This function is found in DSP2833x_InitPeripherals.c
    // InitPeripherals(); // Not required for this example
       scia_init();       // Initialize SCIA
       scib_init();       // Initialize SCIB
    
    // Step 5. User specific code, enable interrupts:
       LoopCount = 0;
       ErrorCount = 0;
    
    // Enable interrupts
       PieCtrlRegs.PIEIER9.all = 0x0001; // Enable all SCIA RXINT interrupt
       IER |= 0x0100;                    // enable PIEIER9, and INT9
       EINT;
    
        // Start with BRR = 1, work through each baud rate setting
        // incrementing BRR by BAUDSTEP
        for (BRRVal = 0x0000; BRRVal < (Uint32)0xFFFF; BRRVal+=BAUDSTEP)
        {
            // SCIB has a known baud rate.  SCIA will autobaud to match
            ScibRegs.SCIHBAUD = (BRRVal >> 8);
            ScibRegs.SCILBAUD = (BRRVal);
    
            // Initiate an autobaud lock with scia.  Check
            // returned character against baud lock character 'A'
            scia_AutobaudLock();
            while(ScibRegs.SCIRXST.bit.RXRDY != 1) { }
            ReceivedBChar = 0;
            ReceivedBChar =  ScibRegs.SCIRXBUF.bit.RXDT;
            if(ReceivedBChar != 'A')
            {
                error(0);
            }
    
            // Send/echoback characters
            // 55 AA F0 0F 00 FF F5 5F A5 5A
            for(i= 0; i<=9; i++)
            {
              SendChar = Buff[i];
              scib_xmit(SendChar);              // Initiate interrupts and xmit data in isr
              // Wait to get the character back and check
              // against the sent character.
              while(ScibRegs.SCIRXST.bit.RXRDY != 1)
              {
                  __asm("   NOP");
              }
              ReceivedBChar = 0;
              ReceivedBChar =  ScibRegs.SCIRXBUF.bit.RXDT;
              if(ReceivedBChar != SendChar) error(1);
            }
    
        } // Repeat for next BRR setting
    
        // Stop here, no more
        for(;;)
        {
           __asm("    NOP");
        }
    }
    
    /* --------------------------------------------------- */
    /* ISR for PIE INT9.1                                  */
    /* Connected to RXAINT  SCI-A                          */
    /* ----------------------------------------------------*/
    
    __interrupt void rxaint_isr(void)     // SCI-A
    {
      // Insert ISR Code here
    
       PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
    
       // If autobaud detected, we must clear CDC
       if(SciaRegs.SCIFFCT.bit.ABD == 1)
       {
          SciaRegs.SCIFFCT.bit.ABDCLR = 1;
          SciaRegs.SCIFFCT.bit.CDC = 0;
          // Check received character - should be 'A'
          ReceivedAChar = 0;
          ReceivedAChar = SciaRegs.SCIRXBUF.all;
          if(ReceivedAChar != 'A')
          {
             error(2);
          }
          else scia_xmit(ReceivedAChar);
       }
    
       // This was not autobaud detect
       else
       {
          // Check received character against sendchar
          ReceivedAChar = 0;
          ReceivedAChar = SciaRegs.SCIRXBUF.all;
          if(ReceivedAChar != SendChar)
          {
             error(3);
          }
          else scia_xmit(ReceivedAChar);
       }
    
       SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1; // clear Receive interrupt flag
       ReceivedCount++;
    }
    
    void error()
    {
          ErrorCount++;
          __asm("     ESTOP0");            // Uncomment to stop the test here
          for (;;);
    }
    
    // SCIA  8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
    void scia_init()
    {
        // Note: Clocks were turned on to the SCIA peripheral
        // in the InitSysCtrl() function
    
        // Reset FIFO's
        SciaRegs.SCIFFTX.all=0x8000;
    
        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.RXBKINTENA =1;
        SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
    
        return; // i added this line
    }
    
    // SCIB  8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
    
    void scib_init()
    {
        // Reset FIFO's
        ScibRegs.SCIFFTX.all=0x8000;
    
        // 1 stop bit, No parity, 8-bit character
        // No loopback
        ScibRegs.SCICCR.all = 0x0007;
    
        // Enable TX, RX, Use internal SCICLK
        ScibRegs.SCICTL1.all = 0x0003;
    
        // Disable RxErr, Sleep, TX Wake,
        // Disable Rx Interrupt, Tx Interrupt
        ScibRegs.SCICTL2.all = 0x0000;
    
        // Relinquish SCI-A from reset
        ScibRegs.SCICTL1.all = 0x0023;
    
        return;
    }
    
    // Transmit a character from the SCI-A'
    void scia_xmit(int a)
    {
        SciaRegs.SCITXBUF=a;
    }
    
    // Transmit a character from the SCI-B'
    void scib_xmit(int a)
    {
        ScibRegs.SCITXBUF=a;
    }
    
    //------------------------------------------------
    // Perform autobaud lock with the host.
    // Note that if autobaud never occurs
    // the program will hang in this routine as there
    // is no timeout mechanism included.
    //------------------------------------------------
    void scia_AutobaudLock()
    {
    
        SciaRegs.SCICTL1.bit.SWRESET = 0;
        SciaRegs.SCICTL1.bit.SWRESET = 1;
    
        // Must prime baud register with >= 1
        SciaRegs.SCIHBAUD = 0;
        SciaRegs.SCILBAUD = 1;
    
        // Prepare for autobaud detection
        // Make sure the ABD bit is clear by writing a 1 to ABDCLR
        // Set the CDC bit to enable autobaud detection
        SciaRegs.SCIFFCT.bit.ABDCLR = 1;
        SciaRegs.SCIFFCT.bit.CDC = 1;
    
        // Wait until we correctly read an
        // 'A' or 'a' and lock
        //
        // As long as Autobaud calibration is enabled (CDC = 1),
        // SCI-B (host) will continue transmitting 'A'. This will
        // continue until interrupted by the SCI-A RX ISR, where
        // SCI-A RXBUF receives 'A', autobaud-locks (ABDCLR=1
        // CDC=0),and returns an 'A' back to the host. Then control
        // is returned to this loop and the loop is exited.
        //
        // NOTE: ABD will become set sometime between
        //       scib_xmit and the DELAY_US loop, and
        //       the SCI-A RX ISR will be triggered.
        //       Upon returning and reaching the if-statement,
        //       ABD will have been cleared again by the ISR.
    
        while(SciaRegs.SCIFFCT.bit.CDC== 1)
        {
           // Note the lower the baud rate the longer
           // this delay has to be to allow the other end
           // to echo back a character (about 4 characters long)
           // Make this really long since we are going through all
           // the baud rates.
           DELAY_US(280000L);
    
           if(SciaRegs.SCIFFCT.bit.CDC == 1)
               scib_xmit('A');  // host transmits 'A'
       }
    
        return;
    }
    
    
    
    //===========================================================================
    // No more.
    //===========================================================================
    
    

    这里是我的程序的编码、我没有对它做太多更改。 我还将 InitScibGpio 配置为9和11。  

    更新了:当 RS232电缆插入 P12和 J12时,它会直接变为 void error()。 RS232电缆是否有问题?

    谢谢你。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marcus、

    遇到错误时、寄存器的状态是什么?  

    [引用 userid="501481" URL"~/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1045074/tms320f28335-how-do-i-use-rs232-cable-with-this-dsp/3871602 #3871602"]更新:将 RS232电缆插入 P12和 J12时,它会直接变为 void error ()。 RS232电缆是否有问题?[/QUEST]

    一种测试方法是使用电路板上的其他 SCI 引脚。 我相信 J2和 J4也提供了 SCI 引脚。 这将通过不同的 GPIO 实现、因此您必须在代码中更改该值、但我会先尝试以这种方式运行示例。

    此致、

    Marlyn

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marlyn、
    SCIA 和 SCIB 的寄存器为空、不会移动。

    我正在使用 eZdsp F28335、似乎找不到 J2和 J4来测试 RS232电缆。 还有其他解决方案吗?

    此致、
    Marcus

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Marlyn、

    感谢您坚持并帮助所有这些、同时、我执行了一个程序、能够从 SCIA 和 SCIB 发送信息、而不会出现任何问题。 :>  
    最佳 Rgds、
    Marcus