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.

CCS/TM4C123GH6PM: Not able to transmit data through interrupts on UART.

Part Number: TM4C123GH6PM

Tool/software: Code Composer Studio

Hi,

I am trying to write code to transmit one byte of data through UART0. The control is transferred to the UART handler only once and after that the transmit interrupt is not triggered. Also after inserting data into UART_DR register when I am single stepping through code, data is not reflected in the UART0_DR register. I am hereby attaching my UART.c file. 

typedef struct
{
    bool is_tx_over;
    uint16_t *tx_buff_ptr;
    uint16_t numofbytes;
}tx_db_t;


static tx_db_t tx_db;

 void Uart0_Init(void)
{
     uint32_t delay;
     SYSCTL_RCGC1_R |= SYSCTL_RCGC1_UART0;
     SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOA;
//     SYSCTL_RCGCUART_R |= SYSCTL_SCGC1_UART0;
     UART0_CTL_R &= ~UART_CTL_UARTEN;
     UART0_IBRD_R = 0x2B;
     UART0_FBRD_R = 0x1A;
     UART0_LCRH_R |= UART_LCRH_WLEN_8;
     UART0_LCRH_R &= ~UART_LCRH_FEN;
     UART0_LCRH_R &= ~UART_LCRH_STP2;
//     UART0_IFLS_R |= UART_IFLS_TX4_8;
     GPIO_PORTA_AFSEL_R |= 0x03;
     GPIO_PORTA_DEN_R |= 0x03;
     GPIO_PORTA_AMSEL_R &= 0xFC;
     GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R & 0xFFFFFF00) +  0x00000022;
     //     delay = SYSCTL_RCGC2_R;

     //    GPIO_PORTC_AHB_DIR_R = 0x20;
     UART0_CTL_R &= ~UART_CTL_RXE;
     UART0_IM_R &= ~UART_IM_RXIM;
  
     UART0_CTL_R &= ~UART_CTL_TXE;
     UART0_CTL_R |= UART_CTL_TXE;
     UART0_CTL_R |= UART_CTL_EOT;
//     UART0_CTL_R |= UART_CTL_UARTEN;
}


 void Uart0_Transmit(uint16_t *tx_buff, uint16_t buffsize)
 {

     tx_db.numofbytes = buffsize;
     tx_db.is_tx_over = false;
     tx_db.tx_buff_ptr = tx_buff;
     UART0_ICR_R |= UART_ICR_TXIC | UART_ICR_RXIC ;
     UART0_IM_R |= UART_IM_TXIM;

     UART0_DR_R = *tx_db.tx_buff_ptr;
     tx_db.tx_buff_ptr++;
     UART0_CTL_R |= UART_CTL_UARTEN;

 }


 void UART0_Handler(void)
 {
     if(((UART0_MIS_R & UART_MIS_TXMIS)>>5) == 1)
     {
         if(tx_db.numofbytes > 0)
         {
             UART0_DR_R = *tx_db.tx_buff_ptr;
             tx_db.numofbytes--;
             tx_db.tx_buff_ptr++;
         }
         if(tx_db.numofbytes == 1)
         {
             UART0_DR_R = *tx_db.tx_buff_ptr;
             tx_db.numofbytes--;
             UART0_CTL_R &= ~UART_CTL_TXE;
             UART0_IM_R &= ~UART_IM_TXIM;
             tx_db.is_tx_over = true;
         }
         UART0_ICR_R |= UART_ICR_TXIC;
     }


 }