MK02 UART Transfer Problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MK02 UART Transfer Problem

574 Views
jackxu2016
Contributor II

Hi there,

 

I want to using uart sends character to the pc as following

 

 

       /***************************************************************************

        * Defines

        **************************************************************************/  

         #define    DEMO_UART   UART1

         #define    BOARD_DEBUG_UART_BAUDRATE   115200

       /***************************************************************************

        * Variables

        **************************************************************************/  

         uint8_t   txbuff[] = "Uart polling example\r\nBoard will send back received characters\r\n";

         uint8_t   rxbuff[20] = {0};

       /***************************************************************************

        * Code

        **************************************************************************/  

         int main(void){

            uint8_t   ch;

            uart_config_t   config;

            

            /* Init board hardware*/

            BOARD_InitPins();

            BOARD_BootClockRUN();

 

            /*

             * config.baudRate_Bps = 115200U;

             * config.parityMode = kUART_ParityDisabled;

             * config.stopBitCount = kUART_OneStopBit;

             * config.txFifoWatermark = 0;

             * config.rxFifoWatermark = 1;

            */

            UART_Init(DEMO_UART, &config, CLOCK_GetFreq(kCLOCK_CoreSysClk));

 

            UART_WriteBlocking(DEMO_UART, txbuff, sizeof(txbuff) - 1);

 

            while(1)

           {

               UART_ReadBlocking(DEMO_UART, &ch, 1);

               UART_WriteBlocking(DEMO_UART, &ch, 1);

            }

 

         }

 

         void BOARD_InitPins(void){

            CLOCK_EnableClock(kCLOCK_PortA);

            CLOCK_EnableClock(kCLOCK_PortB);

            CLOCK_EnableClock(kCLOCK_PortC);

            CLOCK_EnableClock(kCLOCK_PortD);

            CLOCK_EnableClock(kCLOCK_PortE);

 

            PORT_SetPinMux(PORTC, 3U, kPORT_MuxAlt3);

            PORT_SetPinMux(PORTC, 4U, kPORT_MuxAlt3);

         }

 

kCLOCK_CoreSysClk      @40MHz

kCLOCK_BusClk               @40MHz

FEE   mode

 

         void UART_GetDefaultConfig(uart_config_t *config)

         {

            assert(config);

 

            config -> baudRate_Bps = 115200U;

            config -> parityMode = kUART_ParityDisabled;

         #if defined(FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT

            config -> stopBitCount = kUART_OneStopBit;

         #endif

         #if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO

            config -> txFifoWatermark = 0;

            config -> rxFifoWatermark = 1;

         #endif

            config -> enableTx = false;

            config -> enableRx = false;

         }

 

163772_163772.pngpastedImage_14.png

163768_163768.pngpastedImage_13.png

163767_163767.pngpastedImage_12.png

 

 

but when using FRDM-K22F runs uart_polling_transfer.c but SYSTEM_CLOCK @40MHz, BUS_CLOCK @40MHz, also in FEE mode, it runs good.

163773_163773.pngpastedImage_15.png

163774_163774.pngpastedImage_16.png

 

 

How can i fix the problem, the mk02 also can output the right message?

 

Thanks in advance!

 

-Jack

0 Kudos
3 Replies

449 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Jack Xu

I see that you have the same question in the following thread: https://community.nxp.com/message/831401 , and they are already answering you, please continue with it.

Regards

Jorge Alcala

0 Kudos

449 Views
jackxu2016
Contributor II

Hi Jorge,

But do not fix the problem, also three days past, there is no response.

Regards

-Jack

0 Kudos

449 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Jack Xu

I saw in the other thread that they asked you for some information, you didn't tell them what value you have in your Baudrate. You put the code that calculate the baudrate, but the actually value depends in srcClock_Hz. So a way to completely  verify this value is if you debug your code to the point where it calculate the baudrate and write the UARTx_BDH and UARTx_BDL values.

Regards

Jorge Alcala

0 Kudos