uart0 in mke06128vqh4

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

uart0 in mke06128vqh4

Jump to solution
552 Views
Iotelctronic
Contributor I

Hello friends, I have a board that I designed with the MKE06Z128VQH4 microcontroller, in which I am using several outputs and inputs. I am using one KBI input, 3 timers, and one counter, so there’s no problem there — I’ve already done the configurations and they work.

I am currently working on the UART0 serial port, where I connect a USB-TTL serial adapter to the PC to receive or send data. I haven’t been able to make it send or receive information using the SDK libraries. My configurations using MCUXpresso are as shown in the image:mk1.JPG

 

the pins:

Iotelctronic_0-1764071007390.png

the clock, i have a external crystal 12MHZ:

Iotelctronic_1-1764071084330.png

 

i can´t put the FEE option because the FLL have error, then i doing the configuration with FBELP.

In the UART0 i doing the configuration with interrupt receive and transmitt polling.

Iotelctronic_2-1764071328099.pngIotelctronic_3-1764071349888.png

 

the sdk installed is:

Iotelctronic_4-1764071419903.png

i have the example sdk:

Iotelctronic_5-1764071510120.png

 

With those examples I still can’t get UART0 to work. I need some guidance — I’ve been trying for several days to get UART0 working.


 

0 Kudos
Reply
1 Solution
402 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Iotelctronic 

 

1) Regarding the clock, please check whether your 12 MHz crystal is functioning properly, and verify the configuration.

2) The KE06 does not support DMA.

 

Thank you.

 

BR

Alice

View solution in original post

0 Kudos
Reply
6 Replies
502 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Iotelctronic 

Thanks for your question.

 

Please first test the UART demo. Does the UART demo work properly on your side?

Make sure the hardware connections are correct. Connect the proper TX and RX pins.

Measure the TX/RX signals.

 

BR

Alice

 

0 Kudos
Reply
477 Views
Iotelctronic
Contributor I

hi alice! I tested with the demo using polling and it doesn't work.

codigo main.c:

#include "pin_mux.h"
#include "board.h"
#include "fsl_uart.h"

/*******************************************************************************
 * Definitions
 ******************************************************************************/
/* UART instance and clock */
#define DEMO_UART          UART1
#define DEMO_UART_CLK_FREQ CLOCK_GetFreq(kCLOCK_BusClk)


/*******************************************************************************
 * Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/

uint8_t txbuff[]   = "Uart polling example\r\nBoard will send back received characters\r\n";
uint8_t rxbuff[20] = {0};

/*******************************************************************************
 * Code
 ******************************************************************************/
/*!
 * @brief Main function
 */
int main(void)
{
    uint8_t ch;
    uart_config_t config;

    BOARD_InitBootPins();
    BOARD_InitBootClocks();


      config.baudRate_Bps = 115200U;
      config.parityMode = kUART_ParityDisabled;
      config.stopBitCount = kUART_OneStopBit;
      //config.txFifoWatermark = 0;
      //config.rxFifoWatermark = 1;
      config.enableTx = false;
      config.enableRx = false;

   // UART_GetDefaultConfig(&config);
   // config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
   // config.enableTx     = true;
    //config.enableRx     = true;

    UART_Init(DEMO_UART, &config, DEMO_UART_CLK_FREQ);

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

    while (1)
    {
        UART_ReadBlocking(DEMO_UART, &ch, 1);
        UART_WriteBlocking(DEMO_UART, &ch, 1);
    }
}
Tags (1)
0 Kudos
Reply
464 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Iotelctronic 

Please use the demo as it is without any modifications.

I have tested it on my side and found no issues

BR

Alice

0 Kudos
Reply
444 Views
Iotelctronic
Contributor I

Hello, I found the problem. The SDK examples and other projects I used with registers were not working for me; they always sent incorrect data and wrong characters. I’m using an external 12 MHz crystal, and it seems that with that crystal you can’t generate an exact baud rate of 115200. However, I changed the configuration to 8 MHz without desoldering the 12 MHz crystal, and it works fine. My big question is: why does it work if I modify the configuration to 8 MHz but don’t change the 12 MHz crystal? The code I’m showing is the modification I made in .freq = 8000000U. Is there an explanation for this? I also wanted to ask if the MKE06Z128VQH4 microcontroller has DMA to use with UART?

/***********************************************************************************************************************
 * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
 * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
 **********************************************************************************************************************/
/*
 * How to setup clock using clock driver functions:
 *
 * 1. call CLOCK_SetSimSafeDivs() to set the system clock dividers in SIM to safe value.
 *
 * 2. If external oscillator is used Call CLOCK_SetXtal0Freq() to set XTAL0 frequency based on board settings and
 *    call CLOCK_InitOsc0() to init the OSC.
 *
 * 3. Call CLOCK_BootToXxxMode()/CLOCK_SetXxxMode() to set ICS run at the target mode.
 *
 * 4. If ICSIRCLK is needed, call CLOCK_SetInternalRefClkConfig() to enable the clock.
 *
 * 5. call CLOCK_SetSimConfig() to configure the divider in sim.
 */

