Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 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: Serial Communication.. SCITXDA & SCIRXDA---Example 9_4 (Receiving is not working)

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Dear TI members,

I am testing example 9_4 from the TI F28335 manual, I am unable to receive the data string ("Instruments") by inserting the text "Texas" on the terminal. The example Module 9 with its sample code is given as below:

Code: 

//
//      Lab9_4: TMS320F28335
//      (c) Frank Bormann
//
//###########################################################################
//
// FILE:	Lab9_4.c
// 
// TITLE:	DSP28 SCI - Communication to PC - Terminal
//			SCI-Setup: 9600 Baud, 8 Bit , ODD Parity , 1 Stopbit	
//			SCI - TX and RX - Interrupt are used in this Lab 
//			SCI - TX and RX - FIFO are used in this Lab
//			DSP waits for "Texas" and answers with "Instruments"
//			Watchdog active , serviced solely in main-loop 
//###########################################################################
//  Ver | dd mmm yyyy | Who  | Description of changes
// =====|=============|======|===============================================
//  3.0 | 08 Jul 2009 | F.B. | adapted for ControlCard28335 @ 20MHz
//  3.1 | 15 Nov 2009 | F.B  | Lab9_4 for F28335 @30MHz and PE revision 5
//###########################################################################
#include "DSP2833x_Device.h"
#include <string.h>
  
// External Function prototypes
extern void InitSysCtrl(void);
extern void InitPieCtrl(void);
extern void InitPieVectTable(void);

// Prototype statements for functions found within this file.
void Gpio_select(void);
void SCIA_init(void);
interrupt void SCIA_TX_isr(void);	 // SCI-A Transmit Interrupt Service
interrupt void SCIA_RX_isr(void);	 // SCI-A Receive  Interrupt Service

// Global Variables
char message[]={" Instruments! \n\r"};

//###########################################################################
//						main code									
//###########################################################################
void main(void)
{
	InitSysCtrl();	// Basic Core Initialization
					// SYSCLK=150MHz, HISPCLK=75MHz, LSPCLK=37.5MHz
	EALLOW;
   	SysCtrlRegs.WDCR= 0x00AF;		  // Re-enable the watchdog 
   	EDIS;			// 0x00E8  to disable the Watchdog , Prescaler = 1
   					// 0x00AF  to NOT disable the Watchdog, Prescaler = 64
	
	Gpio_select();	// GPIO9, GPIO11, GPIO34 and GPIO49 as output
					// to 4 LEDs at Peripheral Explorer			
	
	InitPieCtrl();		// default status of PIE; in DSP2833x_PieCtrl.c
	
	InitPieVectTable(); // init PIE vector table; in DSP2833x_PieVect.c
	
	// re-map PIE - entry for SCI-A-TX and SCI-A-RX
	EALLOW;  
   	PieVectTable.SCITXINTA = &SCIA_TX_isr;
	PieVectTable.SCIRXINTA = &SCIA_RX_isr;
   	EDIS;    
   		
   	SCIA_init();  // Initalize SCI 
   
    // Enable SCI-A TX Interrupt Group9 interupt 2
	PieCtrlRegs.PIEIER9.bit.INTx2 = 1;
	// Enable SCI-A RX Interrupt Group9 interupt 1
	PieCtrlRegs.PIEIER9.bit.INTx1 = 1;


	// Enable INT9 for SCIA-TX and SCIA-RX:
    IER = 0x100;
    
	// Enable global Interrupts and higher priority real-time debug events:
   	EINT;   // Enable Global interrupt INTM
   	ERTM;   // Enable Global realtime interrupt DBGM
   	
	while(1)
	{    
	  	EALLOW;
		SysCtrlRegs.WDKEY = 0x55;			// Service watchdog #1
		SysCtrlRegs.WDKEY = 0xAA;			// Service watchdog #2
		EDIS;
	}
} 	

void Gpio_select(void)
{
	EALLOW;
	GpioCtrlRegs.GPAMUX1.all = 0;			// GPIO15 ... GPIO0 = General Puropse I/O
	GpioCtrlRegs.GPAMUX2.all = 0;			// GPIO31 ... GPIO16 = General Purpose I/O
	
	GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;	// SCIRXDA
	GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1;	// SCITXDA	
	
	GpioCtrlRegs.GPBMUX1.all = 0;			// GPIO47 ... GPIO32 = General Purpose I/O
	GpioCtrlRegs.GPBMUX2.all = 0;			// GPIO63 ... GPIO48 = General Purpose I/O
	GpioCtrlRegs.GPCMUX1.all = 0;			// GPIO79 ... GPIO64 = General Purpose I/O
	GpioCtrlRegs.GPCMUX2.all = 0;			// GPIO87 ... GPIO80 = General Purpose I/O
	 
	GpioCtrlRegs.GPADIR.all = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO9 = 1;		// peripheral explorer: LED LD1 at GPIO9
	GpioCtrlRegs.GPADIR.bit.GPIO11 = 1;		// peripheral explorer: LED LD2 at GPIO11

	GpioCtrlRegs.GPBDIR.all = 0;			// GPIO63-32 as inputs
	GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;	// peripheral explorer: LED LD3 at GPIO34
	GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1; // peripheral explorer: LED LD4 at GPIO49

	GpioCtrlRegs.GPCDIR.all = 0;			// GPIO87-64 as inputs
	EDIS;
} 

