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.

TMS320F28027: SCI communication is not receiving continuously.

Part Number: TMS320F28027


Dear all;

I am using F28027 and I am trying to make a communication on SCI between two DSP. Transmitter is transmitting the data. I have observed iton scope. However reciever is not receiving continuously. I have a delay loop in transmitter code and the longer I keep the delay time, the more receiver stuck on while condition to check flag. When I increase delay time code is waiting on while continuously, like there is no incoming data. When I make shorter delay time, it stuck less. Could someone tell me how to get rid of this problem. Here is my transmitter and receiver codes.

   for(;;)
	    {
	    	SendChar=0;
	    	for (SendChar=1; SendChar<=255; SendChar++)
	    	{
	    		delay_loop();
	    		scia_txmit(SendChar);
	    		/*while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY =1 for empty state
	    		// Check received character
	    		ReceivedChar = SciaRegs.SCIRXBUF.all;
	    		if(ReceivedChar != SendChar) error();
	    		LoopCount++;*/
	    	}
	    }

void scia_init()
		{

	  	    //02.03.2017 SCI configuration for bluetooth
	  	    EALLOW;
	  	    GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; 	//enable pull-up for gpio28(SCIRXDA)
	  	    GpioCtrlRegs.GPAPUD.bit.GPIO29 = 1; 	//disable pull-up for gpio29(SCITXDA)
	  	    GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3;	//asynch input GPIO28 (SCIRXDA)
	  	    GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;	//configure gppio as SCI transmitter
	  	    GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; 	//configure gppio as SCI reciever
	  	    EDIS;



			SciaRegs.SCICCR.bit.STOPBITS = 0; 		//one stop bit
			SciaRegs.SCICCR.bit.PARITYENA = 0; 		//disable parity
			SciaRegs.SCICCR.bit.LOOPBKENA = 0;		//loop back disable(when Tx connected internaly Rx)
			SciaRegs.SCICCR.bit.ADDRIDLE_MODE = 0;	//idle mode enable
			SciaRegs.SCICCR.bit.SCICHAR = 7;		//bith lenght is 8 bits

			SciaRegs.SCICTL1.bit.TXENA = 1;			//transmitter enable
			SciaRegs.SCICTL1.bit.RXENA = 1;			//receiver enable

			SciaRegs.SCICTL2.bit.TXINTENA = 1;		//Enable TXRDY interrupt
			SciaRegs.SCICTL2.bit.RXBKINTENA = 1;	//enable RXRDY interrupt
			//örnekte ikikez yazılmış?

			SciaRegs.SCIHBAUD = 0x0000;
			SciaRegs.SCILBAUD = 0x000F;					//LSPCLK = 12.5 MHz (50 MHz SYSCLK)  baud=LSPCLK/(16*8)

			SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
			SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
		}

		//transmitter function
		void scia_txmit(int a)
		{

			SciaRegs.SCITXBUF = a;

		}

		void scia_fifo_init()
		{
			SciaRegs.SCIFFTX.all=0xE040;
			SciaRegs.SCIFFRX.all=0x2044;
			SciaRegs.SCIFFCT.all=0;
		}

		void delay_loop()
		{
			short      i;
			for (i = 0; i < 100; i++) {}
		}

the code which is written above is for transmitter side.

I used timer interrupt for delay time but I had same problem.

For receiver side, I have described a variable named Received as uint8. Nevertheless, receiver dsp shows it as unsigned char. I want to learn why. and like I said before, it is stucking on while condition frequently (depends on delay time)

And here is receiver code

 

for(;;) {
	        //asm(" NOP"); // main loop (interrupt bekle)
	    	SciaRegs.SCICTL1.bit.RXENA = 1;
	    	while(SciaRegs.SCIRXST.bit.RXRDY == 0) { } // wait for XRDY =1 for empty state
	    	//while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { }
	    	       // Get character
	    	Received = SciaRegs.SCIRXBUF.all;
	    	Received = Received & 0x00FF;
	    	SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;
	    	//asm (" NOP");
	    	//SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;
	    }