/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
!!GlobalInfo
product: Clocks v7.0
processor: MKE06Z128xxx4
package_id: MKE06Z128VLK4
mcu_data: ksdk2_0
processor_version: 9.0.0
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */

#include "clock_config.h"

/*******************************************************************************
 * Definitions
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/
/* System clock frequency. */
extern uint32_t SystemCoreClock;

/*******************************************************************************
 ************************ BOARD_InitBootClocks function ************************
 ******************************************************************************/
void BOARD_InitBootClocks(void)
{
    BOARD_BootClockRUN();
}

/*******************************************************************************
 ********************** Configuration BOARD_BootClockRUN ***********************
 ******************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
!!Configuration
name: BOARD_BootClockRUN
called_from_default_init: true
outputs:
- {id: Bus_clock.outFreq, value: 20 MHz}
- {id: Core_clock.outFreq, value: 40 MHz}
- {id: Flash_clock.outFreq, value: 20 MHz}
- {id: ICSFF_clock.outFreq, value: 31.25 kHz}
- {id: ICSIR_clock.outFreq, value: 37.5 kHz}
- {id: LPO_clock.outFreq, value: 1 kHz}
- {id: OSCER_clock.outFreq, value: 8 MHz}
- {id: Plat_clock.outFreq, value: 40 MHz}
- {id: System_clock.outFreq, value: 40 MHz}
- {id: Timer_clock.outFreq, value: 20 MHz}
settings:
- {id: ICSMode, value: FEE}
- {id: ICS.BDIV.scale, value: '1', locked: true}
- {id: ICS.IREFS.sel, value: ICS.RDIV}
- {id: ICS.RDIV.scale, value: '256'}
- {id: ICS_C1_IRCLKEN_CFG, value: Enabled}
- {id: OSC_CR_OSCEN_CFG, value: Enabled}
- {id: OSC_CR_OSC_MODE_CFG, value: ModeOscLowPower}
- {id: OSC_CR_RANGE_CFG, value: High}
- {id: OSC_CR_RANGE_RDIV_CFG, value: High}
- {id: SIM.DIV2.scale, value: '2'}
- {id: SIM.DIV3.scale, value: '2', locked: true}
sources:
- {id: OSC.OSC.outFreq, value: 8 MHz, enabled: true}
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */

/*******************************************************************************
 * Variables for BOARD_BootClockRUN configuration
 ******************************************************************************/
const ics_config_t icsConfig_BOARD_BootClockRUN =
    {
        .icsMode = kICS_ModeFEE,                  /* FEE - FLL Engaged External */
        .irClkEnableMode = kICS_IrclkEnable,      /* ICSIRCLK enabled, ICSIRCLK disabled in STOP mode */
        .bDiv = 0x0U,                             /* Bus clock divider: divided by 1 */
        .rDiv = 0x3U,                             /* FLL external reference clock divider: divided by 256 */
    };
const sim_clock_config_t simConfig_BOARD_BootClockRUN =
    {
        .outDiv1 = 0x0U,                          /* DIV1 clock divider: divided by 1 */
        .outDiv2 = 0x1U,                          /* DIV2 clock divider: divided by 2 */
        .outDiv3 = 0x1U,                          /* DIV3 clock divider: divided by 2 */
        .busClkPrescaler = 0x0U,                  /* bus clock optional prescaler */
    };
const osc_config_t oscConfig_BOARD_BootClockRUN =
    {
        .freq = 8000000U,                         /* Oscillator frequency: 12000000Hz */
        .workMode = kOSC_ModeOscLowPower,         /* Oscillator low power */
        .enableMode = kOSC_Enable,                /* Enable external reference clock, disable external reference clock in STOP mode */
    };

/*******************************************************************************
 * Code for BOARD_BootClockRUN configuration
 ******************************************************************************/
void BOARD_BootClockRUN(void)
{
    /* Set the system clock dividers in SIM to safe value. */
    CLOCK_SetSimSafeDivs();
    /* Initializes OSC0 according to board configuration. */
    CLOCK_InitOsc0(&oscConfig_BOARD_BootClockRUN);
    CLOCK_SetXtal0Freq(oscConfig_BOARD_BootClockRUN.freq);
    /* Set ICS to FEE mode. */
    CLOCK_BootToFeeMode(icsConfig_BOARD_BootClockRUN.bDiv,
                        icsConfig_BOARD_BootClockRUN.rDiv);
    /* Configure the Internal Reference clock (ICSIRCLK). */
    CLOCK_SetInternalRefClkConfig(icsConfig_BOARD_BootClockRUN.irClkEnableMode);
    /* Set the clock configuration in SIM module. */
    CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
    /* Set SystemCoreClock variable. */
    SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
}
0 Kudos
Reply
403 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Iotelctronic 

 

1) Regarding the clock, please check whether your 12 MHz crystal is functioning properly, and verify the configuration.

2) The KE06 does not support DMA.

 

Thank you.

 

BR

Alice

0 Kudos
Reply
359 Views
Iotelctronic
Contributor I

thanks the problem of clock is the crystal solder is 8MHZ not 12MHZ

0 Kudos
Reply