Everything you always wanted to know about Eclipse, Embedded Systems Programming, Software and Tools, or any topics of this blog, but where afraid to ask, then this page is for you.

Post a comment, and you might get an answer, either from myself or from the readers of this blog. Otherwise: the answer is always ‘42‘ 😉

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


748 thoughts on “Q&A

  1. Hi Erich,
    I need to implement a control loop to control pressure in a chamber. Also separate loop to just control the temperature of a heater.
    I thought that using your PID components would allow this, but I noticed the PID_integer wanted to add motor and quadrature stuff which isn’t needed.
    I tried the PID_float component, but I don’t really know how to use it, I could maybe make some good guesses, but is there an example somewhere? Or documentation?

    Many Thanks,


  2. Hi Erich,
    Another question – I have 5 I2C devices on one bus, and from time to time that bus can get locked up (SDA remains low). Is there a way to reset the bus to get it going again? I’ve had to power cycle my board sometimes to get rid of the lockup, other times just resetting the software works. Using the GI2C component wrapping the CI2C kenitis component (on my K22fn512 board)

    It was working really well for a while, when I noticed my SPI interrupt was not updating the SPI peripheral at 1000Hz. I fixed that, and now the I2C (which is much slower and I have seen the SPI transactions which share no pins come in the middle of the I2C transaction) is locking up much more often.


    • Hi Brynn,
      do you know who pulls the SDA low? If one of the devices does that, there is not much you can do about it.
      You can try to unlock it with a repeated sequence of data (see https://mcuoneclipse.com/2013/12/08/bit-banging-i2c-with-resetbus-functionality/), but I have this available only in the bit banging version of the driver.
      What I have done in the past to overcome such situations is to power down/up the I2C device(s) with a FET.


      • The earlier version of the board had FETs controlling the power of 3 of the 5 I2C devices (Because they all came at the same address), When any of those three were powered down they dragged both SDA and SCL low so I couldn’t use that to enable/disable them individually – so I removed the feature from the next board. Which is too bad because I cannot power cycle them with software anymore. Though it could well be one of the other two devices that are the culprits.



  3. Hi Erich
    I am trying to implement a USB CDC host on KL25Z and having lots of problems do it. I am trying to use MQX-Lite.

    case 1:
    I created a project, changed the clock, added consoleIO, and FSL_USB_CDC_Host. Generated the code and then compiled.
    I get errors in the generated code.

    case 2:
    Same as above except the I used the FSL_USB_Stack component and then selected a CDC host. When I compile it, I get errors in the MQXLITE directory.

    Any suggestions as to what is wrong.


    • Hi Eli,
      I have not used MQX (or MQXLite) for a very long time, so I cannot really help on that. I would use FreeRTOS instead. The FSL_USB_Stack is not compatible with MQX, and probably never will be.


  4. Hi Erich
    I am wondering if you have noticed this:
    I created an application where I added the following components:
    -FSL_USB_Stack – setup as a USB CDC device
    The only thing the application does is a printf to the console.
    This works fine.

    I than disabled the CDC device and enabled the CDC host.
    Now the printf does not work.

    I did notice that the CDC sub-component changed from CDC1 to CDC2.


  5. Hi Erich

    I am working with KDS 3.2.0 and the K64F board.
    Two items:
    1-When I add the RingBuffer component from the 2016-10-30 release everything is OK
    When I use the 2016-12-12 release there is a problem with CS1 component.
    Are you aware of this.
    2- I want to use UART1 to communicate with a RS232 printer. If I don’t use flow control I get some bad characters printed. When I enable flow control it does not work at all.
    Any suggestions.


  6. Hi Erich,
    On my I2C problems, I switched from the kinetis CI2C component to the genericSWI2C component and all My I2C problems went away. I don’t even have to use the ‘ResetBus’ function which was why I switched to the software solution in the first place!

    Today I just made a bunch of changes to my code, and now the KDS V3.2 is giving me phantom compile errors – the error message is telling me that there is an undefined reference to a variable that existed in a previous version of the code, but is no longer used and has been completely deleted. I double click on the error and it puts me on a line of code that is completely different than the error it claims. It is approximately where the old variable existed in the code.

    No amount of ‘clean’ or deleting the debug and generated code directories help.

    Any ideas how to fix this bug??



    • Hi Brynn,
      Well, my first thought would have been to do a ‘clean’ or delete the ‘debug’ folder. But as you already did this, not sure what else it could be. If it is a undefined reference, it means that the code is using that variable, but it is not defined somewhere. But what sometimes happens is that Eclipse ‘keeps’ the errors listed in the ‘Problems’ view. Check the console view output if the error report is real. You can delete/remove the errors from the ‘Problems’ view (context menu and delete them all or individually).
      I hope this helps,


      • Hi Erich,
        Apparently there were still instances of the not entirely deleted variables elsewhere in the file, and now that I deleted them it compiles again. (but it was still pointing to the wrong places when listed in the problem window).



  7. Hi Erich,
    New question – I am using the USB CDC as a debug port and am displaying lots of stuff.
    I changed my code over to using a text frame buffer that I update with values and colors, and then only send a big serial stream of the stuff that changed. (It uses ansi esc sequences to change the colors and position the cursor, and I have a ‘dirty’ bit in the frame buffer that gets set whenever I write new info to the frame buffer)

    It actually works real good – except two things – both having to do with the CLS shell component.
    The first I am sure I can fix so I won’t go into it…
    The second is that after I start typing a ‘command’ to the shell, the other tasks come nearly to a complete stop, and stay sloooow until I hit the ‘return’ to end the command.
    Any suggestions on how to best fix this?



    • Hi Brynn,
      I have not observed such a slow thing with the shell. Which terminal application are you using? What happens in the shell is that it checks if there are any incoming characters and appends it to a buffer. It uses a function to find out if there is anything available, then gets the character. Maybe something is wrong with this: with your changes it thinks that there is a character, but then when it tries to get it, it runs into a timeout?


      • I just started typing a command now and see that the other tasks have gone slow (like 50x slowdown) but not stopped.
        I hit the ‘pause’ to break where the code is now, and the call stack is:
        CDC1_RecvChar() …
        CDC1_StdIOReadChar() …

        CDC1_RecvChar() is
        while(Rx1_Get(Chr)!=ERR_OK) {}
        and that’s where it is spending 99% of the time

        Instead of that empty while loop I just tried adding a vTaskDelay(1); inside that loop, and it makes my code not slow perceptibly

        Except now that is in generated code and will get overwritten when PEX generates components.

        Did I fix this the right way?



      • Hi Brynn,
        interesting, I think I see now the problem you describe. Not sure why I have not observed this on my side. Indeed, it should not block that way. I have added timeouts and waiting for the sending, but not for receiving characters. Your fix is basically correct. I need to think this through, a better way would be not to block or to provide a flexible way dealing with this.
        My current thinking is that CDC1_StdIOReadChar() should call Rx1_Get() and not CDC1_RecvChar().


      • Instead of that empty while loop I just tried adding a vTaskDelay(1); inside that loop, and it makes my code not slow perceptibly

        Actually not true, it is slowed by a factor of 2 or 3, but that is way better than 50x



      • Hi Brynn,
        I looked closer at what you describe. And my finding is that it should not block like you describe? CLS1_ReadAndParseWithCommandTable() calls CLS1_ReadLine() which first calls io->keyPressed(). This calls CLS1_KeyPressed() which checks using USB1_GetCharsInRxBuf() if there are characters in the Rx buffer. If there are zero, it will not try to read from the Rx ring buffer.
        I don’t know what is happening on your end, as indeed it should not try to read if there is nothing in the buffer?
        That’s why I have not seen such a blocking issue on my side.
        I hope that makes sense, and I don’t know what I’m missing?


  8. Hi Erich,
    I also have the SeggerRTT component included, as I am using that to dump some logging data.
    I only want the shell responding to the USB commands.

    I do call
    (void)CLS1_ReadAndParseWithCommandTable(in_buffer, sizeof(in_buffer), &CDC1_stdio, CmdParserTable);

    with the CDC1_stdio struct ptr.



    • Hi Brynn,
      with (void)CLS1_ReadAndParseWithCommandTable(in_buffer, sizeof(in_buffer), &CDC1_stdio, CmdParserTable); it will use the USB CDC as input/output for the shell (UART) communication. You can have as many RTT channels on the side as you want.


      • Hi Erich,
        I’m still having problems with the CDC blocking. Again, everything is fine until I type the first character of a command. From then until I type a ‘return’, it loops on the code:
        CDC1_RecvChar() is
        while(Rx1_Get(Chr)!=ERR_OK) {}

        I tracked down that CLS1_KeyPressed() is a function that calls USB1_App_Task(…) which returns the number of chars that are in RX1 waiting to be read.

        This is driving me nuts, I think I need to write my own routine that gets my character input and then just calls CLS1_ParseWithCommandTable() to replace the ‘CLS1_ReadLine’ which is the root of what causes that while(Rx1_Get(Chr)!=ERR_OK) {} loop.

        Yes my ‘vTaskDelay’ that I added helps a bunch, but it is also in the generated code directory so it gets overwritten by PEX the next time I generate components – is there a way to change code that was generated by PEX and not have it get overwritten later?


  9. Hi Erich,
    A different dumb USB question – my code starts talking and sending screens to the USB as soon as the USB is plugged in. But it does that even before my terminal emulator is connected to the USB serial port.
    Is there a function that I can use to actually wait until there is a terminal emulator connection so I don’t send to a non-existent screen? This would also help out because right now my initial screen draws happen long before the terminal is hooked up, and I have to manually type a screen refresh command after it has been connected.

    I see a few likely function names (ApplicationStarted, TransactionsStarted) but I am not sure they or any other function will do what I want.



  10. Hello Erich,

    I have a bricked KL25Z Freedom Board which has the next versions:
    Board Name is: FRDM-KL25Z
    MicroBoot Kernel Version is: 1.01
    Bootloader Version is: 1.01
    Application Version is: 0.00

    I was watching your tutorial and trying to recover it.
    I know that you said it will not work on versions below V1.11: “only works if the bootloader of the board has been already updated to V111”. But i want to recover this little beast.

    Is there a way to recover this board?


    • First: it would make sense if you could post your question in that article (easier find for everyone else).
      About your problem: You will need a Windows 7 machine to update the bootloader first, see ‘Updating the bootloader’ in https://mcuoneclipse.com/2014/11/01/illustrated-step-by-step-instructions-updating-the-freescale-freedom-board-firmware/, there is no way around it. Check out the comments section for that article: Mark Butcher posted a hint (I was not able to try that one), but maybe with that one you can do it from a Windows 8.x machine too.
      Good luck!


      • Thank you Mr. Erich,

        I was able to fix my bricked board following your instructions.

        What i did: I just connected the board to a windows 7 PC and copied the last version of the SDA firmware for this board (MSD-DEBUG-FRDM-KL25Z_Pemicro_v118). After a reset, the board was up and running again.

        By the way, sorry about not commenting on the right post.


      • Hi Ivan,
        no worries about posting. In any case, I recommend that you update the bootloader too as outlined in the instructions, just in case. Having the new bootloader ensures that you can update the firmware from a Windows 8/10, Mac or Linux machine too.


  11. hi Eric, how do i toggle program flash protection on a mk22fn1m0vlh12

    i can see how to do it in PE or by using

    /* Flash configuration field */
    __attribute__ ((section (“.cfmconfig”))) const uint8_t _cfm[0x10] = {
    /* NV_BACKKEY3: KEY=0xFF */
    /* NV_BACKKEY2: KEY=0xFF */


    but how do i change the following field in my application:

    /* NV_FPROT3: PROT=0xFF */
    /* NV_FPROT2: PROT=0xFF */
    /* NV_FPROT1: PROT=0xFF */
    /* NV_FPROT0: PROT=0x7F */

    i tried
    NV_FPROT3 = 0xFF;
    NV_FPROT2 = 0xFF;
    NV_FPROT1 = 0xFF;
    NV_FPROT0 = 0x7F;

    but that causes hard fault. i can read from those however.

    thanks for help


  12. Hello, Erich!

    I have a sumo robot project in which I use two QTR-1RC digital sensors for detecting the border of the battle ring. I don’t know how to do the code for them. Can you please help me? I am using the FRDM-KL46z. Do I need a counter for using them?



  13. FRDM-KL24Z + IRDA

    Have you ever done any IRDA using the FlexIO of a KL2x processor.

    I have a FRDM-KL24Z board and can see a demo app for KSDK1.3.0 using a KL43Z.

    http://www.nxp.com/assets/documents/data/en/user-guides/KSDK13DEMOUG.pdf ( search for IRDA )

    I am unsuccessful getting the demo ported over to the FRDM board I have (24z), and have never done any FlexIO implementations yet.

    If you have had some experience in this or some suggestions, pointing me in the correct direction would be greatly appreciated.


  14. Hi Erich,
    I wrote my own character reading handler instead of calling CLS1_ReadandParseWithCommandTable. In it, I use the NON_Blocking function CDC1_GetChar() . Deep inside the CLS_R…. command above, it calls the blocking function CDC1_RecvChar(). This is what makes that command block. Now that I have my own nonblocking character handler, everything is great.



  15. Hi Erich,
    I am working a Virtual COM port with the USB port on MK20DX256, bare metal no RTOS.
    I have tried to use the USB CDC CLASS from PEx and USB stack from NXP. I have experienced the “not supported on selected processor” or the similar issue. I have tried KDS 3.2 and Eclipse V10.3. V10.6 with the PEx components from USB stack 4.1.1 , V4.03 and the FSL_USB_Stack from your website, but no luck at all. I also tried to port the example code from SDK 2.0 for MK20 but the debug is such a pain. I really hope that I can use the USB_CDC_CLASS with what ever version IDE from NXP. Any suggestions would be highly appreciated.

    Tony Wang


  16. Hi Erich,
    I have tried the 2nd link which is for KDS. After plug the USB onto computer with Windows 10, the computer installed the driver itself and the K20DX256VLL10 is shown as COM4. However, there is nothing shown on the terminal. The USB driver for this port is from Microsoft. I will take a further look tomorrow.
    If I plug the same USB at Windows XP or Vista, I will need to manually install the driver.Not sure what driver I should use.
    Thank you so much for the help. Also thanks for the new release of PEx component on March 12,2017. Without this new release, I don’t think I can make the progress so far.



  17. Hi Erich,
    Everything works well. I can get echoed text after send letter or string on the Virtual COM port.Thank you so much.


  18. Hello Erich,

    I am Rashed. I am presently struggling to get the camera (OV7670) work with OPen4X9I-C development board.

    I have been following the example code made by Mr. Jorge’s blog (http://embeddedprogrammer.blogspot.kr/2012/07/hacking-ov7670-camera-module-sccb-cheat.html)

    I have built and debugged the project on eclipse neon.2. But I am trapped in an infinite loop.

    The loop is ov7670 configuration. It is not able to read the camera. I changed and activated all the pheripherals, clock and arrangement. Checked them a lot of times.

    Can you please help me in this project? I am just trapped. I can also send you my project by email.

    Thank you so much for your time.



    • Hi Rashed,
      I don’t thinkn I have that camera around (I had a similar one), so hard to help you out here. What I suggest is to check the signal lines with a logic analyzer: do they make sense? Do you see the commands you send? Do you see the signals the camera is sending?


      • Hi again Erich,
        Yes. I did check all those signals. Firstly, after checking deeply the code for peripherals and clock settings, I used oscilloscope to check all the signals on the sensor. It worked well, all the signals show up as they have to.

        I checked them several times. They are working but the code gets into a loop (never ending) and just stays in it sending only unknown default values.

        I checked the signals from data output pins (D0~D7). They all show up nice signals.

        I checked the peripherals for GPIO initialization on a LED test (blinking an LED). It worked nicely.

        I really doubt if USART, DMA and DCMI are working. I am duly checking them again.

        Please let me know if any suggestions you feel I need to check or do.
        Thank you so much for your time.



  19. Hello erich,
    I’m finishing high school and as final project I have to design a HDK (harware development kit) I decided to base the frdm kl25, which uses a microcontroller MKL25Z128VLK4 (32 bits, ARM cortex M0), since it is open source, in The schematic of the board uses as a debugger the microcontroller PK20DX128VFM5, but this is not achieved. I would like to know all the k20 series of nxp is compatible with the board? Or in its defect why micro could replace it? I wait your answer.
    Thank you
    debugger: http://www.nxp.com/assets/documents/data/en/data-sheets/K20P32M50SF0.pdf
    micro: http://cache.freescale.com/files/32bit/doc/ref_manual/KL25P80M48SF0RM.pdf


    • Hi Bill,
      no, I’m not aware of any. But I know there were some at element14 for the FRDM-KL25Z. I planned to 3D print one for my FRDM-K64F boards too, but had not the time for this yet.


  20. I made a mistake and posted this in requests, but am unable to delete it, sorry.

    Erich or Anyone please.
    Can you give me a link to a starting point for using your PE system with the Kinetis SDK v2.2 please?

    I have to change from MQX to FreeRTOS and SDK v2.2 and wanted to use PE. I used PE a long time ago, v10 and before with CodeWarrior but was blocked because of missing BSP’s for parts I was using and so on. So we switched from PE because MQX was limited with PE.

    And now I find the SDK documentation very difficult to follow with no explanation of why a particular design is being done and just basically incorrect (function calls that do not exist, incorrect numbers of parameters and so on in the example code). So I wanted to go back to PE but I am not sure how to start. I have followed your work for sometime now and always appreciated your clear explanations. I noted that you at one point did not have a way to integrate PE with the SDK v2.2 and that FSL/NXP had stopped the integration with PE after SDK v1.3 but am hoping now that you have found a way through the maze, or I may have misunderstood your recent post. The end result is I am trying to start over again by not sure how to begin. Could you point me to a project that you have done that uses a USB FAT system and or an i2c driver please? There are a lot of projects and ways to fail, so i am looking for a starting point if possible. Thanks.



    • Hi Robert,
      see https://mcuoneclipse.com/2017/03/25/tutorial-using-eclipse-with-nxp-mcuxpresso-sdk-v2-and-processor-expert/.
      I have it working with most of the McuOnEclipse components, FreeRTOS plus peripherals like UART and GPIO. I2C (and SPI) are using GPIO only for now (bit banging). I do have now a basic timer component available too.
      In any case, it is possible to mix the PEx components with the SDK, so you have to use the SDK for now for things like hardware I2C (unless I find a lot of time doing that one too as component).
      There is an (experimental) project for the FRDM-KL27Z on GitHub (https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-KL27Z/FRDM-KL27Z_McuOnEclipseLib) which I’m currently using to have a 1-Wire communication implemented with the SDK and Processor Expert.

      USB and FAT are for sure on my ‘to-do’ list, but I have not portet that one yet. Too many things on my plate right now 😦


      • Hi Erich
        I got my project moved from FreeRTOS and sdk v2.2 to include PE using your instructions, they were excellent. The wait and LED components work correctly.

        I can see the CI2C1 component in the components library but can I assume that it will work? I can’t figure out how to set it up to get 100K baud rate so far. I did download your github examples and found one that had the i2c component.

        I don’t care if I use the code from the sdkv2.2, for the drivers, all I want is any drivers to work with FreeRTOS and PE. Is there a non sdk v2.2 system that can have a working USB FAT system and I2C? It seems that you have resolved all the build issues so I can’t see why the components would not work or am I missing something?

        I really dislike the sdk v2.2 in its’ present state. The comments for the i2c driver are totally wrong; some of the calls in the example list 2 parameters, but the real calls use one, there are missing functions that are critical and on and on. I think one guy wrote the documentation and someone else wrote the code without communicating. IMHO anyway. It is a hair pulling experience working with it right now.

        Thank you for responding, I know you are very busy.



    • Hi, I sorted it out… found your “Tutorial: Using Eclipse with NXP MCUXpresso SDK v2 and Processor Expert” and it gave all my answers. Thank you very much for the Tutorials


  21. Hi Erich

    Can you give me some direction on what software systems to use please?

    My priority is to use: FreeRTOS, PE with the Eclipse in Kinetis Design Studio. I have KDS V3.2 and it works. I have PE integrated following your tutorial and this works. I have a CAN driver from the SDK v2.2 that I got working under FreeRTOS and have moved this over to the PE + FreeRTOS + KDS v3.2 as per your tutorial and that all works. But what I need most of all are the Fat file system using the USB Stack, runnning under FreeRTOS and the PE components. I have tried the sdk v2.2 USB Stack with the File system in the example code and it is completely bizarre. I got the test program to load but it does nothing and there is no documentation to know how to run anything. Just a set of innumerable callbacks that does nothing with no explanation as to how to make the whole sorry mess work. I don’t see that as a viable long term supportable system.

    I would be willing to go backward and use v1.3 of the SDK if that is what it takes, to use PE and the above. I would also rewrite the CAN code and use PE components (gladly… I used to use them and they worked great… before MQX was stuck in the mix).

    My problem is I do not know what pieces I should change. Also not all the pieces seem to be there; NXP’s site says sds v1.3 is available for a download but when I try the download I get redirected to download sdk v2.2 which I have. If I find a link that does not re-direct, all I get is a pop-up png with the words “DOWNLOAD”: a bit rude and irritating. I found a link on GitHub for v1.3 built for the FRDM-KL27Z board (not posted by NXP but a contributor), but I use the MK20dx256 part. I am assuming I can change the core with PE.

    I am willing to downshift any of the software and re-install KDS Vn.xx if I could figure out what to do. As I said I want to use the PE components for I2C, FAT, FreeRTOS, CAN and so on.

    I know your system works, I have followed it for years. We could not change before now because of our dependency on MQX but that requirement is now gone. If you could give me any direction it would be very appreciated.

    Thanks again



  22. Hi

    After a bit more searching for a way to update my KDS v3.2 system to use SDK v1.3 in order to use the PE components, I think I need to find the update for Kinetis which is something like KSDK_1.3.0_Eclipse_Update.zip inorder to get KDS to recognize the sdk v1.3. I think I found a version of the sdk v1.3 on my system but can’t find the update plug-in.

    Can someone lead me to the plug-in on Github somewhere, or a link would be appreciated?




What do you think?

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

WordPress.com Logo

You are commenting using your WordPress.com 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