void scia_init()
		{

	  	    //02.03.2017 SCI configuration for bluetooth
	  	    EALLOW;
	  	    GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; 	//enable pull-up for gpio28(SCIRXDA)
	  	    //GpioCtrlRegs.GPAPUD.bit.GPIO29 = 1; 	//disable pull-up for gpio29(SCITXDA)
	  	    GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3;	//asynch input GPIO28 (SCIRXDA)
	  	    GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;	//configure gppio as SCI reciever
	  	    //GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; 	//configure gppio as SCI transmitter
	  	    EDIS;



			SciaRegs.SCICCR.bit.STOPBITS = 0; 		//one stop bit
			SciaRegs.SCICCR.bit.PARITYENA = 0; 		//disable parity
			SciaRegs.SCICCR.bit.LOOPBKENA = 0;		//loop back disable(when Tx connected internaly Rx)
			SciaRegs.SCICCR.bit.ADDRIDLE_MODE = 0;	//idle mode enable
			SciaRegs.SCICCR.bit.SCICHAR = 7;		//bith lenght is 8 bits

			//SciaRegs.SCICTL1.bit.TXENA = 1;			//transmitter enable
			SciaRegs.SCICTL1.all = 0x0001;			//receiver enable

			//SciaRegs.SCICTL2.bit.TXINTENA = 1;		//Enable TXRDY interrupt
			SciaRegs.SCICTL2.all = 0x0002;	//enable RXRDY interrupt
			//örnekte ikikez yazılmış?

			//autobaud detection(14.03.2017)
			SciaRegs.SCIFFCT.bit.CDC = 1;		//Enable aoutoboaud aligment
			SciaRegs.SCIFFCT.bit.ABDCLR = 1;    //clear abd bit

			SciaRegs.SCIHBAUD = 0x0000;					//selact a baud speed below 500 kbps
			SciaRegs.SCILBAUD = 0x0001;					//LSPCLK = 12.5 MHz (50 MHz SYSCLK)  baud=LSPCLK/(16*8)

			//SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
			SciaRegs.SCICTL1.all =0x0021;     // Relinquish SCI from Reset

			//SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;		//enable fifo tx interrupt so as to disable autobaud
		}

	void scia_fifo_init()
	{
	    SciaRegs.SCIFFTX.all=0xE040;
	    SciaRegs.SCIFFRX.all=0x2044;
	    SciaRegs.SCIFFCT.all=0x0;
	}

I will be glade if someone help me immediately.

Thanks a lot.

Regards

Fahri

  • Fahri,

    I'm sorry that you are experiencing some trouble getting your code working. Let's see if I can help get it sorted out.

    First, from what you have stated, the transmitter side appears to be sending the data as expected, without troubles. So I think that we can eliminate that as a cause for now.

    I am going to confirm this, but I believe that you should not use the RXRDY if using the receive FIFO, you must use RXFFST. The SCI HW will clear the RXRDY bit when it moves the data from the Shift register to the FIFO. Consider moving the polling loop over to using RXFFST, and I will try and get a confirmation of the behavior quickly.

    Regards,
    Mark
  • Hi Mark

    Thank you for your attantion. I have solved this problem, but I am still working on SCI, so if I need any help, I will write you on here

    Thank you again.

    Regards

    Fahri

  • Fahri,

    I am glad to hear that you were able to figure it out on your own. Could you share what your resolution was to this issue? Others may find it useful.
    If you have additional questions in the future, please don't hesitate to create a new post!

    Thanks,
    Mark
  • Hi Mark

    Sorry for late response. After your advice, I have changed RXRDY flag with RXFFST regs. And I had ground problem, I fixed it. With wire, it is communicating succesfully. 

    Nevertheless, I have again another problem. I have removed the wire and connect a bluetooth device to make communication as wireless, when I connect receiver pin to bluetooth module, ground level of F28027 is rising. Because of that, when a data is sent, DSP could not receive it. Because ground level is not zero anymore. I used a buffer, but ground level is still rising up. Could you tell me your idea why it is happenning and how I can overcome it.

    Thank you.

    Regards.

    Fahri

  • Fahri,

    Please create a new post as this sounds like a different issue not related to the initial topic of this conversation.

    -Mark