void SCIA_init()
{    
   	SciaRegs.SCICCR.all =0x0027;   	// 1 stop bit,  No loopback 
                                   	// ODD parity,8 char bits,
                                   	// async mode, idle-line protocol
	SciaRegs.SCICTL1.all =0x0003;  	// enable TX, RX, internal SCICLK, 
                                   	// Disable RX ERR, SLEEP, TXWAKE
	
	// SYSCLOCKOUT = 150MHz; LSPCLK = 1/4 = 37.5 MHz
	// BRR = (LSPCLK / (9600 x 8)) -1
	// BRR = 487  gives 9605 Baud
	SciaRegs.SCIHBAUD    = 487 >> 8;		// Highbyte
	SciaRegs.SCILBAUD    = 487 & 0x00FF;	// Lowbyte

	SciaRegs.SCICTL2.bit.TXINTENA = 1; 		// enable SCI-A Tx-ISR
	SciaRegs.SCICTL2.bit.RXBKINTENA = 1; 	// enable SCI_A Rx-ISR

	SciaRegs.SCIFFTX.all = 0xC060;	// bit 15 = 1 : relinquish from Reset
									// bit 14 = 1 : Enable FIFO
									// bit 6 = 1 :  CLR TXFFINT-Flag
									// bit 5 = 1 :  enable TX FIFO match
									// bit 4-0 :  TX-ISR, if TX FIFO is 0(empty) 
	SciaRegs.SCIFFCT.all = 0x0000;	// Set FIFO transfer delay to 0
	
	SciaRegs.SCIFFRX.all = 0xE065;	// Rx interrupt level = 5

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

// SCI-A Transmit Interrupt Service
interrupt void SCIA_TX_isr(void)	 
{
	unsigned int i;
	// copy 16 character into SCI-A TX buffer
	for(i=0;i<16;i++) SciaRegs.SCITXBUF= message[i];
	// Acknowledge this interrupt to receive more interrupts from group 9
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;  
}

// SCI-A Receive Interrupt Service
interrupt void SCIA_RX_isr(void)
{
	int i;
	char buffer[16];
	for (i=0;i<16;i++) buffer[i]= SciaRegs.SCIRXBUF.bit.RXDT;
	
	if (strncmp(buffer, "Texas", 5) == 0)
	{
		SciaRegs.SCIFFTX.bit.TXFIFOXRESET =1;  // enable TXFIFO
		SciaRegs.SCIFFTX.bit.TXFFINTCLR = 1 ;  // force TX-ISR		
	}
	 	
	SciaRegs.SCIFFRX.bit.RXFIFORESET = 0;	// reset RX-FIFO pointer  
	SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;	// enable RX-operation
	SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;    // clear RX-FIFO INT Flag
	PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;  
}

//===========================================================================
// End of SourceCode.
//===========================================================================

The Result window is shown below: By typing " Texas" and then pressing enter, I don't receive "Instruments" at the Terminal.... which is a problem:

Please suggest accordingly.

Thanks

Regards

Arsalan

  • Hi Arsalan,

    • Could you please provide the link to your Lab 9_4 document and source? I don't see this lab in our current Academy archive.
    • Are you entering the SCI TX and RX ISRs at all? Can you set breakpoints there to confirm?
    • Are you able to test the C2000Ware SDK device_support SCI echoback example and receive successfully?
    • Are you using the F28335 controlCARD for this? Can you please check which position the switch 1 is in?

    Best Regards,

    Allison

  • Hi Allison Nguyen,

    Thanks for your reply.

    I moved to an example SCI echo back to check whether I was receiving characters from the terminal or not.

    The very first error I see in the example is given below:

    Remember. Here SW1 is on (For UART to USB connection, no DB 9 is connected to headers GPIO28/29).

    Code: 

    Please suggest to resolve this error. 

    Thanks

    Regards

    Arsalan

  • Hi Arsalan,

    Regarding the first error from the image, I do not see this when I import and compile the project. Are you making modifications to this EPWM example? Or are you saying you import it "out-of-box" and it does not build properly in CCS?

    Secondly, to clarify are you saying you are able to successfully run the echoback example? Or are you having issues with our SCI echoback example without having made modifications to it?

    Best Regards,

    Allison

  • Hi Allison,

    Thanks for your reply.

    I imported the project directly instead of running on the EPWM example. The Building Error has been removed or gone finally. This problem has been resolved now. Next step, I ran the simulation and checked the serial terminal with " some characters written on the terminal: "Hello World..... Enter a Character...". It means transmitting is working fine. Now when I write a character "A"  or any character or word. and press Send button (Please see picture below... the Send window). It can't be seen on the terminal. I assume that the DSP is not receiving the Character "A" that's why can't see it here on the Terminal Screen. 

    Remember the SW1 is On (UART to USB communication... no DB is connected here). Please suggest to resolve this issue.

    Same case is here: I also verify this by using the CCS terminal. By typing the Character "AAA"  and then pressing enter, nothing appeared on the terminal Screen. It seems (the DSP is not receiving character). No changes in SCIA  Registers values while sending Characters through the terminal.

    Please suggest to resolve this issue.

    Kind Regards

    Arsalan

  • Hi Arsalan,

    This may be a another issue due to hardware setup. Please review this related thread to see if it able to resolve this:

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/817929/ccs-tms320f28335-sci-echo-back-rx-issues 

    Best Regards,

    Allison

  • Hi Allison,

    Thanks for your reply.

    It works finally...(See Picture Below). Also, the example I shared at the beginning of my first post above works very well. Thanks

    I am very thankful to you and your team's support. 

    Kind Regards

    Arsalan

  • Hi Arsalan,

    So glad to hear it is working- and the example as well! I will close this thread for now, but feel free to open another one should you run into further issues Slight smile

    Best Regards,

    Allison