Why SysTick_Handler works on FRDM-KL03Z but not on a custom KL03 board?

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

Why SysTick_Handler works on FRDM-KL03Z but not on a custom KL03 board?

3,137 Views
jerwey
Contributor I

I created a custom board based off the FRDM-KL03Z explorer board, but for some reason, my timer delays don't work on my new custom board. I have narrowed it down to SysTick_Handler never gets called on my custom board, but when I flash the same program to the FRDM board it works. I'm am pretty new to this so I feel like I am asking a stupid question, but from everything I can find, the SysTick is an internal system that would not be affected by my hardware. I only have I2C pins and SWD pins initialized/used on my custom board.

I am not sure what to share to allow others to help, but I am using MCUXpresso and LPC-Link 2 probe for debugging. I added an SWD socket to J7 on the FRDM-KL03Z board to use the LPC-Link 2 probe to debug the same way we designed our custom board to work.

Everything else in the firmware works as expected on both boards, except the SysTick timer.

Is there something external on the FRDM-KL03Z board that is affecting the SysTick timer that I missed implementing on our new board?

0 Kudos
13 Replies

2,532 Views
Lorac
Contributor III

I got the same issue on my k22 design. Nevertheless, I have found one think that can explain this situation. When I desire the code in mcu flash at the offset 0x0, It works fine, but as soon as I change this offset somewhere else ex: 0x20000, It was failed. It is related to the boot config info location, that seem fixed in the first boot access in its flash memory. Is this assumption make sense?

0 Kudos

2,940 Views
nxf58904
NXP Employee
NXP Employee

Hi,

Have you flashed the code to  another custom board ?  And if possible , check the PCB.

Jianyu: 

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,940 Views
nxf58904
NXP Employee
NXP Employee

Hi,

Have you update the code after config it ?  Have a try to debug , and watch if SYSTICK  work.

Jianyu: 

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,940 Views
jerwey
Contributor I

Yes, you can see in the above config tool screenshot that the generated code is up to date. I have debugged the code and the SysTick_Handler does not fire on my board but when I debug it on the FRDM board the SysTick_Handler does work. It doesn't make sense to me why they would be different. We did all our testing on the FRDM board and once we were happy with how it was performing we decided to make our own board. Everything works as expected on our own board EXCEPT the SysTick timer doesn't work so none of our program delays work. I can step through the program through the debugger and it works great, but I need the delays in order for it to work by itself.

0 Kudos

2,940 Views
nxf58904
NXP Employee
NXP Employee

Hi,

Thanks for Mark's reply . It will be ok to config microcontroller via the config tool  .

Jianyu: 

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,940 Views
jerwey
Contributor I

Thank you, Jianyu, for confirmation that I should be able to rely on Config Tool to set up my microcontroller.

Then I guess the next question is, is there something in the config tool I am setting up wrong? Here is a screenshot of my clock config page:
Screen Shot 2020-05-13 at 3.34.58 PM.png

So based on your and Mark's comments, because I have Core clock set to 48MHz from the HIRC then my SysTick timer should be using that clock because we confirmed SYSTICK_CSR (register at address 0xe000e010 in the Cortex M0+ core) bit 2 is set. That means my SysTick timer clock should be set correctly. Is there another reason why my SysTick timer might not work on my board but does on the FRDM board?

Here is the timer_kinetis code I imported from FRDM MKL02 board, because the MKL03 board didn't come with a timer. It works on the FRDM MKL03 board (!!) but not on my board.
Screen Shot 2020-05-13 at 3.41.27 PM.png

I have left all the parameters default from the freshly download MKL03Z32CAF4 SDK from online and use the Config tool to set my pins and clock. I feel like I am missing something obvious but I don't know enough to make changes on my own.

0 Kudos

2,940 Views
mjbcswitzerland
Specialist V

Hi

Load the attached binary to your FRDM_KL03Z ad then to your custom HW to see whether it runs only on one?

