i am a newbie to TM4C123G
Could anyone please guide me if my code is correct
I am trying to use PD6 to receive card number from a RDM6300 RFID Card reader
Baud rate: 9600
8 Bits
1 stop bit
No parity
FIFO enabled
Interrupt at 7/8 full
following is my code:
#define UART_FR_RXFE 0x00000010 // UART Receive FIFO Empty
#define UART_LCRH_WLEN_8 0x00000060 // 8 bit word length
#define UART_LCRH_FEN 0x00000010 // UART Enable FIFOs
#define UART_CTL_UARTEN 0x00000001 // UART Enable
void UART_Init(void){
SYSCTL_RCGCUART_R |= 0x04; // activate UART2
SYSCTL_RCGCGPIO_R |= 0x08; // activate port D
while((SYSCTL_PRGPIO_R&0x08) == 0);
UART2_CTL_R = 0; // disable UART
UART2_IBRD_R = 104; /* for 9600 baud rate, integer = 104 */
UART2_FBRD_R = 11; /* for 9600 baud rate, fractional = 11*/
UART2_LCRH_R = (UART_LCRH_WLEN_8|UART_LCRH_FEN);
UART2_CTL_R |= UART_CTL_UARTEN; // enable UART
GPIO_PORTD_AFSEL_R |= 0x40; // enable alt funct on PD6
GPIO_PORTD_DEN_R |= 0x40; // enable digital I/O on PD6
GPIO_PORTD_PCTL_R = (GPIO_PORTD_PCTL_R&0x0F000000)+0x01000000; // configure PD6 as UART
GPIO_PORTD_AMSEL_R = 0; // disable analog functionality on PD
// enable interrupt
UART2_ICR_R &= 0x10; // Clear receive interrupt
UART2_IM_R = 0x10;
NVIC_EN1_R =1;
NVIC_PRI8_R = (NVIC_PRI8_R&0xFFFFFFF0)|0x0000000A; // (g) priority 0
}
void UART2_Handler( void )
{
char tag_arr[13];
uint16_t i=0;
unsigned char rx_data = 0;
UART2_ICR_R &= 0x10; // Clear receive interrupt
rx_data = UART2_DR_R ; // get the received data byte
LCD4bits_Data (rx_data);
tag_arr[i]=rx_data;
i++;
}