AnsweredAssumed Answered

UART problem with KL26Z128

Question asked by Rafael Dalazen on Jul 9, 2015
Latest reply on Jul 9, 2015 by Earl Orlando Ramirez Sanchez

Hi,

 

 

I'm dealing with a UART problem, I can't transmit any data from UART1 (which share the same pin with OpenSDA on KL26Z128 board) to the serial port terminal. I must not use interrupt mode, only polling; and I'm testing the code forcing it to  transmit the character '5' (0x35 in ASCII), but without success. The UART_D buffer remains equal to 0x00 all the time. I thought that the problem could be the baud rate (115200 bps) , but  the UART_TX (PTC4) signal   is a normal UART signal.

 

The UART's code follows below:

 

void uart1_init (void){

 

     SIM_SCGC5 = SIM_SCGC5_PORTC_MASK;

     SIM_SCGC4 = SIM_SCGC4_UART1_MASK;

     SIM_SOPT5 |= SIM_SOPT5_UART1TXSRC(0);

  

     PORTC_PCR3 = PORT_PCR_MUX(0x3);

     PORTC_PCR4 = PORT_PCR_MUX(0x3);

  

     UART1_BDH = 0x00;

     UART1_BDL = 0x1A; /* SBR = 26 */

 

     UART1_C1 = 0x00;

     UART1_C3 = 0x00;

     UART1_C4 = 0x00;

     UART1_S2 = 0x00;

 

     UART1_C2 |= UART_C2_TE_MASK;

}

 

void uart1_send (int data){

 

     while(!(UART1_S1&UART_S1_TDRE_MASK) && !(UART1_S1&UART_S1_TC_MASK));

     UART1_D  = data;

 

}

 

int main (void){

 

     uart1_init();

 

while(1){

 

     uart1_send( 0x35 );

 

}

 

}

 

Is there any error on code?

 

Could someone give me a clue?

 

Thanks in advance,

 

Rafael

Outcomes