It prints out a message on the LPUART and responds to input (19'200 Baud) and flashes the green LED output.

It runs from 48MHZ HIRC and the timing is controlled by SYSTICK interrupt so if it also runs on your custom board it may help distinguish between a HW or SW problem.

Regards

Mark

[uTasker project developer for Kinetis and i.MX RT]

0 Kudos

2,940 Views
jerwey
Contributor I

Hi Mark,

Maybe you forgot or may this is my own rookie mistake, but is there a special place to find attached files in this forum, or should it be connected to your post? I don't see a file.

Thanks,

Jerry

0 Kudos

2,940 Views
mjbcswitzerland
Specialist V

Jerry

I believe that you need to be logged in to see attachments, however there may be a problem with the forum at the moment. I also couldn't see the attachment so I loaded it again and then I saw it twice, suggesting it was there but not visible.

In case of continued issues I have also put it here:

http://www.utasker.com/temp/uTaskerV1.4_FRDM_KL03_48M_Hello_WORLD.bin


Regards

Mark

[uTasker project developer for Kinetis and i.MX RT]

0 Kudos

2,940 Views
jerwey
Contributor I

As I investigate my situation further, the first thing that comes to mind is that the FRDM board has an external clock whereas my board does not. If for some reason the SysTick timer is using that external clock, then that might be why the timer works on the FRDM board but not on my custom board.

However, I built my project from a fresh new downloaded SDK for my KL03 processor with the online tool, and then I used the MCUXpresso Config Tool to set my pins and clocks. Then I added my programming logic. I assumed that disabling the External OSC and RTC in the MCUXpresso Config Tool would force everything to use the configured internal clocks. Maybe the default SDK for the KL03 processor is set to use the external OSC for the SysTick timer and I still have to change that somewhere? If this is the case, can someone advise me on where I might change this?

Am I not able to strictly use the MCUXpresso Config Tool to manage my pins and clocks? Do I have to make changes in other places to support my setup in Config Tool?

0 Kudos

2,940 Views
mjbcswitzerland
Specialist V

Hi

Check the setting of SYSTICK_CSR (register at address 0xe000e010 in the Cortex M0+ core and not in the Kinetis peripherals)
- bit 2 (0x04) controls whether the SYSTICK is clocked from the core clock or from an external reference clock.

If this is set it will always be clocked from the same clock as the Cortex M0+ core and so will be HW independent.

Regards

Mark

[uTasker project developer for Kinetis and i.MX RT]

0 Kudos

2,940 Views
jerwey
Contributor I

Hi Mark,

It looks like I misunderstood what you were saying. What I showed does confirm that the SysTick is using the same clock as the Cortex M0+ core. So next step is to find out how the Cortex M0+ core clock is set.

I attached the screenshots of how MCUXpresso Config Tool setup my clock:Screen Shot 2020-05-12 at 12.50.11 PM.png

Screen Shot 2020-05-12 at 12.56.16 PM.png

I told the config tool to disable the external clock and use the internal HIRC source. I assume that is what it is doing here. Is there something else I need to change?

0 Kudos

2,940 Views
jerwey
Contributor I

Thanks, Mark, for the reply.
I dug into the SysTick_Config that initiates the timer because it must reference a clock in it somewhere. I found that there is a value set called SysTick_CTRL_CLKSOURCE_Msk and when I followed it is just a single bit that is currently turned on at bit 2 of the address you mentioned (0xe000e010). I couldn't find any documentation on it from what the options where so I have not tried changing it yet. But based on your comment, I assume then that on (1) must refer to an external reference clock, and therefore if I turn it off (0) that should set that reference to the core clock. Is that correct?

I attached my screenshots of the SysTick_Config function:

Screen Shot 2020-05-12 at 12.35.09 PM.png

And the SysTick_CTRL_CLKSOURCE_Msk variable:

Screen Shot 2020-05-12 at 12.35.45 PM.png

Regards,

Jerry

0 Kudos