Hi am using KL15Z128 in RUN mode. But I the code gets stuck in UARTEnableRxInterrupt (). Please see the code below:
//------------------------------------------------------------------------------------//
void main()
{
ClockConfigBootClockRUNMode();
//ClockConfigBootClockVLPRMode(); //it works
UARTInit(); // Initialize UART port
UARTEnableRxInterrupt (); // Enable Rx Interrupt
}
void UARTInit(void)
{
lpsci_config_t ltUARTConfig;
LPSCI_GetDefaultConfig(<UARTConfig);
ltUARTConfig.stopBitCount = 0;
ltUARTConfig.baudRate_Bps = 9600;
ltUARTConfig.parityMode = 3;
ltUARTConfig.enableRx = 1;
ltUARTConfig.enableTx = 1;
//Initialize UART Peripheral
Chip_UART_Init(<UARTConfig);
/* Enable interrupt in NVIC. */
EnableIRQ(UART0_IRQn);
}
//-----------------------------------------------------------------------------//
However the above code works well with VLPR Mode. Attached here the ClockConfig.c file for different configurations of RUN mode and VLPR mode.
Regards,
shreekant
Hi,
UART0_CLK has different clock source. In RUN mode, UART0 clock can be set up to 48M. In VLPR mode, UART0_CLK max is 4M. You may have to use different setting in these two mode.
Please refer to the example in SDK package\boards\frdmkl43z\demo_apps\power_mode_switch. It switch work mode while keep uart work.
Regard,
Jing
Hi Jing,
I had tried the same code(SDK package\boards\frdmkl43z\demo_apps\power_mode_switch) before, but the code is getting stuck at below function.
Please see red text where my code gets stuck
//--------------------------------------------------------------------------------------------
void CLOCK_InitOsc0(osc_config_t const *config)
{
uint8_t range = CLOCK_GetOscRangeFromFreq(config->freq);
OSC_SetCapLoad(OSC0, config->capLoad);
OSC_SetExtRefClkConfig(OSC0, &config->oscerConfig);
MCG->C2 = ((MCG->C2 & ~OSC_MODE_MASK) | MCG_C2_RANGE(range) | (uint8_t)config->workMode);
if ((kOSC_ModeExt != config->workMode) && (OSC0->CR & OSC_CR_ERCLKEN_MASK))
{
/* Wait for stable. */
while (!(MCG->S & MCG_S_OSCINIT0_MASK)) //Code stuck here.
{
}
}
}
//-------------------------------------------------------------------------------------------------
Regards,
Shrey
Hi jing,
I am using the same tool MCUXpresso Config Tools for clock configuration. The default clock configuration for MKL15Z128CAD4R shows UART0 clock is inactive as shown in the diagram.
Regards,
shrey