Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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 Sci problem

Other Parts Discussed in Thread: UNIFLASH

hi, i  have made only a few changes on control suite echoback example. i want to turn off the led when i send "2" and turn on when i send "3". but it doesn't work. i hope you help me to find problem. thank you for answering.

regards

#include "DSP28x_Project.h"

void scia_echoback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void scia_msg(char *msg);
void delay_loop(void);

Uint16 LoopCount;
Uint16 ErrorCount;

void main(void)

{
    Uint16 ReceivedChar;
    char *msg;

   InitSysCtrl();	// PLL, WatchDog, enable Peripheral Clocks	--DSP2833x_SysCtrl.c
   InitSciaGpio();

   DINT;	// Disable CPU interrupts

   InitPieCtrl();	// The default state is all PIE interrupts disabled and flags are cleared.	--DSP2833x_PieCtrl.c

   IER = 0x0000;	// Disable CPU interrupts and Level 1 interrupt enable;
   IFR = 0x0000;	// Dlear all CPU interrupt flags

   InitPieVectTable();	// This is useful for debug purposes.	--DSP2833x_PieCtrl.c
   EnableInterrupts();

   EALLOW;  // This is needed to write to EALLOW protected registers
   GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 0;  //set as gpio
   GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;   // set as output
   GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0; // low
   EDIS; // This is needed to disable write to EALLOW protected registers

   GpioDataRegs.GPASET.bit.GPIO31 = 1;   //ters çalışıyor

   LoopCount = 0;
   ErrorCount = 0;

    scia_fifo_init();	   // Initialize the SCI FIFO
    scia_echoback_init();  // Initialize SCI for echoback

    msg ="\n\rLED ON  -> 3\n\rLED OFF -> 2";
    scia_msg(msg);

	for(;;)
    {
       // Wait for inc character
       while(SciaRegs.SCIFFRX.bit.RXFFST !=0) { } // wait for XRDY =1 for empty state

       ReceivedChar = SciaRegs.SCIRXBUF.all; // Get character

      if (ReceivedChar != '\0')// wait till transmission starts ,note that null condition will stand true even
           //if voltage data sends zero,to avoid that the flag bits being sent are other then zero
       {

    	   if (ReceivedChar == 3 )
    	   {
    		   GpioDataRegs.GPACLEAR.bit.GPIO31 = 1;
    		   msg = " LED ON ";
    		   scia_msg(msg);
    		   delay_loop();
    	   }
    	   else if (ReceivedChar == 2)
    	   {
    		   GpioDataRegs.GPASET.bit.GPIO31 = 1;
    		   msg = " LED OFF ";
    		   scia_msg(msg);
    		   delay_loop();
    	   }
       }
      // LoopCount++;
    }
}


void scia_echoback_init()// Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
{
    // 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; // SCITXBU-register interrupt enable
	SciaRegs.SCICTL2.bit.RXBKINTENA =1; // recieve interrupt enable

#if (CPU_FRQ_150MHZ)
   SciaRegs.SCIHBAUD    =0x0001;  // 9600 baud @LSPCLK = 37.5MHz.
   SciaRegs.SCILBAUD    =0x00E7;
#endif
#if (CPU_FRQ_100MHZ)
    SciaRegs.SCIHBAUD    =0x0001;  // 9600 baud @LSPCLK = 20MHz.
    SciaRegs.SCILBAUD    =0x0044;
#endif

	SciaRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset 0010
}


void scia_xmit(int a)// Transmit a character from the SCI
{
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
    SciaRegs.SCITXBUF=a;
}


void scia_msg(char * msg)
{
    int i;
    i = 0;
    while(msg[i] != '\0')
    {
        scia_xmit(msg[i]);
        i++;
    }
}


void scia_fifo_init()// Initialize the SCI FIFO
{

    SciaRegs.SCIFFTX.all=0xE040; //1110 0000 0100 0000
    SciaRegs.SCIFFRX.all=0x204F; //0010 0000 0100 1111
    SciaRegs.SCIFFCT.all=0x0;
}


void delay_loop()
{
    long i;
    for (i = 0; i < 2500000; i++) {}
}