This page is for you! If you’d like more information about something I’ve posted about, or if there is a topic you think I should post about, please leave a comment and I’ll get right to it (as fast as my schedule permits it)!

I have started to list things in my bucket list (still ongoing).

For feature requests or bug reports on the McuOnEclipse project end Processor Expert components, you should use the GitHub issue tracking system:

719 thoughts on “Requests

  1. Erich,
    I recently discovered a bug in some PEx-generated code for USB. The bug is brought in by invoking your USB component but I believe the problem lies in the Freescale USB Stack V4.1.1 when run on a K40 processor.

    PEx generates two files: wdt_kinetis.c and wdt_kinetis.h, that implement Watchdog_Reset(). The instruction in that subroutine: (void)(WDOG_REFRESH = 0xA602, WDOG_REFRESH = 0xB480); can cause a reset if an interrupt occurs between the two writes to WDOG_REFRESH. This is exactly what you were talking about when you wrote about Critical Sections.

    Watchdog_Reset() is called from usb_dci_kinetis.c, which also appears to be a Freescale USB Stack file.

    Since this code comes from a Freescale driver that I cannot modify and the offending code is re-generated every time I run Processor Expert, what can I do to fix it?



    • Hi Greg,
      I don’t think that case is a problem, because during the call to Watchdog_Reset() the interrupts are already disabled. Watchdog_Reset() is called from the delay loop in USB_DCI_Assert_Resume() which gets called from USB_Class_Initiate_Resume() which does a DisableInterrupts-EnableInterrupts around it. So there should be no interrupts in this case. Let me know if I’m missing something?

      And you can affect the code generation. First you can disable code generation for a component (see Second you can directly change the code base used for the code generation, you only need to find out where the component sources are (see In my case the USB stack sources are in C:\ProgramData\Processor Expert\PEXDRV_PE5_3\Drivers\FSL_USB_Stack. So you could directly modify the sources there if you want.

      I hope this helps,


      • Erich,

        Your description of how wdt_kinetis is used is correct, except I still have a stylistic issue with it. For a Watchdog Reset function to be sitting alone as it is with no comments regarding interrupts, what is the guarantee that future modifications to the software won’t call it while interrupts are enabled?
        In my case, that’s exactly what I did. I saw it sitting there just waiting to be called, so I called it. Then I started getting unexpected resets…

        Thanks for pointing me to the source code those routines come from.



      • Hi Greg,
        Yes, I 100% agree with you. The Freescale engineers seems to have lumped toghther things for the USB stack that way, unfortunately. Well, there is a newer (better?) stack available in the Kinetis SDK V2.0, but I have not adopted that one because that legacy 4.1.1 stack works very well for what I need, and I did not had the bandwidth to learn that SDK v2.0 stack. Wrapping yet another EnterCritical()-ExitCritical() in the watchdog function could have a solution, but creating nested critical sections that way is not a a good thing neither. So I’m not sure what I should do, and the same time I don’t want to invest too much time into that stack. As for the watchdog, I have used my own routines outside of that one of the USB stack.


  2. Hello, Erich!
    I have a mini sumo project using the kl46z and four HC-SR04 for detecting enemies.
    I am having troubles with the lack of counters for both the echo pins (the timer units) and the motors.
    My question is if I can use more than TPM0, TPM1 and TPM2. I know they can have multiple channels, but I do not know how to use them



    • Hi Surdu,
      I would not use HC-SR04 for this task: it is simply not reliable and fast enough. You can use multiple timer channels, depending how you do the measurement. If you do the measurement one after each other, used dedicated pins for triggering the measurement and dedicated pins for the input capture signal.


What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s