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,
It seems your crystal oscillator doesn't work properly. Please observe if the oscillator is start-up and if the oscillator wave is stable. Please see chapter 25 in rm.
Regards,
Jing
Hi jing,
Is there any effect of crystal we are using? I am using ABS07 for my application which has frequency 32.768KHz.
Regards,
shrey
Hi,
32.768k crystal should be ok. I suggest you to use MCUXpresso Config Tools to create clock config file. You can see the clock path easily.
Regards,
Jing
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
Hi,
Please set as my picture. Remember you can click every thing on the diagram that you want to change.
Regards,
Jing
Hi Jing,
Thanks for your replay. The above settings worked for me but in FEI mode.
Regards,
shrey
Hi,
It seems the erternal 32.769k crystal does not work properly. Can you try other crystal model?
Regards,
Jing