Kinetis MKL24 randomly not starting when powered on

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

Kinetis MKL24 randomly not starting when powered on

761 Views
mroczeks
Contributor IV

Hi All,

I have a problem with Kinetis MKL24 based device.

It is powered with a single cell 3.0 V battery.

My software project is build with Processor Expert drivers, including MQX Lite OS driver.

I have a very simple single task that loops every 1 second and blinks some LED.

For some reason around 50% of cases when I insert battery into a socket my device does not start (no LED blinking).

I found that if I short-circuit GND with RESET pins on PCB's programming socket for a moment it starts do blink.

It also starts every time when started from under debugger.

Do you have any ideas what's the problem?

Labels (1)
0 Kudos
2 Replies

446 Views
mroczeks
Contributor IV

I managed to dig deeper into the problem.

I found out that when my application does not start it is because MCU is entering Low Power Wait mode.

I have not enabled any of power saving options available in ProcessorExpert yet but I see that it is executing "wfi" command (line 46):

ASM_PUBLIC_BEGIN(_sched_execute_scheduler_internal)

ASM_PUBLIC_FUNC(_sched_execute_scheduler_internal)

ASM_LABEL(_sched_execute_scheduler_internal)

#if MQX_ENABLE_USER_MODE

                cpsid i

                push {r0}

                mrs r0, IPSR

                cmp r0, #0xb

                pop {r0}

                bne _sched_execute_scheduler_internal2

                push {lr}

                //bl _set_pend_sv

                cpsie i

                pop {pc}

ASM_LABEL(_sched_execute_scheduler_internal2)

                cpsie i

#endif

                // store active task registers

                STORE_ALL_REGISTERS

                // disable interrupts

                cpsid i

                GET_KERNEL_DATA r0

                ldr r3, [r0, #KD_ACTIVE_PTR]        // get active task descriptor

                str r1, [r3, #TD_STACK_PTR]         // store task SP to task descriptor td

#if MQX_KERNEL_LOGGING

                KLOG r0, ASM_PREFIX(_klog_execute_scheduler_internal)  // kernel log this function

#endif

ASM_LABEL(sched_internal)

                ldr r1, [r0, #KD_CURRENT_READY_Q]   // get current ready q

ASM_LABEL(find_noempty_que)

                ldr r2, [r1, #0]                    // address of first td

                cmp r2, r1                          // ready_q structure itself?

                bne switch_task

                ldr r1, [r1, #RQ_NEXT_Q]            // try next queue

                movs r1, r1

                bne find_noempty_que

                // r1 is 0 -> empty

ASM_LABEL(no_one_to_run)

                // wait for interrupt

                cpsie i

                wfi

                cpsid i

                // TODO check r0, must be kernel data

                ldr r1, [r0, #KD_READY_Q_LIST]      // get first que from ready list

                b find_noempty_que

ASM_LABEL(switch_task)

                // update kernel structures

                str r1, [r0, #KD_CURRENT_READY_Q]   // store addr for active que

                str r2, [r0, #KD_ACTIVE_PTR]        // active task descriptor

                ldrh r3, [r2, #TD_TASK_SR]

                strh r3, [r0, #KD_ACTIVE_SR]        // restore priority mask for enabled interrupt for active task

Any ideas what and why is hapenning?

0 Kudos

446 Views
mroczeks
Contributor IV

Ok, found some more again :smileyhappy: ...

I have 32kHz generator connected to RTC_CLKIN pin.

I also have ProcessorExpert's RTC_LDD component added. Its clock source is set to ERCLK32K.

In CPU bean's option for RTC Clock input is enabled.

The problem appears when this RTC component has its interrupts options enabled (INT_RTC and INT_RTC_Seconds interrupts).

When these interrupts are disabled my MCU starts with no Low Power Wait.

0 Kudos