Wait Component don't work on MK20

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

Wait Component don't work on MK20

Jump to solution
1,050 Views
ViniciusHoff
Contributor II

I am using the LCDHTA custom component created (Processor Expert Component *.PEupd Files on GitHub | MCU on Eclipse), but it doesn't work properly. I saw that the problem is on Wait component,. The function WAIT1_Waitus()  does a small time rather than the requested.

The CPU Component (MK20DX128VLL7) haven't the Delay100US() method used by Wait component.

How could I fix that?

Tags (2)
0 Kudos
1 Solution
729 Views
BlackNight
NXP Employee
NXP Employee

Hi Vinicius,

indeed, I confirm the problem :-(.

The issue is about BUS vs . CORE clock speed. For the wait ns and us macros, it was using the BUS instead of (correctly) using the CORE clock speed. So as long you have the bus clock speed matching the core clock speed, you are fine. So if your core clock speed is three times the bus clock speed, the time waiting was three times too short.

I h ave fixed this on GitHub in case you are interested:

https://github.com/ErichStyger/McuOnEclipse_PEx/commit/96091726c9b600d611bf46db8c5ebfa0d35987cf

I have attached the fixed WAIT component to this post. I have not formally tested it, but using my FRDM-K20D50 board I'm able to get a 563us (for 500 us specified) waiting time at 48 MHz core clock speed and 24 MHz bus clock speed which matches the expectation, without any compiler optimization.

I appologize for the problem, and hope this helps you.

Best regards,

Erich

View solution in original post

0 Kudos
6 Replies
731 Views
BlackNight
NXP Employee
NXP Employee

Author of that Wait component talking here ;-)

Can you provide some more information what your problem is? Is it because the Waitus() is not waiting *exactly* the number of microseconds? Keep in mind that depending on the number of microseconds to wait, there is some +/- 10% skew, depending on interrupt load or call overhead.

Best regards,

Erich

731 Views
ViniciusHoff
Contributor II

Hi Erich

I am having problems with component in LCDHTA again.

I am using the MK20DX128VLL7 with a 10MHz crystal and the internal PLL set configured to 75Mhz.

I want set Core Clock to 75Mhz, but the Wait component doesn't work at this frequency.  A delay which should provide 500uS, was providing less that 60uS.

If I set Core Clock to 12Mhz, the Wait component works properly.

Why I can't set Core Clock to high frequencies?

0 Kudos
730 Views
BlackNight
NXP Employee
NXP Employee

Hi Vinicius,

indeed, I confirm the problem :-(.

The issue is about BUS vs . CORE clock speed. For the wait ns and us macros, it was using the BUS instead of (correctly) using the CORE clock speed. So as long you have the bus clock speed matching the core clock speed, you are fine. So if your core clock speed is three times the bus clock speed, the time waiting was three times too short.

I h ave fixed this on GitHub in case you are interested:

https://github.com/ErichStyger/McuOnEclipse_PEx/commit/96091726c9b600d611bf46db8c5ebfa0d35987cf

I have attached the fixed WAIT component to this post. I have not formally tested it, but using my FRDM-K20D50 board I'm able to get a 563us (for 500 us specified) waiting time at 48 MHz core clock speed and 24 MHz bus clock speed which matches the expectation, without any compiler optimization.

I appologize for the problem, and hope this helps you.

Best regards,

Erich

0 Kudos
731 Views
ViniciusHoff
Contributor II

Thank you very much Erich,

Now, It works fine.

0 Kudos
731 Views
ViniciusHoff
Contributor II

Hi Erich!

I figured out the problem. It was not with the Wait component. For some reason, the CPU component was not working properly. As a result, a delay which should provide 500uS, was providing less that 60uS.

I reloaded the CPU component and reconfigured them, so the delay of Wait component worked properly.

Thank you!

Vinícius Hoff

0 Kudos
731 Views
BlackNight
NXP Employee
NXP Employee

As a further suggestion: you can disable code generation (see Disable my Code Generation | MCU on Eclipse) and make your timing changes in the LCDHTA module too.

Erich