AnsweredAssumed Answered

K70 UART2 with Hardware fifo not working.

Question asked by Aseem C on Sep 21, 2013
Latest reply on Sep 21, 2013 by jeremyzhou


Hi all,

 

I'm working on K70 microcontroller.

I've successfully implemented uart driver without hardware fifo. ( 8-E-1 38400 baud rate)

Receive in Interrupt mode and Transmit in Polling mode.

Now I want to use hardware fifo. However after enabling hardware fifo its not working, not going in ISR routine.

below is my code. Please correct me where I'm doing wrong

 

SIM->SCGC4 |= SIM_SCGC4_UART2_MASK;

SIM->SCGC5 |= SIM_SCGC5_PORTE_MASK; 

PORTE->PCR[17] = (3UL <<  8);     

PORTE->PCR[16] = (3UL <<  8);

UART2->C2 &= ~(UART_C2_TE_MASK | UART_C2_RE_MASK | UART_C2_RIE_MASK);

UART2->C1 = 0; /* We need all default settings, so entire register is cleared */

 

br = ((60000000)/(38400 * 16));

temp = UART2->BDH & ~(UART_BDH_SBR(0x1F));
UART2->BDH = temp |  UART_BDH_SBR(((br & 0x1F00) >> 8));
UART2->BDL = (unsigned char)(br & UART_BDL_SBR_MASK);

brfa = (((60000000*32)/(38400 * 16)) - (br * 32));
temp =UART2->C4 & ~(UART_C4_BRFA(0x1F));
UART2->C4 = temp |  UART_C4_BRFA(brfa);   
UART2->C1 |= (UART_C1_M_MASK | UART_C1_PE_MASK); /* Even parity */

 

UART2->S2 = 0x00;
UART2->C3 = 0x00;

/********************* added below code for hardware fifo ****************/

UART2->PFIFO |= 0x08;
UART2->CFIFO |= UART_CFIFO_RXFLUSH_MASK;
UART2->CFIFO &= ~UART_CFIFO_RXFLUSH_MASK;
/*********************************************************************************/

 


// UART2->RWFIFO = UART_RWFIFO_RXWATER(1); /* without fifo */

UART2->RWFIFO = UART_RWFIFO_RXWATER(2); /* with fifo */
UART2->TWFIFO = UART_TWFIFO_TXWATER(0);

 

NVIC_EnableIRQ(UART2_RX_TX_IRQn);

UART2->C2 |= (UART_C2_TE_MASK | UART_C2_RE_MASK| UART_C2_RIE_MASK) ;

 

Thanks in advance..

A

Outcomes