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.

CCS/TMS320F28335: To trsmit data from PC to PCB via SCI

Part Number: TMS320F28335
Other Parts Discussed in Thread: MAX3221, C2000WARE, CONTROLSUITE

Tool/software: Code Composer Studio

Respectd sir,

I want to transmit data from PC to PCB via RS232[MAX3221] with UART .what should I have to make changes in following code ?.Previously i trasmit data from PCB to PC .code

SendChar = 0;

while(1)
{
scic_xmit(0xAB);

while(ScicRegs.SCIFFRX.bit.RXFFST !=1);
ReceivedChar = ScicRegs.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++;

Delay();

}

  • Mahesh,

    From your post it sounds like you were successful in transmitting data from the device to the PC. Now you want to receive data from the PC to the device. Within the SCI, transmit and receive can be viewed as two separate and independent blocks. Please reference the receive portion of the scia_loopback code which can be found in C2000Ware at:

    C:\ti\c2000\C2000Ware_<version>\device_support\f2833x\examples\scia_loopback

    Also, the following post may be useful to you too:

    e2e.ti.com/.../317141 SCI receive

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken
  • HOW TO transmit the data from PC to PCB ?Tell me procedure

    below I have provide u the screenshot of the Transmission from PCB to PC as follow and also tell me IS it correct or not? what modification that I have to made the in scia_loopback example code to transmit data from PC to PCB?
  • #include "DSP28x_Project.h"
    
    void scia_loopback_init(void);
    void scia_fifo_init(void);
    void scib_loopback_init(void);
    void scib_fifo_init(void);
    void scic_loopback_init(void);
    void scic_fifo_init(void);
    
    void scia_xmit(int a);
    void scib_xmit(int a);
    void scic_xmit(int a);
    
    void Delay();
    Uint16 rdataA[8];
    void error(void);
    Uint16 LoopCount;
    Uint16 ErrorCount;
    
    
    void main(void)
     {
    	Uint16  SendChar;
    	Uint16  ReceivedChar;
    
       InitSysCtrl();
       InitSciGpio();
    
    	DINT;
    	IER = 0x0000;
    	IFR = 0x0000;
    
        InitPieVectTable();
    
        scic_loopback_init();
        scic_fifo_init();
        SendChar = 0;
    
    	while(1)
        {
    		scic_xmit(0xAB);
    
         while(ScicRegs.SCIFFRX.bit.RXFFST !=1);
           ReceivedChar = ScicRegs.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++;
    
                 scic_xmit(ReceivedChar );
                // LoopCount++;*/
    	   Delay();
    
        }
    }
    
    void Delay()
    {
    	unsigned int i;
    	for(i = 0;i < 1000;i++);
    }
    
    void scia_loopback_init()
    {
    
     	SciaRegs.SCICCR.all =0x0007;//// Idle-line mode,// 1 stop bit,  No loopback  // No parity,8 char bits,
    	SciaRegs.SCICTL1.all =0x0003;/// enable TX, RX, internal SCICLK,  // Disable RX ERR, SLEEP, TXWAKE
        SciaRegs.SCIHBAUD    =0x0000;
        SciaRegs.SCILBAUD    =0x000F;//BRR=15(0xFF),SCI Asynchronous Baud=292
        ScibRegs.SCICCR.bit.LOOPBKENA =1;///Loop Back test mode enabled bit4[SCICCR]
    	SciaRegs.SCICTL1.all =0x0023;//re-enable the SCI by writing a 1 to SW RESET bit-5[SCICTL1]
    }
    //================Initialize the SCI FIFO==========================//
    void scia_fifo_init()
    {
        SciaRegs.SCIFFTX.all=0xE040;
        SciaRegs.SCIFFRX.all=0x204f;
        SciaRegs.SCIFFCT.all=0x0;
    }
    
    void scib_loopback_init()
    {
    
     	ScibRegs.SCICCR.all =0x0007;// Idle-line mode,// 1 stop bit,  No loopback  // No parity,8 char bits,
    	ScibRegs.SCICTL1.all =0x0003;// enable TX, RX, internal SCICLK,  // Disable RX ERR, SLEEP, TXWAKE
        ScibRegs.SCIHBAUD    =0x0000;
        ScibRegs.SCILBAUD    =0x000F;//BRR=15(0xFF),SCI Asynchronous Baud=292
    	ScibRegs.SCICCR.bit.LOOPBKENA =0;///Loop Back test mode enabled bit4[SCICCR]
    	ScibRegs.SCICTL1.all =0x0023;//re-enable the SCI by writing a 1 to SW RESET bit-5[SCICTL1]
    }
    //================Initialize the SCI FIFO==========================//
    void scib_fifo_init()
    {
        ScibRegs.SCIFFTX.all=0xE040;
        ScibRegs.SCIFFRX.all=0x204f;
        ScibRegs.SCIFFCT.all=0x0;
    }
    
    void scic_loopback_init()
    {
    
     	ScicRegs.SCICCR.all =0x0007;// Idle-line mode,// 1 stop bit,  No loopback  // No parity,8 char bits,
        ScicRegs.SCICTL1.all =0x0003;/// enable TX, RX, internal SCICLK,  // Disable RX ERR, SLEEP, TXWAKE
        ScicRegs.SCIHBAUD    =0x0000;
        ScicRegs.SCILBAUD    =0x000F;////BRR=15(0xFF),SCI Asynchronous Baud=292
    	ScicRegs.SCICCR.bit.LOOPBKENA =1;//Loop Back test mode disabled bit4[SCICCR]
    	ScicRegs.SCICTL1.all =0x0023;//re-enable the SCI by writing a 1 to SW RESET bit-5[SCICTL1]////Relinquish SCI from Reset
    }
    
    //================Initialize the SCI FIFO==========================//
    void scic_fifo_init()
    {
        ScicRegs.SCIFFTX.all=0xE040;
        ScicRegs.SCIFFRX.all=0x204f;
        ScicRegs.SCIFFCT.all=0x0;
    }
    
    void scia_xmit(int a)    //// Transmit a character from the SCI'
    {
        SciaRegs.SCITXBUF=a;
    }
    
    void scib_xmit(int a)   //// Transmit a character from the SCI'
    {
        ScibRegs.SCITXBUF=a;
    }
    
    void scic_xmit(int a)  //// Transmit a character from the SCI'
    {
        ScicRegs.SCITXBUF=a;
    }
    void error()
    {
          ErrorCount++;
    //    __asm("     ESTOP0");  // Uncomment to stop the test here
    //    for (;;);
    }

  • Mahesh,

    To know if your code is working check to see if the receive register has what you sent it. I also suggest comparing your code to another C2000Ware example:

    C:\ti\c2000\C2000Ware_<version>\device_support\f2833x\examples\scia_Autobaud

    as well as the two other examples for SCI, and refer to the Doc folder for the directions.

    In general, we do not review or debug user code, but we will provide assistance to you with specific issues relating to our devices and development tools. This includes clarifying the behavior of any bit, register, or features when designing with our devices. Please note that all peripherals have example code in C2000Ware / controlSUITE. We suggest comparing your code to the example code to determine where the problem may exist. It is recommended to follow standard and logical debugging techniques. Please continue to debug your code and feel free to use this forum to ask specific questions. The more specific the question, the better we can assist you.

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken
  • Dear sir ,
    My task is to send the char through SCI between PC and PCB.simply I want to see behavior of SCI .please suggest me correct sample code in controsuite.
  • Mahesh,

    All F28335 sample code for the SCI can be found in C2000Ware at:

    C:\ti\c2000\C2000Ware_<version>\device_support\f2833x\examples\

    then see the following folders:

    \sci_autobaud
    \sci_echoback
    \scia_loopback
    \scia_loopback_interrupts

    Also, please refer to the "TMS320x2833x, 2823x Serial Communications Interface (SCI) Reference Guide" at:

    www.ti.com/lit/SPRUFZ5

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken
  • I am doing Uart(SCI) communication. plz suggest me following GPIO initialization correct or not

    for  GPIO62 (SCIRXDC)---->  ,GPIO63 (SCITXDC)------>

    GpioCtrlRegs.GPBDIR.bit.GPIO62 =0;//RX--I/P
    GpioCtrlRegs.GPBDIR.bit.GPIO63 =1;//TX---O/P  ,is the initialization correct or not ?

    EALLOW;


    GpioCtrlRegs.GPBPUD.bit.GPIO62 = 0; // Enable pull-up for GPIO62 (SCIRXDC)
    GpioCtrlRegs.GPBPUD.bit.GPIO63 = 0; // Enable pull-up for GPIO63 (SCITXDC)

    GpioCtrlRegs.GPBQSEL2.bit.GPIO62 = 3; // Asynch input GPIO62 (SCIRXDC)

    GpioCtrlRegs.GPBMUX2.bit.GPIO62 = 1; // Configure GPIO62 for SCIRXDC operation
    GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 1; // Configure GPIO63 for SCITXDC operation

    GpioCtrlRegs.GPBDIR.bit.GPIO62 =0;//RX--I/P
    GpioCtrlRegs.GPBDIR.bit.GPIO63 =1;//TX---O/P

    EDIS;

  • Mahesh,

    Setting the direction is only applicable for when the pin is configured as GPIO (MUX = 00). Other than that, the code you have is fine and exactly matches the InitScicGpio() found in -

    C:\ti\c2000\C2000Ware_<version>\device_support\f2833x\common\source\DSP2833x_Sci.c

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken
  • Dear Sir,
    while doing the UART communication ,Is it necessary to initialize direction of GPIO ?
    so I have initialized GPIO as follows: that is correct or not?

    GpioCtrlRegs.GPBDIR.bit.GPIO62 =0;//RX--I/P
    GpioCtrlRegs.GPBDIR.bit.GPIO63 =1;//TX---O/P
  • mahesh joshi said:
    while doing the UART communication ,Is it necessary to initialize direction of GPIO ?

    Not Required. All you need to do is call InitSciaGpio()/InitScibGpio() routine. You can check the routines for required inits.

    Regards,

    Gautam

  • Dear sir,

              below I have initialized  GpIO for Uart . IS the correct or not ?I am not understood that "You can check the routines for required inits.?"

    EALLOW;

    GpioCtrlRegs.GPBPUD.bit.GPIO62 = 0; // Enable pull-up for GPIO62 (SCIRXDC)
    GpioCtrlRegs.GPBPUD.bit.GPIO63 = 0; // Enable pull-up for GPIO63 (SCITXDC)

    GpioCtrlRegs.GPBQSEL2.bit.GPIO62 = 3; // Asynch input GPIO62 (SCIRXDC)

    GpioCtrlRegs.GPBMUX2.bit.GPIO62 = 1; // Configure GPIO62 for SCIRXDC operation
    GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 1; // Configure GPIO63 for SCITXDC operation

    EDIS;

  • The configuration is correct. These configs are readily available in DSP2833x_Sci.c
  • Mahesh,

    Please read my previous reply. It specifically stated that setting the direction is only applicable for when the pin is configured as GPIO (MUX = 00). Other than that, the code you have is fine and exactly matches the InitScicGpio() found in -

    C:\ti\c2000\C2000Ware_<version>\device_support\f2833x\common\source\DSP2833x_Sci.c

    - Ken
  • Dear Sir,
    thanks for ur reply. Now I am transmitting the data from PC i.e (Hercules) to PCB .but it is not entering into the interrupt.plz guide me correct path.I shared my code:


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

    #pragma CODE_SECTION(InitFlash, "ramfuncs");
    /*
    #define CPU_FREQ 150E6
    #define LSPCLK_FREQ CPU_FREQ/4
    #define SCI_FREQ 100E3
    #define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1
    */


    void Send_Char_PortC( unsigned char Byte );

    // Prototype statements for functions found within this file.
    //__interrupt void scicTxFifoIsr(void);
    __interrupt void scicRxFifoIsr(void);
    void scic_fifo_init(void);
    void InitScicGpio();

    Uint16 rdataC[16]; // Received data for SCI-C

    extern Uint16 RamfuncsLoadStart;
    extern Uint16 RamfuncsLoadEnd;
    extern Uint16 RamfuncsRunStart;
    extern Uint16 RamfuncsLoadSize;

    void Delay()
    {
    unsigned int i,j;
    for(i = 0;i < 500;i++)
    for(j = 0;j < 500;j++);
    }

    void main(void)
    {
    // Uint16 i;
    // unsigned char SendChar = 0xAA;

    InitSysCtrl();
    InitScicGpio();
    DINT;

    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();

    MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
    InitFlash();

    EALLOW;
    PieVectTable.SCIRXINTC = &scicRxFifoIsr;
    // PieVectTable.SCITXINTC = &scibTxFifoIsr;
    EDIS;

    scic_fifo_init(); // Init SCI-C

    PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
    PieCtrlRegs.PIEIER8.bit.INTx5 = 1; // PIE Group 8, INT5[8----5---Rx]
    // PieCtrlRegs.PIEIER8.bit.INTx6=1; // PIE Group 8, INT6[8----6---Tx]
    IER = 0x080;
    EINT;

    while(1)
    {
    Send_Char_PortC(0xAA);
    //ScicRegs.SCITXBUF=SendChar;

    // SendChar++;
    // SendChar &= 0xFF;
    Delay();Delay();Delay();Delay();
    }


    }
    /*
    __interrupt void scicTxFifoIsr(void)
    {
    Uint16 i;
    for(i=0; i< 8; i++)
    {
    scicRegs.SCITXBUF=sdataB[i]; // Send data
    }

    for(i=0; i< 8; i++) //Increment send data for next cycle
    {
    sdataB[i] = (sdataB[i]-1) & 0x00FF;
    }


    ScicRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ACK
    }
    */
    __interrupt void scicRxFifoIsr(void)
    {
    // Uint16 i;
    unsigned char i=0;
    for(i=0;i<=7;i++)
    {
    rdataC[i]=ScicRegs.SCIRXBUF.all; // Read data
    }

    ScicRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
    ScicRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
    //PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack
    PieCtrlRegs.PIEACK.all= PIEACK_GROUP8;
    }

    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;
    ScicRegs.SCIHBAUD = 0x0001;// 0x0001
    ScicRegs.SCILBAUD = 0x00E7;//
    // ScicRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
    ScicRegs.SCIFFTX.all=0xC021;//0xC021//0xC060
    ScicRegs.SCIFFRX.all=0x0028;//0x0028//// 0xE065
    ScicRegs.SCIFFCT.all=0x00;

    ScicRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
    ScicRegs.SCIFFTX.bit.TXFIFOXRESET=1;
    ScicRegs.SCIFFRX.bit.RXFIFORESET=1;
    }

    void InitScicGpio()
    {
    EALLOW;

    GpioCtrlRegs.GPBPUD.bit.GPIO62 = 0; // Enable pull-up for GPIO62 (SCIRXDC)
    GpioCtrlRegs.GPBPUD.bit.GPIO63 = 0; // Enable pull-up for GPIO63 (SCITXDC)

    GpioCtrlRegs.GPBQSEL2.bit.GPIO62 = 3; // Asynch input GPIO62 (SCIRXDC)

    GpioCtrlRegs.GPBMUX2.bit.GPIO62 = 1; // Configure GPIO62 for SCIRXDC operation
    GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 1; // Configure GPIO63 for SCITXDC operation

    GpioCtrlRegs.GPBDIR.bit.GPIO62 =0;//RX--I/P
    GpioCtrlRegs.GPBDIR.bit.GPIO63 =1;//TX---O/P

    EDIS;
    }

    void Send_Char_PortC( unsigned char Byte )
    {
    ScicRegs.SCITXBUF = Byte;
    Delay();
    }
  • Mahesh,

    If you are not getting into the ISR check to be sure the interrupts are enabled. You have some code lines commented out, double check if they are needed. Also, check if the INTM, IER, and PIEIER is enabled for the appropriate ISR. From a previous post, setting the GPIO direction is only applicable for when the pin is configured as GPIO (MUX = 00).

    - Ken

  • Mahesh,

    It's been a while since we have heard from you last. Therefore, we are assuming you were able to resolve your issue. If this isn’t the case, please reject this resolution or reply to this thread. If this thread locks, please make a new thread describing the current status of your issue. Thank you.

    - Ken
  • Dear sir,
    I have tried to do SCI communication .problem is when I have send the data (8bit)from herculues ,it doesnot go into receive_interrupt,what should I have to do in such sistuation?