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.

UART functionality with PER test project

Hi,

 I wanted UART functionality in PER test project. There is a hal_uart.h file already present but there is no hal_uart.c file present.

So effectively there was no uart functionality supported by the PER test project.

I included hal_uart.c file from SerialApp project into PER test project.

But still the uart call back function does not get triggered on data being received at UART.

I feel hal_board.h and hal_board.c files in PER test project are different compared to that in SerialApp project.

These two files along with hal_board_cfg.h file are to be configured properly for UART to work properly in PER test.

But I could not figure out what all needs to be changed in these files.

Could some one help me regarding this?

Thanks and Regards,

Vamsi.

  • Please refer DN112 swra222b.pdf  for UART details and sample code. 

    The attached code may be a quick start for you that uses UART0 ALT1 on P0.2 RX & P0.3 TX.

    #define uint unsigned int
    #define uchar unsigned char
    
    char Txdata[30]="RF Uart Test";
    
    void Delay(uint n)
    {
    	uint i;
    	for(i=0;i<n;i++);
    	for(i=0;i<n;i++);
    	for(i=0;i<n;i++);
    	for(i=0;i<n;i++);
    	for(i=0;i<n;i++);
    }
    
    void InitUART(void)
    {
    
        CLKCONCMD &= ~0x40;              
        while(!(SLEEPSTA & 0x40));      
        CLKCONCMD &= ~0x47;             
        SLEEPCMD |= 0x04; 		 
    
        //UART0 ALT1 on P0
        P0SEL |= 0x3c;
        PERCFG &= ~0x01;
        P2DIR &= ~0XC0;
    
        U0CSR |= 0x80;  //Buad 57600
        U0GCR |= 10;				
        U0BAUD |= 216;			
    
        UTX0IF = 0;
        U0UCR = 0x80;
    
        U0CSR |= 0x40; 
        URX0IF = 0;
    }
    
    void UartTX_Send_String(char *Data,int len)
    {
      int j;
      for(j=0;j<len;j++)
      {
        U0DBUF = *Data++;  
        while(UTX0IF == 0);
        UTX0IF = 0;
      }
      U0UCR |= 0x80;
    
    }
    
    void main(void)
    {	
    	uchar i;
    	uchar rx_byte;
     
    	InitUART();
    
      for(i=0;i<30;i++)txBuffer[i]=' ';
    
      strcpy(txBuffer,"UART0 test ");      
    
      // Loop back test : Send whatever received
      
    	while(1)
    	{
        while( !URX0IF );
        rx_byte = U0DBUF;
        URX0IF = 0;
    	  
        U0DBUF = rx_byte;  
        while(UTX0IF == 0);
        UTX0IF = 0;
      }
    }