AnsweredAssumed Answered

Uart framing error TWR-k53n512 in code warrior v10.6

Question asked by community community123 on Jul 8, 2016
Latest reply on Jul 13, 2016 by Alice_Yang

I am trying to print a char 'a' via uart3 in Tower k53n512.But after configuring the setting and baud rate still i am getting a wrong output at console..i have attached the nxp given code and the error photo..

 

please take look the attached project

 

Real term shows a error:UART framing error with some junk people coming along with some delay..

 

<code>

int core_clk_khz;

int core_clk_mhz;

int periph_clk_khz;

 

void main (void)

{

    //MCU_Init();           // MCU Initialization Clock, WatchDog etc

    //turn_power_on();     // Turn ON, the device connected at Medical connector

    //Timer_Init();         // Periodic Timer interrupt initialization - 1ms

    //initopamp();        // OpAmps Initialization           

    //ADC_Init8b();        // ADC Initialization

   

    //int core_clk_khz= 50*1000;

        

    //long int periph_clk_khz = core_clk_khz / (((SIM_CLKDIV1 & SIM_CLKDIV1_OUTDIV2_MASK) >> 24)+ 1);

 

    //core_clk_mhz = pll_init(CORE_CLK_MHZ, REF_CLK);

   

    //SIM_SCGC4 |= SIM_SCGC4_UART1_MASK ;

   

    SIM_SCGC4 |=  SIM_SCGC4_UART3_MASK ;

   

                 SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK

                              | SIM_SCGC5_PORTB_MASK

                              | SIM_SCGC5_PORTC_MASK

                              | SIM_SCGC5_PORTD_MASK

                              | SIM_SCGC5_PORTE_MASK );

   

    core_clk_khz = 48*1000;                                    //core_clk_mhz * 1000;

   

    periph_clk_khz = core_clk_khz / (((SIM_CLKDIV1 & SIM_CLKDIV1_OUTDIV2_MASK) >> 24)+ 1);

   

   

    

    /* Enable the UART1_TXD function on PTC4 */

    //    PORTC_PCR4 = PORT_PCR_MUX(0x3); // UART is alt3 function for this pin

 

    /* Enable the UART1_RXD function on PTC3 */

        //PORTC_PCR3 = PORT_PCR_MUX(0x3); // UART is alt3 function for this pin

 

   

    

   

      /*Enable the UART3_TXD function on PTC17 */

  PORTC_PCR17 = PORT_PCR_MUX(0x3); // UART is alt3 function for this pin

 

/* Enable the UART3_RXD function on PTC16 */

  PORTC_PCR16 = PORT_PCR_MUX(0x3); // UART is alt3 function for this pin

      

       /*Enable the UART3_RXD function on PTB10*/    

    PORTB_PCR10 = PORT_PCR_MUX(0x3);

 

  /*Enable the UART3_TXD function on PTB11*/

        PORTB_PCR11=  PORT_PCR_MUX(0x3);

     

uart_init (UART3_BASE_PTR , periph_clk_khz , 115200 );

//uart_init (UART1_BASE_PTR , core_clk_khz , 115200 );

 

 

while(1)

{

     

uart_putchar(UART3_BASE_PTR ,'a');

//uart_putchar(UART1_BASE_PTR ,'a');

time_delay_ms(1000);

     

}   

}

Outcomes