Hi!
Today I am testing UART 0 RX function through interrupt flag URX0IF polling.
I am using the Hyperterminal to send messages from the computer to the CC2530 board using UART via RS-232.
However, in debug mode, the URX0IF flag does not become high when I type a letter in the Hyperterminal.
I've used this Receiving function:
void uart0Receive(char* uartRxBuf, unsigned short uartRxBufLength)
{
unsigned short uartRxIndex;
U0CSR |= 0x40;
URX0IF = 0;
halLcdWriteChar(1,0,'x');
for(uartRxIndex = 0; uartRxIndex < uartRxBufLength; uartRxIndex++){
halLcdWriteChar(1,0,'y');
while (!URX0IF);
halLcdWriteChar(1,0,'z');
uartRxBuf[uartRxIndex] = U0DBUF;
URX0IF = 0;
}
}
Here is how I initialized UART
void halUartInit(void){
U0CSR |= 0x80; //UART mode selected for USART0.
U0UCR |= 0x40; //H/w flow control enable.
PERCFG &= ~0x01; //Alernative 1 selected for UART0 peripheral.
P0SEL |= 0x0C; //P0.2 and P0.3 peripheral mode enabled.
CLKCONCMD = CLKCONSTA & 0xB8; //initialized clock to 32MHz
while(CLKCONSTA & 0x40);
U0GCR |= 0x0C; U0BAUD = 0xD8; //Baud rate set to 230400 bps.
//U0GCR |= 0x0A; U0BAUD = 0xD8; //Baud rate set to 57600 bps.
//U0GCR |= 0x08; U0BAUD = 0x3B; //Baud rate set to 9600 bps.
}
Here is a function in the main:
char* a;
halLcdClear();
while(1){
uart0Receive(a, 1);
Serial_Print("Received: ");
Serial_Println(a);
}
(Basically the Serial_Print and Serial_Println functions are guaranteed
working UART TX functions and transmits the given string parameter and
have them show up on the Hyperterminal)
Am I missing something?
Thank you!