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.

CC2530 UART1 problem

Other Parts Discussed in Thread: CC2530, Z-STACK

Hi All. We use P1_6 as TX and P1_7 as RX in cc2530 custom board. I tried to debug UART funciton in the board. So I wrote such program to test it. I'm using cc2530F256 chip and my IAR version is 9.20.2. After I run the program, I got nothing in the TX pin. I don't know why.

#include "ioCC2530.h"
#include <string.h>

#define uchar unsigned char
#define uint  unsigned int


#define led1 P0_0


void delayms(uint ms);              
void ledInit();                      
void uartInit();                     
void uartSend(char *Data, int len);  


uchar RXTXflag = 1;                  
char  temp;                          
uchar datanumber = 0;                
char  Rxdata[12] = { '0','1','2','3','4','5','6','7','8','9' };                   


/***********************************

***********************************/
void delayms(uint ms)
{
  int i, j;
  for(i=ms; i>0; i--)
    for(j=1156; j>0; j--);
}

/***********************************

***********************************/
void ledInit()
{
  P0SEL &= ~0x01;  //set as general I/O
  P0DIR |= 0x01;   //set as output
  P0INP &= ~0x01;  //set pull-up pull-down mode
 
  led1 = 0;
}

/***********************************

***********************************/
void uartInit()
{

 
  CLKCONCMD &= ~0x40;      
  while(!(SLEEPSTA & 0x40));
  CLKCONCMD &= ~0x07;     
 
  SLEEPCMD  |= 0x04;       
 
 
  //
  PERCFG &= ~0x02;            //set USART1 Alt2
  P1SEL  |=  0xc0;            //P1_7、P1_6 used as UART
  P1DIR  &=  ~0x80;             //P1_7 as input and P1_6 as output
 // P2DIR  &= ~0x80;            // the frist priority is UART1
  P2SEL &= ~ 0x20;
  P2SEL |= 0x40;
 
  //
  U1CSR  |= 0x80;              //set UART mode
  U1UCR   = 0x02;
  U1GCR  |= 10;                //set BPS 38400
  U1BAUD |= 59;               //
  UTX1IF  = 0;                 //UART1 TX interrupt
  U1CSR  |= 0x40;              //enable UART1 TX
  IEN0   |= 0x88;              //Enable Interrupt
  IEN2   |= 0x08;
 
}

/***********************************

***********************************/
void uartSend(char *Data, int len)
{
  int j;
  for(j=0; j<len; j++)         //
  {
    U1DBUF = *Data++;          //
    while(UTX1IF == 0);        //
    UTX1IF = 0;                //
  }
}

/***********************************

***********************************/
void main()
{
  //
  ledInit();
  uartInit();
#if 1
 
  datanumber = 12;
 
  while (1)
  {
      U1CSR &= ~0x40;          //disable receive
      uartSend(Rxdata, datanumber); //
      RXTXflag = 1;            //
      //datanumber = 0;          //
  }
#endif
 

}

#pragma vector = URX1_VECTOR
__interrupt void UART1_ISR(void)
{
  URX1IF = 0;  
  temp = U1DBUF;
}