AnsweredAssumed Answered

MK02 UART Transfer Problem

Question asked by Jack Xu on Sep 15, 2016
Latest reply on Sep 20, 2016 by Jorge Antonio Alcala Vazquez

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;

         }

 

 

 

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

 

 

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

 

Thanks in advance!

 

-Jack

Outcomes