Q&A


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:

981 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,
    Brynn

    Like

  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.
    Brynn

    Like

    • 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.
      Erich

      Like

      • 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.

        Brynn

        Like

  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.
    Thanks
    Eli

    Like

    • 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.

      Like

  4. Hi Erich
    I am wondering if you have noticed this:
    I created an application where I added the following components:
    -WAIT
    -ConsolIO
    -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.

    Like

  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.

    Like

  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??

    Brynn

    Like

    • 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,
      Erich

      Like

      • 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).

        Thanks,
        Brynn

        Like

  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?

    Brynn

    Like

    • 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?
      Erich

      Like

      • 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:
        Rx1_Get()…
        CDC1_RecvChar() …
        CDC1_StdIOReadChar() …
        CLS1_ReadLine()…
        CLS1_ReadAndParseWithCommandTable()…

        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?

        Brynn

        Like

        • 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().

          Like

      • 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

        Brynn

        Like

        • 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?

          Like

  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.

    Brynn

    Like

    • 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.

      Like

      • 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?
        Brynn

        Like

  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.

    Brynn

    Like

  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?

    Like

    • 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!

      Like

      • 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.

        Like

        • 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.

          Like

  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 */
    0xFFU,
    /* NV_BACKKEY2: KEY=0xFF */

    etc

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

    /* NV_FPROT3: PROT=0xFF */
    0xFFU,
    /* NV_FPROT2: PROT=0xFF */
    0xFFU,
    /* NV_FPROT1: PROT=0xFF */
    0xFFU,
    /* 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
    dave

    Like

  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?

    Thanks.
    Alex

    Like

  13. FRDM-KL24Z + IRDA

    Erich,
    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.

    Like

  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.

    Brynn

    Like

  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

    Like

  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.

    Tony

    Like

  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.
    Tony

    Like

  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.

    Sincerely,
    Rashed.

    Like

    • 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?

      Like

      • 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.

        SIncerely,
        Rashed.

        Like

  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
    LINKS:
    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

    Like

    • 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.

      Like

  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.

    Robert

    Like

    • 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 😦

      Like

      • 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.

        Robert

        Like

    • 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

      Like

  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

    Robert

    Like

  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?

    Thanks

    Robert

    Like

  23. Hello Erich,
    I started developing a product with the Raspberry Pi Zero. But after some research it looks like the Pi Zero will never ship in wholesale quantities. So I now have to come up with a small microcontroller board or chip on which to base my product. Do you have any suggestions of something in the general price range and functionality of the Pi Zero that will be around for years to come?

    I just started looking into NXP products but there are a lot of options to sort through.

    Thank you.

    Like

    • I think I am going to go with the LPC1347. I ordered the dev board and will have to create my own board on which to mount the LPC1347.

      Like

      • The LPC1347 is an ARM Cortex-M3 and does not have a FPU to my knowledge. While this is a good device, I would pick a M4 with floating point unit instead. It all depends what the target application will be.

        Like

    • I just see that you picked the LPC1347. Keep in mind that this M3 is much less powerful than the device on the Pi Zero (less FLASH, less RAM, slower speed) and does not run Linux like the Pi Zero.
      If you are looking for a more ‘industrial’ kind of board, you might have a look at the BeagleBone: I know that these boards are used in larger quanties. But if it comes to ‘guarantees’, you might be better going down the route of using a board like the Toradex (see https://mcuoneclipse.com/2016/10/22/tutorial-first-steps-with-nxp-i-mx7-and-toradex-colibri-board/) or similar.
      The thing is that the Raspy is built with such large quantities, you get a lot for your money. But I heard (and believe) that the Pi Zero is sold at about half of the costs (so it must be a negative business). That’s probably why you cannot get it in quantities.

      Like

      • Thank you for the advice. I am already using the BBB and Raspberry Pi 3 on other projects. I just need roughly a dozen inputs and a dozen outputs for this project. The LPC1347 may even be overkill. The Pi Zero was definitely overkill but at $5 a board who cares?

        Like

  24. Hi Erich

    I uninstalled all my KDS and SDK software and followed the steps in your tutorial. It all installed correctly, I left the defaults in place. I manually set the system and user environment variables for (SDK v1.3 because the install did not set them) , KSDK_PATH, KSDK_LOC, to point to the install directory of the sdk v1.3 (C:\Freescale\KSDK_1.3.0).
    I did the eclipse update from the sdk v1.3 tool folder and it said it worked correctly.

    I Rebooted and still the SDK path is NONE for the PE or any other type of project. Even when I choose an v1.3 SDK project from the project wizard! If I choose a V2.x project it asks for a path to the sdk but I don’t have sdk 2.2 installed and don’t want it for the near future if I can use PE.

    Questions:
    1). Do you think that with any new install of KDS v3.2 instead of an upgrade from v3.0 NXP has disabled the ability to use the older v1.3 sdk? Maybe they killed PE for all new and future installs and are maybe trying to force everyone to use just SDK v2.2?
    2). Should I uninstall everything again and install KDS V3.0 and work from there? I have researched the web for a solution and followed every suggestion, but nothing seems to work.

    Thanks again

    Robert

    Like

    • Hi Robert,
      1). I can use KDS V3.2 with the SDK 1.3. In the wizard (File > New Kinetis SDK v1.x) I can manually select and browse fro an SDK (e.g. I have one in C:\nxp\KSDK\SDK_1.3_FRDM-K22F). So this is definitely still there. Make sure you have installed the SDK plugin e.g. from C:\nxp\KSDK\SDK_1.3_FRDM-K22F\tools\eclipse_update
      2) No, this is definitely not necessary. Make sure you have installed/updated the wizard (Help > Install new software, then point to http://freescale.com/lgfiles/updates/Eclipse/KDS).

      I hope this helps,
      Erich

      Like

  25. Hi
    Here is what I did and found:
    1). Installed KDS v3.0 with all the updates as per tutorial, installs had no error
    2), Tried to build a project against a processor core MK20DX256xVLL10 using both PE and just the SDK v1.3, In both instances the environment variables were manually defined by me, but the SDK selection was NONE
    3) Built a project by selecting a Tower board, and the SDK v1.3 was allowed to be selected, added PE and it built a project. I can see all the components.
    4) Retried KDS v3.2, selecting a processor only would not allow the SDK to be selected as per usual
    5) Selected the same board as above and the SDK could be selected, added PE and the project built without problems.

    Conclusion
    Only the board projects work with the file/new/SDK 1.x or Processor Expert. There is no support on my system for creating a project with just a processor. I will try your project generator tutorial and maybe that is a way around this issue.

    If there is a fix for this it might save others some time as well; it wasted a number of hours for me but I am grateful the IDE is usable now. Even if I have to manually re-adjust the code to get around all the extraneous defines for the Tower. I have have had to do this with MQX and the Tower/BSP systems and it was a bit of a mess.

    Robert

    Like

    • Hi Robert,
      maybe it is about the version of the ‘New Project Wizard for SDK V1.x’?
      Here is what I have:
      KSDK 1.2.0 Eclipse Update 1.0.1.b150603 com.freescale.processorexpert.ksdk-1.2.0.sp.feature.group Freescale Semiconductor, Inc.
      KSDK 1.3.0 Eclipse Update 1.0.0.b150914 com.freescale.processorexpert.kinetis-ksdk-1.3.0.sp.feature.group Freescale Semiconductor
      KSDK 1.3.0 KV5xF Eclipse Update 1.0.0.b160311 com.freescale.processorexpert.kinetis-220mhz-kv5xf.sp.feature.group Freescale Semiconductor, Inc.
      KSDK 1.3.0 MK26FN2M0xxx18 Eclipse Update 1.0.0.b151216 com.freescale.processorexpert.ksdk-MK26FN2M0xxx18.sp.feature.group Freescale Semiconductor, Inc.

      Like

      • Hi Erich

        I think I have a simple way around the problem. I think my software has all the latest plug-ins and that they are update as far as sdk v1.3 and KDS v3.2 is concerned.

        I have a new way of using the sdk generator, the sdk-clcp methodology. Or the sdk chicken little, cluck and peck system. Do not pick a tower board unless you have no intention of using your own hardware, rather pick any board until you find one that supports FreeRTOS and the SDK (they all do not… a message often comes up saying ‘FreeRTOS was not available at the time of this sdk’). Generate the project for that board, then go in and use Processor Expert to change the cpu to the one you want, adjust the components and clock and there it is, the sky is not falling… the sun comes out.

        What a mess. Dropping PE was the worst customer decision I have seen to date. I have worked a lot with sdk 2.2 and various IDE’s and much of the sdk 2.2 functionality like the fsl_clock.c system is a redaction of PE’s functionality, for example the web system/desktop system to configure the clocks. And it does not work! The final code generated has modes that do not work and the interface is very poorly documented. They took a working system from PE for the clock and replaced it with a state machine whose api is not even added to the generated code. That code will not even print hello world on the MK60 Tower system. All that was accomplished was to remove a visual working architecture and replace it with a fragmented set of api’s inadequately documented with no cohesive connectivity.

        Anyway I appreciate the work you have done and made public thank you. I hope you stick with the PE system for a long time. Nothing is to be gained going to just the sdk system; and we don’t know what else will be dropped or changed once the next merger goes through.

        Thanks for the help.

        Robert

        Like

        • Hi Robert,
          My students and myself have invested several man years into PE, so we try to continue and keep it alive as long as possible. But I see the challenge with new Eclipse versions coming out. I have PE working in Eclipse Neon, and the only issue is that a few icons are displayed in a wrong way. But what comes out in the next Eclipse version? It very likely means things might be worse. In reality, with PE not be maintained somewhow by NXP (or any other company) it won’t be usable for a longer time :-(.

          Like

  26. Does Processor Expert have anything for the NXP LPC1347? NXP has the SDK option but it does not cover the LPC1347. Is there anything else that you know of associated with MCUXpresso that is for the LPC1347?

    Thank you.

    Like

  27. Hi Erich

    Thank you for you comments and insights above.

    I have found another problem. PE is giving a warning that the USB clock is not set. I can see this problem addressed in older posts on this site. However to correct the problem, I have to switch to Expert Mode, which was the only mode I used when I spent extensive time with PE a few years ago. The problem is that there is no Expert mode on my installation of sdk 1.3, and KDS 3.2… etc. There only is Basic and Advanced. I have looked through the settings and it does not exist (not on the toolset header as well). I am thinking that as a prelude to terminating PE, the support team dropped this feature in-order to minimize the work for the last release. Speculation, but there have been a lot of compromises we have seen now, at the expense of the PE product. As you noted with the setup of the PLL/FLL there are bugs, but without the capability to configure the clocks this is a show stopper.

    So I guess this is the last try; which is to go back and install the set of tools you have listed above and down shift more of the code to see if a working IDE can be built. When I am done I will update here, what does and does not work.

    You may be able to upgrade to the newer toolset functions and sdk (1.2–>1.3), but given the postings I have done, it would be good to be aware of the fact that old installations may upgrade fine, but a new install that a student would do on their own computer would fail. These steps have been a time sink for me with no productivity and they could also be so for someone going directly to the last supported (? sort of) sdk v1.3 with the upgrades.

    Robert

    Like

    • Hi Robert,
      a while back, the Advanced and Expert modes have been combined into the Advanved mode. Which makes sense to me, as having three options does not provide any value to me, and I’m always in the mode which all the possible settings. I have not seen any issues or settings disappear in the advanced mode. About the warning of USB clock not set: this is usually a setting at the bottom of the CPU component settings.

      Like

  28. Hi Erich

    One last update, I have run out of ideas. I am wondering if NXP has modified something beyond redemption.

    1) removed and re-installed KDS v3.0.0 without any updates. No Expert option in PE
    2) installed KDS v2.0.0 without update, No Expert option in PE
    3) Thought some portion of Eclipse could be the problem, therefore created a new account and removed all the Eclipse folders in the system. Removed and re-installed KDS 3.0.0 and still no Expert option in PE. New account had admin priviledge
    4) Took a second totally different PC system, installed KDS v3.0.0, and sdk 1.2, and the sdk update. Still no Expert option in PE
    5) Added the PE v3.01 update to KDS v3.0.0, no Expert in PE

    During the installs I noticed that there are fetches to the Freescale/NXP servers. I am wondering if the code has been disabled on the servers. Some downloads that link to NXP to fetch older SDKs and PE components just pop-up a png that says “Download”. It appears that they took the lazy way of disabling the downloads by changing out the file zip for a png. The Freescale sites still load correctly.

    Is there something I missing that you can see, or can you advise any other way to get this to work?

    Thanks again

    Robert

    Like

  29. Hi Erich

    After much searching and trial and error I found this on the NXP site “In the CodeWarrior 10.6, this has been changed and the Advanced and Expert options are merged into one Advanced view mode so you will see there all available settings.” If this is true then there is no Expert mode, however, to set the USB clock speed… Expert mode is needed according to many other posts.

    The problem is how do I set the USB clock speed that was in Expert mode if Expert mode no longer exists.

    Erich,
    do you have expert mode on your KDS installation? If so is it because you have a component development license and that is required?

    Regards

    Rober

    Like

      • Erich and Robert,
        I checked on my system and in Codewarrior 10.6, PE in the Advanced mode shows the PLL/FLL selection under the System Oscillator part of the Clock settings for the MK40DN51ZVLL10 CPU. So it’s not broken everywhere, but I haven’t switched over to KDS yet, and probably won’t for a while now.
        Greg

        Like

        • Hi Greg,
          yes, the same for PEx 3.x in KDS/etc. The PLL/FLL selection is the same place. But the setting for how the clocks are routed to the USB block are at the end of the settings. That might be different for other supported processors.

          Like

  30. Hi Erich,
    (I was not able to post this in the appropriate thread for some reason.)

    I am trying to follow the instructions for the LPC800 board with an LPCXpresso 1347 V1 board (OM13045). I understand most of the code you have but I am getting an error in MCUXpresso saying that the compiler can’t find chip.h nor board.h. I have both of these files in my src directory and have done Refresh a number of times. I am at a loss as to what to try next. Do you have any suggestions?

    Thank you for your time.

    Like

  31. Hi Enrich (or who it may concern),

    I’m using CodeWarrior Development Studio with Processor Expert for my Freescale FRDM-KE02Z and I’m having some problems with SPI.
    For a small project, we’re using two development boards, a BeagleBone Black and a FRDM-KE02Z, where the BeagleBone is used for a linux web-interface and it should send 4 different numbers to the FRDM board in SPI.

    To simulate these 4 numbers, I used an example project of the Arduino IDE called DigitalPotControl, removed the address byte and send this to the FRDM board.
    The Arduino program should send SPI at 1 MHz, but measuring with an oscilloscope it is around 4 MHz, which shouldn’t be a problem for the FRDM board.

    For now, I would like to change 4 LED’s on the output pins B2, B3, B4 and B5 (which have been connected, one connection was missing) and would like to know if I do something wrong.

    I tried using the standard Slave mode components available (SPISlave_LDD and SynchroSlave) and implement the typical usage.
    the other Processor Expert components used are two GPIO_LDDs, a TimerUnit_LDD and the NMI is disabled in the processor because of the timer used.

    The SPISlave_LDD does not receive a block and goes into the infinite “while (!DataReceivedFlag) {};” loop since the DataRecievedFlag never goes to TRUE, this is apparent because the LEDs never turn on, even though the code should always turn on an LED.

    The SynchroSlave does receive a character, but it either shows a 0 or 0b00001010U.

    The Arduino is connected from pins 13 (CLK), 11 (MOSI), 10 (SS) and GND to PTE0 (CLK), PTE1 (MOSI), PTE3 (PCS) and GND.
    SPI0 is chosen on SS1.
    GPIO1 is connected to 1 field with pins PTB2, PTB3, PTB4 and PTB5.
    GPIO2 is connected to 2 fields with pins PTF2, PTF3, PTF6 and PTF7.

    If you could help me, that would be great, since I’ve been working on it for a few weeks now, and it shouldn’t be this complicated with Processor Expert.

    Kind Regards,
    Lex van de Wiel

    Like

    • Hi Lex,
      If DataReceivedFlag is not set, this means the interrupt is not triggered. Are you sure interrupts are enabled? I recommend you set a breakpoint in the interrupt service routine to see if the interrupt happens. Make sure the SPI component is using interrupts in the settings with some buffer sizes set. Check the processor interrupt flag (PRIMASK), it should be cleared. I’m not sure why you say NMI is disabled, because the NMI has nothing to do with a timer?
      I hope this helps,
      Erich

      Like

  32. Hi Erich,

    Sorry to bother you again but I don’t know where else to look.

    I am trying to access the GPIO registers for the LPC1347 LPCXpresso board V1. I have successfully run blinky on the board using MCUXpresso.

    But when I try to use the following I get “Syntax Error”.

    Chip_GPIO_Init((*)base_adr);
    Chip_GPIO_SetPinDIROutput((*)base_adr, 0, 7);
    Chip_GPIO_SetPinToggle((*)base_adr, 0, 7, 1);
    x = Chip_GPIO_GetPinState((*)base_adr, 0, 1);

    I am at a loss as to what to try next. Do you have any suggestions?

    Thank you very much for your time.

    Like

    • Hi Erich,

      I found out what I was doing wrong. I needed to put a “void” in front of the * in the statements.

      I don’t understand why that works but it does.

      Like

      • Well, this is basic C programming language. If you cast something, you have to cast it to a type. ‘*’ is not a type, it is a pointer. ‘void *’ is a pointer to anything. Technically void* works (as a wildcard), but is strictly speaking not correct: you should cast it to the pointer the API expects.
        I hope this helps,
        Erich

        Like

      • Thank you, Erich,

        Technically I’m not a programmer. I am a hacker, maker, inventor. My only interest in programming is to make something work for me.

        Nevertheless, thank you for the help.

        Like

  33. Hi Erich

    I am having a hard time getting the USB stack + PE + FatFS working on my custom board mk20dx256VLL10 using the github projects, so I thought a better way to go would be to get a board you recommended that worked out of the box. Then I would have a reference point for testing and understanding the system.

    Can you tell me which project is the most current and which board you would recommend that I buy please for USB stack + PE + FatFS? I do not know the FRDM boards that well. I have an older FRDM-25Z but I would rather buy a board that I did not have to patch anything for 5v and that worked with your most current software system. I saw a reference to the FRDM-27Z but as I say I need some advice please.

    I can see all these really great tools for PE and Perceptio but it is like looking on the other side of a bullet proof window, I know it all works but just not for me… hence the request to start from a known good reference point.

    Thanks

    Robert

    Like

    • Hi Robert,
      I’m travelling this week, so not sure how much I can help you. As for a board recommendation, I would recommend the FRDM-K64F: it is powerful, h as a SD card socket and I have FatFS/FreeRTOS/etc running on it. I have not used the FRDM-K64F in host mode (I think this is what you want?), but I could give it a try.

      Like

    • Hi Robert,
      thinking more about your request, and looking at your other questions, I see that you want to use the SDK v1.3. I have to say that I have not used the SDK v1.x for a while, and I don’t recommend using it. NXP has moved to the SDK v2.x and I doubt there will be any ongoing support for that SDK. What I can offer is an example project with Processor Expert for say the FRDM-K64F board with KDS, FreeRTOS and FatFS: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-K64F120M/FRDM-K64F_Demo
      As for host support, I have one here: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-K64F120M/FRDM-K64F_USB_MSD_Host/Sources

      On another note: as KDS will be in maintenance mode, I’m moving over to MCUXpresso IDE. I have it now updated so it has the same capabilities as KDS, so I can use it with Processor Expert too.
      Maybe you could describe what you need? It will be very unlikely that I find time for the SDK V1.x.

      Like

      • Hi Erich

        I would prefer to use is whatever code base you recommend. The reason I went from SDK v2.2 to V1.3 was I thought from our earlier conversations that your code base did not support PE and SDK 2.2 for your PE component library. I had worked through the integration you posted on PE and sdk v2.2 and did get PE and SDK 2.2 integrated and it worked for the simple components. But I need the USB Stack and MFS for a flash drive but I thought you had said that there was no immediate time to get these integrated.

        I therefore switched to SDK v1.3 and KDS v3.2 to try to get the i2c, usb stack and mfs to work with your components. (There are definite problems with the SDK v2.2 wrt the clock system which was another reason I went to sdk v1.3.) Also I saw that the many projects you had posted all use the SDK v1.2, (possibly I thought SDK v1.3). I have no reason to use the SDK v1.3 apart from getting PE to work.

        I have used mcuExpresso with the sdk v2.2 and parts of it work well but there are broken pieces in that as well. For example the PEE mode will not work on any hardware I used… I had to change that part of the code. Also the clock generator code created by the tool does not include the state machine which is critical to the ramp up of the clock and switching to the final state. I found that by debugging the code, not from the documentation.

        I have found the code base and documentation for the sdk v2.2 terrible. They took 50 lines of code for the clock circuit and turned it into 2000 lines of state machine code not counting the header files that contain macros of c code. The drivers are endless structures and call backs. In my estimation they have gone from a fast working embedded platform, to trying to be a generic software system across all the silicon they must support. They have seem to be trying to make the Cortex core a parallel to a multitasking windows system with soft vectors and so on. This may work well for minimizing engineering support by standardizing on a common software base, but it does not help the end user of a specific core on a Cortex M series that needs speed.

        I am willing to use anything you recommend, I have been trying unsuccessfully to find a path through this maze of discontinued products and broken toolsets from Freescale and NXP.

        What I need are a USB Stack, MFS(readable on a windows platform), i2c, uart driver and interrupt handlers for gpio. I tried the NXP sdk v2.2 USB stack and MFS and could get it to compile, but it did nothing… and there was no documentation on even how to do a simple function like open a file or write a stream to a record. As far as I can see, NXP farmed out the whole project offshore and did next to nothing for the documentation. They used doxygen to create the doc set using poor descriptions in the source code. So of like “you should use the functional mode when you want to do functions, because functions are functional in the function code”, but the comments in the doc set do not match the api calls… well enough said.

        Any direction you could suggest would be much appreciated.

        Thank you.

        Robert

        Like

        • Hi Robert,
          Thanks for your insights. To my knowledge, MFS is a MQX thing (which I never really adopted, and looks I was lucky with that decision). So what it sounds is that you need a USB MSD device class implementation, where you can plug in the board with the USB port, and it will show up as mass storage device you can use to read/write e.g. using a FAT file system.
          I have bits and pieces for this, but not pulled it together. When I’m back from travelling, I could look into this. But I would prefer something like using Processor Expert on the FRDM-K64F with KDS, making the SD card on the board accessible throught the MSD implementation? I would use FatFS for this (and not MFS). Does this sound right?

          Like

  34. Hi Erich,
    I am now switching from a K22FN512 to a K22FX512 so I can add the CAN bus. I have already noticed that the CAN_LDD kinetis PE bean doesn’t show up (because my project for now is K22FN512) unless I select ‘ALL’ instead of ‘applicable to project’.
    Anyway, my dumb question: after I switch over to the FX part will it (KDS 3.2 +segger J-link) let me download and debug both the new FX boards and my older boards that have the FN processor? Or will I need to jump through some hoops to be able to support both with the same code base? There is an IO pin that that I can read to let me know which board version I have (although I also have the CPUID that will tell me which CPU I have, if I look) so that I can have a check before trying to initialize the CAN bus module.
    Brynn

    Like

    • I have not checked the difference between the FN and FX part, but for sure there are some, so I don’t expect drivers to work on both devices ‘as is’. Downloading and debugging should not be a problem.
      If you use the UUID (see https://mcuoneclipse.com/2013/11/30/kinetis-unique-identification-register/) then this ID is unique for every device, so you need to keep a decision matrix to know which device you are.
      I’m doing this for many of my robot projects: based in the UUID I can know which board revision I’m using, so I do not need to waste a pin, and it is much more flexible.
      Check out the KinetisTools component which has functions using the UUID. If you want, I can point you to some code in which I use a table to find out what kind of board/device is used.
      Other than that, there is some familiy ID related information on the device. Not sure if it will tell you the difference between FX and FN, but it gives you information which familiy your are and the FLASH and RAM size information.

      Like

  35. Hi Erich

    I worked with MQX too long and am mixing up the technical terms. I made a mistake in using the term MFS, when what I meant was ‘any system that will support FAT32, running on a USB stack with FreeRTOS as the OS that can use a flash drive’.

    I am confused as to which pieces I should be trying to use. You mentioned that you are transitioning from PE & the SDK system to MCUXpresso, but I thought that all that happened with MCUXpresso is that it generated a file set that contained the source code and headers tailored to a specific processor. They added a partial icon based setup of the ports and clock circuit that generates the port & device init fcns but these files are often just partial extractions of PE code (and even some MQX functionality). As well the driver source is the current SDK which is version 2.2. The middleware pieces and drivers are all in the full sdk v2.2, at least this was my perception when I worked with MCUXpresso.

    What I originally wanted to achieve was, to use PE with the sdk v2.2 and your components, but because I thought there was no of sdk v2.2 with PE + FAT system + USB stack (apart from the FSL USB + FatFs that I could not get to work) I went down the path I described.

    Have you tried to use any processor with the fsl_clock.c from MCUXpresso in PEE mode (not with the internal clock but with an external crystal)? I tried three different K series, 20,40,60 and none of them would work in PEE mode using code from MCUXpresso. There is an error in the fsl_clock code. Also I cannot run up the clock to PEE mode with the code generated by MCUXpresso, it is missing the state machine sequence. It starts in PEE mode with errors in the code and won’t run. This and a lot of other problems caused me to try and get PE + a different USB Stack + FreeRTOS as a base. I thought if this system is so badly tested and the fundamentals are broken, what else doesn’t work? Then I found the i2c driver example code is dead wrong… right in the API doc set the parameters in the called didn’t line up, and that added further concern.

    The key management people for the major software product lines were all let go and the code development went to China as far as I can tell. There they used pieces of PE to assemble parts of the current SDK and generalized the system to cover multiple processor families; but they did not appear to test or validate the pieces as an integrated system. A very frustrating and time wasting experience to throw onto the customer IMHO. The customer base should not be used as a test lab resource.

    The components you have added for the FreeRTOS, PE file system seemed to be the only real path out of the wreckage that resulted from the NXP & FSL merger.

    Thanks for taking the time to respond, I know you are very busy.

    Robert

    Like

  36. Hi Erich,

    I am wondering if you have come across the Cypress PSoC (Programmable System on Chip) technology in microcontrollers? Cypress has combined a PLD in with its MCU on the same silicon. This means that you can define inputs, create a schematic with well over a hundred different types of logic blocks, then send the desired output to most any pin, and not use the MCU whatever.
    The MCU pins can be configured to most any function, unlike any other MCU I have worked with. This means that if you got your TX and RX pins crossed in your final PC board, fixing it is a matter or reprogramming the pins.
    Cypress has created what I think might be the next generation of IDE. Instead of programming registers in C code, you simply drop the logic block components into a schematic, wire it up as you like and then download it into the chip.

    If you want to check it out, I recommend the PSoC 4 Pioneer kit (CY8CKIT-042) for $25 US. But you can get away with something as cheap as $4 US (CY8Ckit-049-42xx). This second kit does not have debugging capability. It has a removable USB to serial bootloader. Snap that off and you have something that can be the heart of you new device.

    There are also lots of video lessons from Cypress on how to use these kits. (Perhaps watching two or three will help you get a better idea of what they are offering.)

    Cypress is the only company that has this PSoC technology. They are also, as I understand it, the world leader in cap sense technology. I think they may have invented it.

    I know you are too busy to change over to Cypress, but I thought I would at least update you on an interesting development in the MCU field.

    Like

    • Yes, I have come across, I’m aware and I’m using the Cypress PSoC. These are great devices, and I love the ability of using its internal programmable logic. With it, I can save board space as I can implement logic inside the chip which otherwise would need some external flip-flops or other circuit. And I like the Cypress tools, they are much like Processor Expert and really easy to use. And proablay you have seen Alan Hawse (https://iotexpert.com/, ) in the videos? Great person! I only had no time left to write more about the PSoC’s due lack of time 😦

      Like

  37. Hi Erich,
    We have a project where we are using the LPC4088 because we decided it was the cheapest color LCD solution. I had hoped that we would have been able to us the Processor Expert components with it. Apparently not. (we are using MCUxpresso for the IDE, and went through all the stuff to add PEX to it)
    So, I guess the question: is there a good way to use PEX with the LPC4088?

    For example one of the tasks is to read and write to an external SPI flash chip. I was thinking that I could make a bogus Kxx project and add PEX beans for the SPI flash, generate code, then port that back into the LPC4088 project. Do you think that would work? Can you think of an easier=better way?

    Brynn

    Like

    • I have used that approach with dummy projects as well, that works well. But keep in mind that you cannot use any standard PEx components for the hardware (like SPI), as they depend on the CPU component.
      For a dummy project, that CPU component won’t match. You can use my generic components, but again you have to add the low level hardware layers to your LPc4088

      Like

  38. Hello Erich,
    I am developing a project that will later run on a K02 processor but, because the hardware is not ready yet, I started implementing it on the FRDM-K64 using MCUXpresso with the MCUXpresso FRDM-K64 SDK. I have not used any configuretion tools, but relied on bits from the supplied SDK examples and also adapted some code that I found on the web.

    My question is what is the best way to go about porting my code to the K02 ?

    I am aware that there will be some issues concerning clocks and pinmux, and of course the project will also have to use the header file for the K02 device instead of the K64.
    Also, there are some board definitions that will have to be redefined to fit the new hardware.

    Like

    • Hi Jesper,
      I would focus on the application code first which should be pretty much independent of the underlying hardware. Then once your K02 is ready, create a new project with the SDK for the K02 and SDK, and move over your application code. Don’t port the SDK, keep things on the application level.
      I hope this helps,
      Erich

      Like

  39. Hi Erich,

    – I’m new to the embedded system world. I used to program web applications project at the moment using javascript also i used in the past programming with ATMEL AT89C51 8-bit microcontroller.
    I started back with nxp k22f board but i saw a huge difference from what i was doing in the past now a day it is kind of framework that provide you almost every thing but if you get an error you have to dig deep which goes into the functions that generated by the processor expert (i use kinetis design studio).
    My question is what is the best book or learning curve to start with a good basics understanding the the modules and how to search inside the tones of PDF in order to figure what i want and how to do it using framework or without it??
    I spent many days trying to figure from where to start my journey of learning.
    You can say that i am lost.
    Any advice please ?!

    Like

    • Hi Ahmed,
      welcome to an exciting world!
      Best advice I can give you is that you sign up for my courses at the university, because this is what I’m teaching there. My view is that learning style is very different, and these days only a few seem to be effective learning with books, so you might have a different style. The thing is that books are usually out of date very fast. What you could do is to use google and search my blog articles for information. You probably have seen my ‘books’ section (https://mcuoneclipse.com/books/). There is good (but a bit outdated) material on the ARM university site (https://www.arm.com/research-education/university).
      I hope this helps as a starter,
      Erich

      Like

  40. Hello Erich,

    I went thro’ your articles on using Freedom boards to debug other
    custom kinetis boards and thought that you are the right person to addrees
    our querry.

    We are interested in knowing the following perticular combination.

    1. We are onto building a custom motor control hardware around MKV46F256VLL16
    For this we have based our hardware on HVP-KV46F150M schematic.
    Obviously we want to include the same debug support as provided in HVP- board.

    2. Since Freedom board FRDM-KV31F is easily available and is also nearest cpu & cheaper,
    we would like to use this board for debugging support.

    Our doubt is, Will OpenSDA sw meant for debugging KV31 cpu mounted here, will allow
    flashing/debugging of KV46 of Target Board.

    3. We do the following steps to isolate the resident KV31’s debug & uart signals.

    i) As explained in your posts, cutting J11 link to isolate resident KV3x SWD_CLK is
    quite clear.

    In this case, it seems, we need to also jump J8 & J12 (on sheet 4 of 5 of
    FRDM-KV31F schematic) to reach SWD-DIO & SWD-CLK signals properly.

    Likewise, for TRACE_SWO signal, lift R80 to isolate the resident KV3x.
    This signal, anyway, is not routed to OpenSDA interface.

    ii) Is it correct, that, for Virtual Serial Port implementation, we will also need to
    route the UART signals viz. UART0_RX_TGTMCU and UART0_TX_TGTMCU
    (on Sheet 4 of 5 of FRDM-KV31F schematic) i.e we need to also isolate
    the UART connection of the resident KV3x.

    This can be done by lifting R24 and R38 and putting jumpers at appropriate places.

    It would be helpful if you can give your comments on above.

    Thank you very much for your time.

    Best Regards,

    Vijay Vaidya
    http://www.tritek.in

    Like

  41. Hello Erich,

    I have a question about NMI. I need to disable NMI input pin and use it as GPIO input. I found and used many solutions for KDS and PE, but not for IAR and SDK 2.2. I have an application using KL17Z64. Because I had a problem with start of the program when the NMI pin was low, I disabled NMI pin in startup by rewriting the value of the register FTFA_FOPT -> NMI_DIS = 0. The NMI_DIS bit is properly written to 0 in debug mode but program gets stuck in the same way like in the case the NMI is enabled.

    Debug log shows:
    The stack pointer for stack ‘CSTACK’ (currently 0x20000508) is outside the stack range (0x20002C00 to 0x20003000)

    Call stack contains: PendSV_Handler + 0x1bffd7fd

    The program doesn’t get stuck immediately but after first interrupt handler call, commonly handler for systick.

    Do you know where the problem can be? What is PendSV_Handler?

    Like

      • Thank you for your reply. I also thought about it. Anyway, if the GPIO PTA14 is pulled up the application is running properly otherwise it gets stuck even when the NMI is disabled. I have never got this issue when using KDS + PE with KL16.

        Like

        • You need that hardware pull up, because it takes some time until you are able to disable the NMI in your software. And if during that time your NMI pin is floating and low, you will get an NMI interrupt?

          Like

      • The NMI input is disabled in register FTFA_FOPT and in the Init is set as a GPIO input connected to the switch. According to the switch state, this input is can be in a low or a high state. If it is in the low state and MCU is booting it will get stuck never reaching NMI interrupt handler.

        Like

      • When the application is already running the GPIO input works fine. In other words, if the state of the pin is hight during init and during running is pulled down.

        Like

  42. Hi,

    Thanks for your great resource for mcu’s and eclipse and especially k64f posts. I’m trying to take one of the example projects come with mcuespresso and the sdk and make it work with some C++ code I have from an older project but am really struggling to get code to build and link when I start adding C++.

    A clean project created by mcuespresso compiles fine as does say the httpd sample project but when I try and combine these it seems that many of the sdk headers do not have this in them to make it play nicely between C/C++, this is my modification to make one file (sys_arch.c) work

    #ifndef __ARCH_SYS_ARCH_H__
    #define __ARCH_SYS_ARCH_H__

    #if defined(__cplusplus)
    extern “C” {
    #endif

    … loads of header  …

    #if defined(__cplusplus)
    }
    #endif

    #endif /* __ARCH_SYS_ARCH_H__ */

    I also have to drag the sys_arch.c file into the source directory to get it to compile and link, so I assume the other folders in a project do not get compiled which seems unusual.

    I guess I’m missing something obvious because I’ve not been looking at the combination of tools before but not finding much help online and nearly every search I do relating to K64F ends up on your site!

    David

    Like

    • Hi David,
      my experience with mixing C and C++ as in your case won’t work without massive changes in the source base, mainly because things have not been implemented in a consistent way, running into all kind of include order hell.
      I recommend that you use that sys_arch.h only from C code, and not from any C++ code (if that’s feasable at all?). The other point is to verify if you are running in C++ mode or in C (see https://mcuoneclipse.com/2013/03/23/compiling-c-files-with-gnu-arm-g/ for yet another possible trap).
      I hope this helps,
      Erich

      Like

      • So my other thought which I Was trying to avoid 🙂 was to just rename all .c files to cpp so it all gets compiled for c++ but was worried I would then end up missing some core module what was not supplied in Source form.

        Given the C++ sample app created by the mcuespresso tool compiles and runs it feels like it might have a chance of success but I suspect there will be a gotcha in there somewhere.

        David

        Like

  43. The other issue thats throwing me off is how to get modules added to a project, I added the lwip code from a working “C” propect by dragging and dropping the files from the work directory structure it into the project and choosing copy so I got duplicate files but it seems that its not compiling that code unless I then drag individual .c files in the source folder which sounds wrong to me.

    David

    Like

  44. Is it possible to print “Modification Date\Time” during “File Save” step? Something similar to the templates, but I would like to see that “variable” will be changed his value each time during “File Save” procedure.

    Like

  45. Hello Erich, my regards…

    I tested Utility PE component in a project with debugger mode. I encountered a problem with result of the map() function…in one moment (range) the return it is negative value. I not know… I solved changing the variables “int32_t” for “uint32_t”, because in “PE_Types.h” int32 type is equal to “signed long int”. So, 0-65535 (min-max) range to 0-x? (min-max), in one determined interval, the result negative.

    See if this information is util for you.
    Thanks.

    Like

  46. Hi Erich! great work on his blog ! I’ll use some of your code inside my project ! Quick question about the freeRTOS PE component. I seem to get lost with the priority scheme of freeRTOS, interrupt and your implementation of the freeRTOS component.

    I want to be sure of one thing : IDLE task is assigned priotity 0, I guess it’S the lowest priority, the priority we give in FRTOS1_xTaskCreate() (PE component) should be related to priority number of the free RTOS right ? not the priority of the interrupt.. which are inverted right ?

    lets says i create 2 tasks with your component :
    FRTOS1_xTaskCreate(tsk1, “Task1”, configMINIMAL_STACK_SIZE, &globalhost, 1, NULL);
    FRTOS1_xTaskCreate(tsk2, “Task2”, configMINIMAL_STACK_SIZE, &globalhost, 2, NULL);

    Task2 priority will be greater than Task1 ?

    sincerely.

    Like

    • Hi Etienne,
      the FreeRTOS component is using the normal FreeRTOS priority scheme (nothing different). If you are new to FreeRTOS and the ARM Cortex interrupts, then I recommend that you have a read at the multipart tutorial starting at https://mcuoneclipse.com/2016/08/14/arm-cortex-m-interrupts-and-freertos-part-1/.
      Keep in mind that FreeRTOS priorities start with zero as the lowest priority, while the ARM Cortex priorities have zero as the highest urgency level.
      So yes, 0 (or tskIDLE_PRIORITY) is the FreeRTOS priority for the IDLE task. The RTOS itself runs with its interrupts (SysTick, PendSV and PendSvReq) at the lowest interrupt priority (15 for 4 priority bits).
      And yes, for your example, the Task2 his higher urgency than Task1 and this one has higher urgency than the IDLE task.
      I hope this helps,
      Erich

      Like

  47. Hello, Erich! I really ensjoy your blog!

    I have a question about mbed, especially openSDA.
    I build a board based on FRDM-KL43Z.
    My trouble is my boards are doesn’t work in my PC. I think absent of bootloader is main problem. Can you teach me how install a new bootloader in a board? There is none-S/W in my board.

    Here is my board symptom.
    1. Power LED is working
    2. MCU USB port ack as USB serial. But it cannot use as storage.
    3. openSDA USB unack.

    sincerely,
    Soo-Chang

    Like

  48. Hi…in my case my boards are doesn’t work in my PC. I think absent of bootloader is main problem. Can you teach me how install a new bootloader in a board? There is none-S/W in my board.

    Like

  49. Hi Erich,
    I just noticed that NXP has a Low Voltage Hbridge PE component (LVHBridge) , and also a medium voltage Hbridge (MVHBridge) component that can be downloaded and work on processors like the K20’s with Processor Expert. Have you seen these before and do you have any experience with them?
    I found it because I want to make a stepper motor driver (microstepping) using discrete components on the theory that it could be better/cheaper than using a microstepping chip- these components look like the easy way to do so.

    Brynn

    Like

  50. Hi Erich,
    I am working on a project where I send short text messages between a K64F and an android tablet. I want the K64F to be a host and the tablet to be a device. How do I do this. Do I need an OTG cable.

    Like

  51. Hi Erich
    I am trying to modify your example using the Adafruit SPI friend. I want to use the Freedom K64F instead of the Tiny20.

    For the Adafruit SPI you use 5 IO lines. I want to use the Adafruit UART friend, no interrupt and the CS tied to GND. This will use up only 2 IO lines.

    Will this work?

    Thanks
    Eli

    Like

  52. Hi Erich,
    Great website ! I found the site not too long ago ! You seem like a person who loves these works and want to teach others as well!
    I have been struggling to learn embedded electronics but what I have discovered missing is a complete guideline from beginner to expert. If you could write an article on where to start and how to grow from there would benefit many beginners like me I believe.

    Thanks
    Mark

    Like

  53. Hi Erich,
    So I was trying to do the DIY USB joystick but I keep getting this error: “Description Resource Path Location Type
    Generator: FAILURE: at line 10: Property not found: “TxBuffer” (file: Drivers\Common\FSL_USB_HID_Joystick_DeviceSettings.Inc) FRDM-KL25Z_USB_HID_Joystick HIDJ1 Processor Expert Problem”
    Can you help me please?

    Like

  54. Hi again
    I have an android tablet talking to a K64F using the Adafruit LE uart. However it will not send more that 20 bytes at a time.Is there a way to increase this limit.
    Thanks

    Like

    • You have to implement message fragmentation (sending larger chunk of data with multiple messages). The BLE protocol is optimized for low power and small amount of data, you cannot send more than this 20 bytes in a a single message.

      Like

  55. Hi Eric,
    Great work. Really appreciate your insights. Had a question. Is it possible to shutdown a cortex m4? I understand the CPU can be configured to go in Stop Mode or Sleep Mode, but is it possible to to initiate a shutdown from software? I don’t think it is possible as I cannot find any register set that lets me perform such an action, but wanted to run it by you as well
    Thanks again

    Like

  56. Hello Erich,
    First of all I would like to thank you for the awesome work and for the effort you have put into these tutorials. I have the following question. I ordered the product FRDM-K64F-AGM01, which consists of a shield and a development board. From the pictures at NXP site, I infered that the sensor shield board would be removable and that I could use the FRDM-K64F standalone. The problem is I can’t remove the shield (if I apply more pressure, I am scared that I will break the board). Do you know if it is supposed to not be removed?

    Thanks in advance,
    Panagiotis

    Like

    • It should be removable. I don’t have that kit, but from the pictures it really should be removable. You should be able to tell this with having a close look at the headers: ther must be a black (high) black row of female headers on the FRDM-K64F board, with a row of male pin headers on the AGM01 board. Try to lift the board carefully on one end, then on the ohter, and so on.
      I hope this helps,
      Erich

      Like

  57. Hello Erich ,
    I have to configure a common SPI bus to be used for two different SP clock frequency 2MHz and 8MHz on K10 series controller. I am using SPIMaster_LDD component in processor expert V10.4.0T.The method SetClockConfiguration() is appear as disabled . How can I enabled it and select the generate code option. Please explain .

    Thanks and Regards,
    Rohit K.

    Like

      • Hi Erich,

        In the clock rate configuration of the component i have used ‘list of values’.
        In value type , I am using mode 0 and mode 1.

        I am setting following the values : mode 0 = 0.125µsec and mode 1= 0.5µsec.

        When I reopen the clock rate configuration window , I observed that mode 1 value that I was set is not there. Mode 1 shows the same value as mode 0.
        Can you please let me know why this is happening?

        Thanks and Regards,
        Rohit K.

        Like

        • Hi Rohit,
          not sure what is causing this. I assume you have pressed the OK button? The other thing is: have you picked the values from the ‘Possible settings’ list (e.g. double-clicking on the value)? If the value you have entered is not part of that list, it will not be applied.
          I hope this helps,
          Erich

          Like

  58. Hello, Erich,
    im thinking about trying to do a firmware update over the air with delta file optimization. Do you something about that? An elipse configuration which does not change all the file over the smallest change in code, maybe?
    Regards,
    Morais D.

    Like

  59. Hi Erich,

    Happy New Year 2019.
    I was looking for some examples for ARM Cortex-M33 with TrustZone and FPU. I couldn’t find any articles on Cortex-M33 here. It is a relatively new ARM core and firmware development on Cortex-M33 is still in nascent stages. Can you please consider writing about it in your next blog?

    Thanks
    Radhika.

    Like

    • Hi Radhika,
      thanks, Happy New Year to you too!
      Yes, Cortex-M33 is on my radar, but because I have not ordered or used any of these in my projects, I have not written any articles about it. I’ll have to see if one of the university research projects starting next semester could benefit from a M33, and then certainly I will come up with an article about it.

      Like

  60. Hi Erich,

    Any idea why the MK20DX128xx5 is not supported in the MCUXpresso IDE? they only seem to have an SDK file for the parts ending in 10 (e.g. MK20DX128xx10).

    Thanks

    Like

    • No real idea. But I think it is maybe because this was one of the very first Kinetis devices, so it seems NXP has left it behind from the SDK point of view. The FRDM-K20 board for it is not available any more too.
      But we are using the MK20DX128x5 in many of our designs, and that’s why we continue to use Processor Expert because it is supported with it.

      Like

  61. Hello Erich,
    i have a problem with a new FRDM-KV31F board; one time attached to PC with Windows 10 (home), i think have bricked the board-bootloader. Now, the board is unresponsive.
    Also i have read your severals tutorials about resolve it, (in effect i have resolved this identical problem with an FRDM-K66F board), but with the kv31f my probe is not able to program the flash of k20dx128 interface chip, i receive an error message (i dont understand why, the chip is identical to interface-chip of frdm-k66f… or not?!)
    my conditions: pc Windows 10, IDE MCUXpresso 10.3.1, probe usb Multilink of PEMicro.

    Like

    • I don’t know the FRDM-KV31F, but if it is similar to the FRDM-KL25Z, then you cannnot reprogram the chip with a debugger as the flash is protected with mass erase disabled.
      But that would be good, as then Windows will not be able to brick the board. Can you try accessing it from a Windows 7 (native, not VM) machine?
      Then you should be able to update the P&E bootloader and load the application again.

      Like

  62. Hi…your openSDA/K20 is programmed, right? It does not matter if your KL43Z is empty or not: the K20 will programm it, no matter what.

    Like

  63. Hi Erich,

    Any idea where i can find the recommended footprint for the MK22FN256VLH12 (yet another thing NXP/Freescale make difficult)?

    Thanks

    Like

  64. Hi Erich,

    Just started using the MCUXpresso IDE with the MK22FN512xxx12, and noticed with an empty project (with just a while loop) 12.5% of the RAM is being used any ideas?

    Memory region Used Size Region Size %age Used
    PROGRAM_FLASH: 2424 B 512 KB 0.46%
    SRAM_UPPER: 8196 B 64 KB 12.51%
    SRAM_LOWER: 0 GB 64 KB 0.00%

    text data bss dec hex filename
    2420 4 8192 10616 2978 MK22FN512xxx12_Project.axf

    Like

  65. Hi Erich,

    Does the KDS USB CDC Lib support the following:

    Clear To Send – CTS
    Data Set Ready – DSR
    Data Carrier Detected – DCD

    I need to enable / disable the above serial port inputs

    Thanks

    Like

      • Hi Erich,

        Sorry should have been more clear.

        I am using the MK20DX128xxx5 device and the USB CDC library, such that the MK20 is enumerated as a virtual com port.

        i need the MK20 to enable / disable CTS, DSR and DCD, such that the host (connected PC) sees the virtual lines go on / off

        Clear To Send – CTS
        Data Set Ready – DSR
        Data Carrier Detected – DCD

        Like

      • Hi Erich,

        Thanks for your reply, i cannot find a method in your CDC wrapper that will do this. Should i be looking at the following function in the usb_cdc_pstn.h?

        extern uint_8 USB_Class_CDC_PSTN_Set_Ctrl_Line_State (
        uint_8 controller_ID,
        USB_SETUP_STRUCT * setup_packet,
        uint_8_ptr *data,
        USB_PACKET_SIZE *size);

        i have the USB CDC working just tring to figure out how i change the state of the virtual lines:

        void CDC_Run(void) {

        for(;;) {

        if(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer)) == ERR_BUSOFF) {
        /* device not enumerated */
        WAIT1_Waitms(10);
        } else {

        SEGGER_RTT_WriteString(0, “Change line state:\r\n”);
        int key = SEGGER_RTT_WaitKey();

        switch(key) {
        case ‘1’:
        SEGGER_RTT_WriteString(0, “CTS Enabled\r\n”);
        // TODO – Enable USB CDC CTC virtual line
        break;
        case ‘2’:
        SEGGER_RTT_WriteString(0, “CTS Disabled\r\n”);
        // TODO – Disable USB CDC CTC virtual line
        break;
        case ‘3’:
        SEGGER_RTT_WriteString(0, “DSR Enabled\r\n”);
        // TODO – Enable USB CDC DSR virtual line
        break;
        case ‘4’:
        SEGGER_RTT_WriteString(0, “DSR Disabled\r\n”);
        // TODO – Disable USB CDC DSR virtual line
        break;
        case ‘5’:
        SEGGER_RTT_WriteString(0, “DCD Enabled\r\n”);
        // TODO – Enable USB CDC DCD virtual line
        break;
        case ‘6’:
        SEGGER_RTT_WriteString(0, “DCD Disabled\r\n”);
        // TODO – Disable USB CDC DCD virtual line
        break;
        default:
        SEGGER_RTT_WriteString(0, “Unknown command\r\n”);
        break;
        }

        }
        }
        }

        Like

      • Hi Erich,

        Yes i have the latest lib and have added the CDC1_OnLineStateChanged event, and i am using the latest FSL_SUB_Stack.

        But I am not trying to monitor the Host lines, which would be DTR and RTS.

        I am trying to Set the device lines which would be CTS, CD, DSR and RI.

        So i was looking for somthing like CDC_Set_LineState(CTS);

        Thanks,
        Andy

        Like

        • Hi Andy,
          I only had a need for getting the status from the host, so this is what I have added to the stack :-).
          I have not implemented reporting the status to the host, but if you have a solution to contribute, I can integrate it into the Processor Expert component?

          Like

    • Hi Erich,

      After looking into it, i think getting the control lines working may require a driver change. So i am going to put down an FTDi device which supports the control lines i need and cahgne the MK20 to an MK10 as the USB will no longer be needed.

      Thanks,
      Andy

      Like

  66. Hi Erich,

    I have a building problem again with my project. The error follows.

    Linker CRP Enabled, but no CRP_WORD provided within application.

    I don’t know what it means. Furthermore, I have linked the project with right paths and there is no other library I should put on the “MCU Linker”.

    Thanks for your attention.

    Best regards,
    Mike

    Like

  67. Hi Erich,

    Quick USB CDC question:

    If CDC1_SendString((unsigned char*)”Some Text”); is called but the com port is closed the stack gets stuck.

    Is there a function to call that checks if the CDC port is open and read to send?

    Like

  68. Hi Erich
    I am using MCUXpresso IDE v11.0.0 [Build 2516] [2019-06-05]
    I incorporated SDK_2.6.0_FRDM-K64F
    Using Import SDK examples, all the examples are bm, why
    When I start a new project, the only option for the Operating System is “baremetal”
    How can I add FreeRTOS?

    Like

  69. Hi again
    I am using MCUXpresso IDE v11.0.0 [Build 2516] [2019-06-05] and communicating with Tera Term.
    I imported the example frdmk64f_freertos_uart.
    The introduction message has garbled characters towards the end.
    Only when I lowered the baud rate to 9600, the message is displayed correctly.
    Is that a problem with the UART_RTOS_Send routine?

    Like

    • You have to check at which baud the UART is configured. If you have configured the UART with the correct baud, you probably have not configured the system clock correclty, as the baud depends on it.

      Like

  70. Hi Erich,

    I’m using MCUXpresso 11.01 for the MIMXRT1062DVJ6A, MCUXpresso SDK USB Stack, Rev. 10, 06/2019, and the MCUXpressio usb_example program host_cdc_bm, which I modified to use FreeRTOS. The data traffic to and from my CDC device is managed in the context of the USB_HostCdcTask handler for the kUSB_HostCdcRunIdle state. Data transmission to my USB device works just fine when I call USB_HostCdcDataSend. But when I call USB_HostCdcDataRecv, my USB device can’t respond because the host cannot receive data (IN-NAK, according to the Beagle USB Analyzer and DataCenter). What might I have missed?

    Like

    • I have not used USB CDC on that i.MX RT, so cannot say much. I would have to try it myself first. But is there an example whithout FreeRTOS in the SDK which works? Just if this would the issue?

      Like

      • Thanks for the response. I actually did try this with the bare metal example and got the same result. However, I just now resolved the problem. I though that I didn’t need to use hardware flow control, but I was. Setting USB_HOST_UART_SUPPORT_HW_FLOW to 1 resolved the issue.

        Like

  71. Hi Erich,
    sorry, not sure if this belongs here but I am having a problem with my newly purchased J-Link EDU. I can somewhat debug my K64F with it through MCUXpresso however I am unable to use any utilities provided by SEGGER such as JLinkRTTViewer or even JLinkGDBServer. When I try to run any of these from command line (using Ubuntu based Linux distro) I get the following error message:

    LOG: J-Link RTT Viewer V6.54: Logging started.
    LOG: Connecting to J-Link via USB…
    LOG: Device “MK64FN1M0XXX12” selected.
    LOG: InitTarget()
    LOG: Protection bytes in flash at addr. 0x400 – 0x40F indicate that readout protection is set.
    For debugger connection the device needs to be unsecured.
    Note: Unsecuring will trigger a mass erase of the internal flash.

    LOG: Device will be unsecured now.
    LOG: Timeout while unsecuring device. Erase never stops.
    LOG: TotalIRLen = ?, IRPrint = 0x..FFFFFFFFFFFFFFFFFFFFFFF1
    LOG: InitTarget()
    LOG: Protection bytes in flash at addr. 0x400 – 0x40F indicate that readout protection is set.
    For debugger connection the device needs to be unsecured.
    Note: Unsecuring will trigger a mass erase of the internal flash.

    LOG: Device will be unsecured now.
    LOG: Timeout while unsecuring device. Erase never stops.
    LOG: TotalIRLen = ?, IRPrint = 0x..FFFFFFFFFFFFFFFFFFFFFFF1
    ERROR: Could not connect to target device.

    I have tried other K64s as well with same result.
    I am quite new to embedded so would be grateful if you could shed some light on what is happening and how to solve this.

    Thank you.

    Zdenek

    Like

    • This seems to be a connection problem with your device. The message
      LOG: Protection bytes in flash at addr. 0x400 – 0x40F indicate that readout protection is set.
      indicates that it is reading back all 0xff (which happens for bad/wrong connection) or if the device is secured.
      The entry
      LOG: Device “MK64FN1M0XXX12” selected.
      shows that your device is the correct one.

      The entry
      LOG: J-Link RTT Viewer V6.54: Logging started.
      shows that you are using a recent version of the J-Link software. As youi say it works with the IDE: can you check and verify what the IDE is using? You will see a similar connection log on the Console view of Eclipse.

      Like

  72. Hi Erich,
    thanks for the quick response.
    This is what I get in MCUXpresso 11

    Executed SetRestartOnClose=1
    [MCUXpresso Semihosting Telnet console for ‘Dev1_FreeRTOS JLink Debug’ started on port 36314 @ 127.0.0.1]

    SEGGER J-Link GDB Server V6.54 – Terminal output channel

    and in another console view

    [01-11-2019 09:19:48] Executing Server: /usr/bin/JLinkGDBServerCLExe -nosilent -swoport 2334 -select USB=261000035 -telnetport 2335 -singlerun -endian little -noir -speed auto -port 2336 -vd -device MK64FN1M0xxx12 -if SWD -halt -reportuseraction
    SEGGER J-Link GDB Server V6.54 Command Line Version

    JLinkARM.dll V6.54 (DLL compiled Oct 28 2019 10:37:24)

    Command line: -nosilent -swoport 2334 -select USB=261000035 -telnetport 2335 -singlerun -endian little -noir -speed auto -port 2336 -vd -device MK64FN1M0xxx12 -if SWD -halt -reportuseraction
    —–GDB Server start settings—–
    GDBInit file: none
    GDB Server Listening port: 2336
    SWO raw output listening port: 2334
    Terminal I/O port: 2335
    Accept remote connection: yes
    Generate logfile: off
    Verify download: on
    Init regs on start: off
    Silent mode: off
    Single run mode: on
    Target connection timeout: 0 ms
    ——J-Link related settings——
    J-Link Host interface: USB
    J-Link script: none
    J-Link settings file: none
    ——Target related settings——
    Target device: MK64FN1M0xxx12
    Target interface: SWD
    Target interface speed: auto
    Target endian: little

    Connecting to J-Link…
    J-Link is connected.
    Device “MK64FN1M0XXX12” selected.
    Firmware: J-Link V11 compiled Aug 14 2019 16:21:09
    Hardware: V11.00
    S/N: 261000035
    OEM: SEGGER-EDU
    Feature(s): FlashBP, GDB
    Checking target voltage…
    Target voltage: 3.32 V
    Listening on TCP/IP port 2336
    Connecting to target…InitTarget()
    Found SW-DP with ID 0x2BA01477
    Scanning AP map to find all available APs
    AP[2]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    AP[1]: JTAG-AP (IDR: 0x001C0000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    ROMTbl[0][6]: E0042000, CID: B105900D, PID: 003BB907 ETB
    ROMTbl[0][7]: E0043000, CID: B105900D, PID: 001BB908 CSTF
    InitTarget()
    Found SW-DP with ID 0x2BA01477
    AP map detection skipped. Manually configured AP map found.
    AP[0]: AHB-AP (IDR: Not set)
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    ROMTbl[0][6]: E0042000, CID: B105900D, PID: 003BB907 ETB
    ROMTbl[0][7]: E0043000, CID: B105900D, PID: 001BB908 CSTF
    Connected to target
    Waiting for GDB connection…Connected to 127.0.0.1
    Reading all registers
    Read 4 bytes @ address 0x00003EF8 (Data = 0xF852F000)
    Reading 64 bytes @ address 0x20000500
    Read 4 bytes @ address 0x00002CDC (Data = 0xB085B480)
    Reading 64 bytes @ address 0x200004C0
    Connected to 127.0.0.1
    Reading all registers
    Read 4 bytes @ address 0x00003EF8 (Data = 0xF852F000)
    Reading 64 bytes @ address 0x20000500
    Read 4 bytes @ address 0x00002CDC (Data = 0xB085B480)
    Reading 64 bytes @ address 0x200004C0
    Received monitor command: reset
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    AfterResetTarget()
    Resetting target
    Downloading 16080 bytes @ address 0x00000000 – Verified OK
    Downloading 16080 bytes @ address 0x00003ED0 – Verified OK
    Downloading 4880 bytes @ address 0x00007DA0 – Verified OK
    Downloading 24 bytes @ address 0x000090B0 – Verified OK
    J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
    Writing register (PC = 0x 1d4)
    Read 4 bytes @ address 0x000001D4 (Data = 0xB672B510)
    Reading 64 bytes @ address 0x00000880
    Read 2 bytes @ address 0x000008AE (Data = 0xF005)
    Read 2 bytes @ address 0x000008AE (Data = 0xF005)
    Reading all registers
    Read 4 bytes @ address 0x000001D4 (Data = 0xB672B510)
    Read 2 bytes @ address 0x000008AE (Data = 0xF005)
    Received monitor command: semihosting enable
    Semi-hosting enabled (Handle on BKPT)
    Received monitor command: exec SetRestartOnClose=1
    Executed SetRestartOnClose=1
    Received monitor command: reset
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    AfterResetTarget()
    Resetting target
    Setting breakpoint @ address 0x000008AE, Size = 2, BPHandle = 0x0001
    Starting target CPU…
    …Breakpoint reached @ address 0x000008AE
    Reading all registers
    Removing breakpoint @ address 0x000008AE, Size = 2
    Read 4 bytes @ address 0x000008AE (Data = 0xFE33F005)
    Starting target CPU…

    Both are indicating the usage of JLink GDB server 6.54

    Like

  73. Hi Erich.
    Just tried to copy/paste the command mcuxpresso used to start the gdb server into cmdline and things started to work. I assume some of my configuration has been incorrect. Noticed that I was using JTAG instead of SWD (should I be using SWD?).
    Another (maybe dumb) question: Is it possible to show PRINTF output over the K64USB or somehow via the J-Link? The project has been setup to redirect printfs to UART. Not sure if I can go back to semihosting and use console instead.

    Thanks for your time.

    Like

    • Hi Zdenek,
      yes, you *have* to use SWD, as the OpenSDA (K20) on the FRDM board only supports SWD and no JTAG.
      You can redirect the printf() to whatever you like, you just have to provide the needed glue logic.

      Like

  74. Hi all, maybe someone can help me with this,

    I have a freedom board kl25z, using GDB PEMicro Interface Debugging with eclipse 2019-12. I am working on dac_adc_demo project in KSDK 1.3 (Kinetis SDK). The startup code for this project is in startup_MKL25Z4.S. I am trying to make the debugger stop at Reset_Handler in startup_MKL25Z4.S. So I can single step in the startup code. For the debug configuration Startup tab, I set breakpoint at Reset_Handler instead of main. When I debug the program (dac_adc_demo.elf) I keep getting this message:

    “Break at address “0x4d0″ with no debug information available, or outside of program code.”

    0x4d0 is the address of Reset_Handler. The Debug settings in Tool Settings is set Maximum(-g3) and -ggdb

    The editor does not open up the startup_MKL25Z4.S and let single step through the startup code.

    But if I set breakpoint at main, I can debug/step through the code just fine.

    Any help would be much appreciate it, I am stuck on this for a while now.

    Thanks in advance.
    Anthony H.

    Like

    • Hi Anthony,
      Does it work if you set manually a breakpoint in the startup code? If not, it might be a problem that somehow you have disabled debug information for the startup_MKL25Z4.S file?
      Erich

      Like

        • Erich,
          I have turned on verbose for gnu assembler and linker.

          OUTPUT OF GNU ASSEMBLER
          Building file: ../startup/startup_MKL25Z4.S
          Invoking: GNU ARM Cross Assembler
          arm-none-eabi-gcc -mcpu=cortex-m0plus -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -x assembler-with-cpp -DCPU_MKL25Z128VLK4 -DDEBUG -DFRDM_KL25Z -DFREEDOM -v -MMD -MP -MF”startup/startup_MKL25Z4.d” -MT”startup/startup_MKL25Z4.o” -c -o “startup/startup_MKL25Z4.o” “../startup/startup_MKL25Z4.S”
          Using built-in specs.
          COLLECT_GCC=arm-none-eabi-gcc
          Target: arm-none-eabi
          Configured with: /tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/src/gcc/configure –target=arm-none-eabi –prefix=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native –libexecdir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/lib –infodir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/info –mandir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/man –htmldir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/html –pdfdir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/pdf –enable-languages=c,c++ –enable-plugins –disable-decimal-float –disable-libffi –disable-libgomp –disable-libmudflap –disable-libquadmath –disable-libssp –disable-libstdcxx-pch –disable-nls –disable-shared –disable-threads –disable-tls –with-gnu-as –with-gnu-ld –with-newlib –with-headers=yes –with-python-dir=share/gcc-arm-none-eabi –with-sysroot=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/arm-none-eabi –build=x86_64-linux-gnu –host=x86_64-linux-gnu –with-gmp=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-mpfr=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-mpc=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-isl=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-libelf=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-host-libstdcxx=’-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm’ –with-pkgversion=’GNU Tools for Arm Embedded Processors 8-2019-q3-update’ –with-multilib-list=rmprofile
          Thread model: single
          gcc version 8.3.1 20190703 (release) [gcc-8-branch revision 273027] (GNU Tools for Arm Embedded Processors 8-2019-q3-update)
          COLLECT_GCC_OPTIONS=’-mcpu=cortex-m0plus’ ‘-mthumb’ ‘-O0’ ‘-fmessage-length=0’ ‘-fsigned-char’ ‘-ffunction-sections’ ‘-fdata-sections’ ‘-g3’ ‘-D’ ‘CPU_MKL25Z128VLK4’ ‘-D’ ‘DEBUG’ ‘-D’ ‘FRDM_KL25Z’ ‘-D’ ‘FREEDOM’ ‘-v’ ‘-MMD’ ‘-MP’ ‘-MF’ ‘startup/startup_MKL25Z4.d’ ‘-MT’ ‘startup/startup_MKL25Z4.o’ ‘-c’ ‘-o’ ‘startup/startup_MKL25Z4.o’ ‘-mfloat-abi=soft’ ‘-march=armv6s-m’
          /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/cc1 -E -lang-asm -quiet -v -imultilib thumb/v6-m/nofp -iprefix /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/ -isysroot /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi -MMD startup/startup_MKL25Z4.d -MF startup/startup_MKL25Z4.d -MP -MT startup/startup_MKL25Z4.o -dD -D__USES_INITFINI__ -D CPU_MKL25Z128VLK4 -D DEBUG -D FRDM_KL25Z -D FREEDOM ../startup/startup_MKL25Z4.S -mcpu=cortex-m0plus -mthumb -mfloat-abi=soft -march=armv6s-m -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -fworking-directory -O0 -fno-directives-only -o /tmp/ccQABHKC.s
          ignoring duplicate directory “/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/../../lib/gcc/arm-none-eabi/8.3.1/include”
          ignoring nonexistent directory “/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/usr/local/include”
          ignoring duplicate directory “/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/../../lib/gcc/arm-none-eabi/8.3.1/include-fixed”
          ignoring duplicate directory “/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/../../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/include”
          ignoring nonexistent directory “/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/usr/include”
          #include “…” search starts here:
          #include search starts here:
          /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/include
          /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/include-fixed
          /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/include
          End of search list.
          COLLECT_GCC_OPTIONS=’-mcpu=cortex-m0plus’ ‘-mthumb’ ‘-O0’ ‘-fmessage-length=0’ ‘-fsigned-char’ ‘-ffunction-sections’ ‘-fdata-sections’ ‘-g3’ ‘-D’ ‘CPU_MKL25Z128VLK4’ ‘-D’ ‘DEBUG’ ‘-D’ ‘FRDM_KL25Z’ ‘-D’ ‘FREEDOM’ ‘-v’ ‘-MMD’ ‘-MP’ ‘-MF’ ‘startup/startup_MKL25Z4.d’ ‘-MT’ ‘startup/startup_MKL25Z4.o’ ‘-c’ ‘-o’ ‘startup/startup_MKL25Z4.o’ ‘-mfloat-abi=soft’ ‘-march=armv6s-m’
          /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/as –gdwarf2 -v -march=armv6s-m -mfloat-abi=soft -meabi=5 -o startup/startup_MKL25Z4.o /tmp/ccQABHKC.s
          GNU assembler version 2.32.0 (arm-none-eabi) using BFD version (GNU Tools for Arm Embedded Processors 8-2019-q3-update) 2.32.0.20190703
          COMPILER_PATH=/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/
          LIBRARY_PATH=/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/lib/thumb/v6-m/nofp/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/lib/
          Finished building: ../startup/startup_MKL25Z4.S
          COLLECT_GCC_OPTIONS=’-mcpu=cortex-m0plus’ ‘-mthumb’ ‘-O0’ ‘-fmessage-length=0’ ‘-fsigned-char’ ‘-ffunction-sections’ ‘-fdata-sections’ ‘-g3’ ‘-D’ ‘CPU_MKL25Z128VLK4’ ‘-D’ ‘DEBUG’ ‘-D’ ‘FRDM_KL25Z’ ‘-D’ ‘FREEDOM’ ‘-v’ ‘-MMD’ ‘-MP’ ‘-MF’ ‘startup/startup_MKL25Z4.d’ ‘-MT’ ‘startup/startup_MKL25Z4.o’ ‘-c’ ‘-o’ ‘startup/startup_MKL25Z4.o’ ‘-mfloat-abi=soft’ ‘-march=armv6s-m’

          OUTPUT OF GNU LINKER
          Building target: dac_adc_demo.elf
          Invoking: GNU ARM Cross C Linker
          arm-none-eabi-gcc -mcpu=cortex-m0plus -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -T “/home/aheak123/eclipse-workspace/dac_adc_demo/linkerscript/MKL25Z128xxx4_flash.ld” -Xlinker –gc-sections -L/home/aheak123/KSDK_1.3.0/lib/ksdk_platform_lib/armgcc/KL25Z4/debug -Wl,-Map,”dac_adc_demo.map” –specs=nosys.specs -v -o “dac_adc_demo.elf” ./utilities/fsl_debug_console.o ./utilities/fsl_misc_utilities.o ./utilities/print_scan.o ./startup/startup.o ./startup/startup_MKL25Z4.o ./startup/system_MKL25Z4.o ./sources/demo_state_machine.o ./sources/hardware_init.o ./sources/main.o ./board/board.o ./board/gpio_pins.o ./board/pin_mux.o -lc -lm -lgcc -lnosys -lksdk_platform
          Using built-in specs.
          Reading specs from /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/nosys.specs
          rename spec link_gcc_c_sequence to nosys_link_gcc_c_sequence
          COLLECT_GCC=arm-none-eabi-gcc
          COLLECT_LTO_WRAPPER=/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/lto-wrapper
          Target: arm-none-eabi
          Configured with: /tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/src/gcc/configure –target=arm-none-eabi –prefix=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native –libexecdir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/lib –infodir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/info –mandir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/man –htmldir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/html –pdfdir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/share/doc/gcc-arm-none-eabi/pdf –enable-languages=c,c++ –enable-plugins –disable-decimal-float –disable-libffi –disable-libgomp –disable-libmudflap –disable-libquadmath –disable-libssp –disable-libstdcxx-pch –disable-nls –disable-shared –disable-threads –disable-tls –with-gnu-as –with-gnu-ld –with-newlib –with-headers=yes –with-python-dir=share/gcc-arm-none-eabi –with-sysroot=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/install-native/arm-none-eabi –build=x86_64-linux-gnu –host=x86_64-linux-gnu –with-gmp=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-mpfr=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-mpc=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-isl=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-libelf=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-594_20190704_1562200936/build-native/host-libs/usr –with-host-libstdcxx=’-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm’ –with-pkgversion=’GNU Tools for Arm Embedded Processors 8-2019-q3-update’ –with-multilib-list=rmprofile
          Thread model: single
          gcc version 8.3.1 20190703 (release) [gcc-8-branch revision 273027] (GNU Tools for Arm Embedded Processors 8-2019-q3-update)
          COMPILER_PATH=/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/
          LIBRARY_PATH=/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/lib/thumb/v6-m/nofp/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/:/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/lib/
          COLLECT_GCC_OPTIONS=’-mcpu=cortex-m0plus’ ‘-mthumb’ ‘-O0’ ‘-fmessage-length=0’ ‘-fsigned-char’ ‘-ffunction-sections’ ‘-fdata-sections’ ‘-g3’ ‘-T’ ‘/home/aheak123/eclipse-workspace/dac_adc_demo/linkerscript/MKL25Z128xxx4_flash.ld’ ‘-L/home/aheak123/KSDK_1.3.0/lib/ksdk_platform_lib/armgcc/KL25Z4/debug’ ‘-specs=nosys.specs’ ‘-v’ ‘-o’ ‘dac_adc_demo.elf’ ‘-mfloat-abi=soft’ ‘-march=armv6s-m’
          /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/collect2 -plugin /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/liblto_plugin.so -plugin-opt=/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccz0K0ND.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lg -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lnosys –sysroot=/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi -X -o dac_adc_demo.elf /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp/crti.o /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp/crtbegin.o /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/crt0.o -L/home/aheak123/KSDK_1.3.0/lib/ksdk_platform_lib/armgcc/KL25Z4/debug -L/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp -L/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp -L/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/lib/thumb/v6-m/nofp -L/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1 -L/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc -L/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib -L/home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../arm-none-eabi/lib –gc-sections -Map dac_adc_demo.map ./utilities/fsl_debug_console.o ./utilities/fsl_misc_utilities.o ./utilities/print_scan.o ./startup/startup.o ./startup/startup_MKL25Z4.o ./startup/system_MKL25Z4.o ./sources/demo_state_machine.o ./sources/hardware_init.o ./sources/main.o ./board/board.o ./board/gpio_pins.o ./board/pin_mux.o -lc -lm -lgcc -lnosys -lksdk_platform –start-group -lgcc -lg -lc –end-group –start-group -lgcc -lc -lnosys –end-group /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp/crtend.o /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp/crtn.o -T /home/aheak123/eclipse-workspace/dac_adc_demo/linkerscript/MKL25Z128xxx4_flash.ld
          COLLECT_GCC_OPTIONS=’-mcpu=cortex-m0plus’ ‘-mthumb’ ‘-O0’ ‘-fmessage-length=0’ ‘-fsigned-char’ ‘-ffunction-sections’ ‘-fdata-sections’ ‘-g3’ ‘-T’ ‘/home/aheak123/eclipse-workspace/dac_adc_demo/linkerscript/MKL25Z128xxx4_flash.ld’ ‘-L/home/aheak123/KSDK_1.3.0/lib/ksdk_platform_lib/armgcc/KL25Z4/debug’ ‘-specs=nosys.specs’ ‘-v’ ‘-o’ ‘dac_adc_demo.elf’ ‘-mfloat-abi=soft’ ‘-march=armv6s-m’
          Finished building target: dac_adc_demo.elf

          Anthony H.

          Like

      • Hi Erich, thank you for replying.
        When I manually set a breakpoint at Reset_Handler in startup_MKL25Z4.S, it still does not work. I don’t think I disable debugging, because set Debugging option to Maximum (-g3) option and I also added -ggdb on the Miscellaneous field in debug setup.

        Regards,
        Anthony H.

        Like

        • Hi Erich,
          I have verified that there is no ‘needle’ in startup_MKL25Z4.S, also my makefile correctly generate the .hex file, see below:

          # Add inputs and outputs from these tool invocations to the build variables
          SECONDARY_FLASH += \
          dac_adc_demo.hex \

          SECONDARY_LIST += \
          dac_adc_demo.lst \

          SECONDARY_SIZE += \
          dac_adc_demo.siz \

          Like

        • Can you verify your elf file with the ‘Executables’ view in Eclipse: it shall show all source files involved.
          The other thing: check your linker .map file: could it be that somehow it is using anyother file as startup?

          Like

        • Erich,
          1) Executable view for dac_adc_demo.elf include the right startup file
          start_MKL25Z4.S
          2) portion of dac_adc_demo.map also shows
          .data 0x0000000000000000 0x0 ./startup/startup_MKL25Z4.o
          .bss 0x0000000000000000 0x0 ./startup/startup_MKL25Z4.o

          Anthony H.

          Like

        • 2) what about the code for the startup? is it listed in the map file too?
          Keep in mind that an address of 0x0 (except it is really there) means it has been removed. For the two things above they do not ‘exist’ as the size is zero too.

          Like

        • Erich,
          I don’t really understand how to read the map file. Below is a small snippet of dac_adc_demo.map file. Looks like startup_MKL25Z4.o sections are in the discarded input sections. My question is, if the startup code in startup_MKL25Z4.o file is discarded, how can we get to the main function after mcu reset?

          Discarded input sections
          .data 0x0000000000000000 0x0 ./startup/startup_MKL25Z4.o
          .bss 0x0000000000000000 0x0 ./startup/startup_MKL25Z4.o
          .text 0x0000000000000000 0x0 ./startup/system_MKL25Z4.o
          .data 0x0000000000000000 0x0 ./startup/system_MKL25Z4.o
          .bss 0x0000000000000000 0x0 ./startup/system_MKL25Z4.o
          .text.SystemCoreClockUpdate
          0x0000000000000000 0x238 ./startup/system_MKL25Z4.o

          Anthony H.

          Like

        • So indeed you have the startup code not included in your map file/linker. It must looks something like this:
          Vector table:
          *(.isr_vector)
          .isr_vector 0x00000000 0xc0 ./startup/startup_MKL27Z644.o
          0x00000000 __isr_vector
          0x000000c0 . = ALIGN (0x4)

          Flash configuration:
          *(.FlashConfig)
          .FlashConfig 0x00000400 0x10 ./startup/startup_MKL27Z644.o
          0x00000410 . = ALIGN (0x4)

          Startup code with all the ISR handlers:
          .text 0x000004e8 0xc8 ./startup/startup_MKL27Z644.o
          0x000004e8 Reset_Handler
          0x00000528 Reserved45_IRQHandler
          0x00000528 TPM1_IRQHandler
          0x00000528 PORTA_IRQHandler
          0x00000528 PIT_IRQHandler
          0x00000528 CMP0_IRQHandler
          0x00000528 LPTMR0_IRQHandler
          0x00000528 TPM0_IRQHandler
          0x00000528 LLWU_IRQHandler
          0x00000528 Reserved42_IRQHandler
          0x00000528 ADC0_IRQHandler
          0x00000528 Reserved39_IRQHandler
          0x00000528 PORTBCDE_IRQHandler
          0x00000528 FTFA_IRQHandler
          0x00000528 DefaultISR
          0x00000528 TPM2_IRQHandler
          0x00000528 Reserved43_IRQHandler
          0x00000528 RTC_IRQHandler
          0x00000528 RTC_Seconds_IRQHandler
          0x00000528 Reserved41_IRQHandler
          0x00000528 Reserved20_IRQHandler
          0x00000528 USB0_IRQHandler
          0x00000528 PMC_IRQHandler
          0x0000052c NMI_Handler
          0x00000530 HardFault_Handler
          0x00000534 SVC_Handler
          0x00000538 PendSV_Handler
          0x0000053c SysTick_Handler
          0x00000540 DMA0_IRQHandler
          0x00000544 DMA1_IRQHandler
          0x00000548 DMA2_IRQHandler
          0x0000054c DMA3_IRQHandler
          0x00000550 I2C0_IRQHandler
          0x00000554 I2C1_IRQHandler
          0x00000558 SPI0_IRQHandler
          0x0000055c SPI1_IRQHandler
          0x00000560 LPUART0_IRQHandler
          0x00000564 LPUART1_IRQHandler
          0x00000568 UART2_FLEXIO_IRQHandler

          I believe you have screwed up your linker settings.
          Make sure your linker does NOT have the option -nostdlib set, and does NOT have the option -nostartfiles set (both options shall not be present). Same for -nodefaultlibs.

          Like

        • It might be that your linker file is wrong too: make sure you are using a correct one, and have something like
          /* Entry Point */
          ENTRY(Reset_Handler)
          in it. Best if you check things with one of the provided examples in KDS or on my GitHub site.

          Like

        • Erich, thank you for the help so far (it is getting late here, so I am going to sleep now), but looking at the dac_adc_demo.map file again, I do see there is code for startup_MKL25Z4.o. Below is a snippet:

          .interrupts 0x0000000000000000 0xc0
          0x0000000000000000 __VECTOR_TABLE = .
          0x0000000000000000 . = ALIGN (0x4)
          *(.isr_vector)
          .isr_vector 0x0000000000000000 0xc0 ./startup/startup_MKL25Z4.o
          0x0000000000000000 __isr_vector
          0x00000000000000c0 . = ALIGN (0x4)

          .flash_config 0x0000000000000400 0x10
          0x0000000000000400 . = ALIGN (0x4)
          *(.FlashConfig)
          .FlashConfig 0x0000000000000400 0x10 ./startup/startup_MKL25Z4.o
          0x0000000000000410 . = ALIGN (0x4)

          .text 0x0000000000000410 0x9548
          0x0000000000000410 . = ALIGN (0x4)
          *(.text)
          .text 0x0000000000000410 0x48 /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/thumb/v6-m/nofp/crtbegin.o
          .text 0x0000000000000458 0x78 /home/aheak123/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/crt0.o
          0x0000000000000458 _mainCRTStartup
          0x0000000000000458 _start
          .text 0x00000000000004d0 0x18 ./startup/startup_MKL25Z4.o
          0x00000000000004d0 Reset_Handler
          0x00000000000004e0 I2C0_IRQHandler
          0x00000000000004e0 HardFault_Handler
          0x00000000000004e0 SysTick_Handler
          0x00000000000004e0 PendSV_Handler
          0x00000000000004e0 NMI_Handler
          0x00000000000004e0 I2C1_IRQHandler
          0x00000000000004e0 UART1_IRQHandler
          0x00000000000004e0 DMA2_IRQHandler
          0x00000000000004e0 TPM0_IRQHandler
          0x00000000000004e0 LLWU_IRQHandler
          0x00000000000004e0 TSI0_IRQHandler
          0x00000000000004e0 UART0_IRQHandler
          0x00000000000004e0 ADC0_IRQHandler
          0x00000000000004e0 Reserved39_IRQHandler
          0x00000000000004e0 SPI1_IRQHandler
          0x00000000000004e0 DefaultISR
          0x00000000000004e0 PORTD_IRQHandler
          0x00000000000004e0 TPM2_IRQHandler
          0x00000000000004e0 RTC_IRQHandler
          0x00000000000004e0 RTC_Seconds_IRQHandler
          0x00000000000004e0 MCG_IRQHandler
          0x00000000000004e0 UART2_IRQHandler
          0x00000000000004e0 Reserved20_IRQHandler

          Like

  75. Hi Erich, I am working on mbed MCUs for my uni dissertation and you have really pointed me in the right direction as a beginner. Thank you!

    Like

      • Hi Erich thanks for the well wishes, just wanted to ask a quick question. I’m using the FRDM-K64F and converting the library for use on the Zumo robot, similar to what you did! One aspect I’d like to look at is the additional wifi/bluetooth capability of the frdm board compared to the arduino uno. However, I’m not sure how to connect a chip such as ESP8266 or a BLE while the board is connected to the Zumo robot at the same time, without the ability to solder. I was wondering if I could test any additional functionality through maybe the inner row of the FRDM board with the 32 additional pins but I actually have no idea what they are for. All I found online is that they’re for “Headers for proprietary shields”, I’m not sure what a proprietary shield is… Anyway this isn’t a highly important task for my dissertation as the main part is just converting the library but thought it would be interesting if I have time! Thank you so much.

        Like

        • Check the FRDM-K64F schematics about the inner rows: they include some extra signals which are not part of the outer rows (the K64F has more pins available than the number of outer rows.
          Standard Ardunio shields only use/have the outer rows of pins. So ‘proprietary’ means as shield/board not only having the outer rows, but the inner ones too.

          Like

  76. Hi Erich
    I am using MCUExpresso and the K64F freedom board. I have a variable where I store data (12 bytes long). What do I need to do in order not to lose that data after a power off and then a power on. Is there an example.
    Thanks
    Eli

    Like

  77. Hola. Thanks for the continued blog. I’ve been following for some time and appreciate the bits of wisdom bestowed freely onto the audience.

    The reason for my post herein: I am working with a LPC54102 in a different dev environment (ARMbasic – a compiled vs. interpreted language instantiation on many LPC and some Atmel/nRF/STM MCUs). On the LPC54102, I am working to implement a battery powered RTC construct on one of the dev boards I have.

    I’ve a ML2020 thereon which is schottky diode isolated from the rest of the board and feeding the four (4) Vdd inputs (pins 8,24,34,& 56 on the QFP-64 package), when power to the onboard regulator gets nix’d. I’m using the regulator to strongly pull up a lightly pulled down IO that I will code to falling-edge-trigger a GPIO interrupt to put the MCU into the deep power down mode, so that the ML2020 can keep the RTC peripheral alive and clocking away.

    I am not C savvy but have ported some C code in the past and was looking to do so now, but it seems that the LPC Xpresso power library makes use of .a libraries and not proper C source/header files (whether it is IP related concerns, or ease of distro/use, is unknown to me). In doing some reading, I understand these library files are just uncompressed archives intended to be dynamically linked to during compilation by the C toolchain. I was looking to port some of the procs over from C to AB to make use of them, but find that I can’t find the forest as I can’t see through all of the trees in my way.

    What is driving this is that the 54102 doesn’t have a separate Vbat input to the MCU but rather expects devs to put the device into the required power mode, to ensure that the existing battery on the board powers only the peripherals/clocks/etc. desired The firmware for the power control that is baked into the devices ROM is flawed, per the errata, so the use of the LPC Xpresso libs is called for, per the UM.

    Ideally, I’d just locate the C source so that I could port that into native AB code. Absent that, I am able to take assembly and run it in my AB sources, via a couple of different mechanisms. In this context, I suspect that I would create a constant (syntax which is pretty similar to C), and then ‘call’ a pointer to that constant’s memory location, to have the proc’s code run as needed, after doing a bin2hex conversion on same and assigning it to said constant.

    What I am struggling with, conceptually, is the mechanics of identifying what bits and pieces of the .a embedded .o files are code vs. memory locations of variables/constants, and how to identify, within each proc’s assembled code, where references are made to the variable/constants so that I can point the imported code to the memory locations of the variables/constants that I instantiate in my wrapper code.

    Anyways, what I am curious about is if there is anyone who might have trudged down a similar path previously, to solicit them for their process and lessons learned/best practices. If anyone is able and willing to codify same, or point me to where prior work may have codified same, that would be most appreciative. Thank you, in advance.

    -t

    Like

  78. Hi again
    I am using the K64F and am supplying power to it via pin 16 (P5-9V_VIN).
    The program only works if there is power via the openSDA usb connector.
    If I don’t have the openSDA connected, how do I get the program to run.
    As always, I appreciate your help.
    Thanks
    Eli

    Like

  79. Hi Erich
    Concerning the previous Q&A: K64F rev B did not work but K64F rev E works fine.
    Thanks for pointing this to me.

    I think I found a problem with MCUXpresso.
    I created a new C/C++ Project for the K64F
    – selected FreeRTOS and all drivers
    – in Middleware I selected USBhost
    – in Software components I selected osa_free-rtos
    I then created the project and then built it.
    I get the following error:
    fatal error: usb_osa_bm.h: No such file or directory

    Have you seen this?

    Like

  80. Hi
    You were right again. I had SDK version 2.6.0

    I upgraded to MCUXpresso 11.1.1 and SDK 2.7.0
    I imported SDK example “frdmk64f_host_hid_generic_freertos”
    I want to add a Uart to this project so I added the driver “uart_freertos”
    When you build this you get an error: malloc.h: No such file or directory

    Like

    • Hi Eli,
      did the same on my side. But the uart_freertos driver is already added for me when I import that project. Note that I used the ‘Import SDK example(s)’ from the Quickstart panel.
      Everything is building fine that way.

      Like

  81. Hi Erich,
    I have a question regarding linker script selection vs #define.

    I use a bootloader that requires (as most bootloaders) some area at the start of the flash.
    If I compile for debugging (without bootloader), I need to select another linker script then with bootloader. This is done by the MCUXpresso – Build Configuration – Set Active (where the selection of the correct script is done). Additionally I need to change my #define BOOTLOADER_VERSION from 1 to 0 or vise versa.

    Do you know any solution that I can combine either the #define into the Build Configuration or the linker script selection into the #define area?

    Thanks and greetings!
    Philipp

    Kinetis K66f, MCUxpresso 11.2

    Example code here:

    *(unsigned long*) 0xE000ED08 = 0x1fff0000; // set the location of interrupt vectors to the start of SRAM
    #if BOOTLOADER_VERSION
    memcpy((void *)0x1fff0000, (void *)0x00008080, 0x0230); // copy the fixed vectors to SRAM
    #else
    memcpy((void *)0x1fff0000, (void *)0x00000000, 0x0230); // copy the fixed vectors to SRAM
    #endif

    Like

  82. Hi Erich,
    do you have an example or article or tutorial about an implementation of an USB virtual com with, for example, an FRDM board (my HW is an FRDM-K66F) under MCUXpressoIDE?
    I have see some example (frdmk66f_dev_cdc_vcom_bm or _lite_bm) and also i have tried with IDEv11.2.0 building code using USBHS peripherals presetting a device CDC VCOM bare metal, but echoing chars don’t work, i think, due to errata USB-VCOM driver on my PC x64 Windows10 based… May be i need a specific driver?
    TNX

    Like

  83. Hi Erich,

    Does PCBWAY offer completed board of the tinykl22 or only the pcb? I checked their website and they seem to only offer just the public.

    Regards,
    Anthony

    Like

    • Hi Anthony,
      they offer by default producing the boards, but you can use as well their assembly service (the extra information is on the github). But the price per board will heavily depend on the number of boards. I heard that for 20 boards it is around $50 in total for a board. We produced 400 for the university and the price was around $20 for a single board. So if you are after a single or few boards, you might be better for just the PCB and then assemble the parts yourself.

      Like

      • Hi Erich,

        Thank you for replying. Thanks for the info. I wish I could just order just one or two with the price being comparable to the freedom boards. Seems to be too expensive for the assembly service. Maybe I can get this board in the future at Mouser or Digikey with comparable price as the freedom boards.

        Regards,
        Anthony

        Like

        • Hi Anthony,
          unfortunately it is all about volume: The freedom boards get produced probably in the >10k numbers, making it cheaper per board. Plus I assume NXP has not to pay for its own chips. The most expensive part on the tinyK22 is the MCU itself and makes up around half the price in single quantity for the parts. As for alternatives: there is the LPC845-BRK which is around $6 (https://mcuoneclipse.com/tag/lpc845-brk/), but an ARM Cortex-M0 and less powerful. Good board for smaller things which do not require native USB. And there is the Teensy (https://mcuoneclipse.com/2017/04/29/modifying-the-teensy-3-5-and-3-6-for-arm-swd-debugging/) but you have to make a hardware modification to make it working with a debugger.
          For Mouser or Digikey probably you would have to produce such a board in >5k quantity, take a huge risk and even leave a margin for them. Maybe a ‘cloning’ company in Asia would pick it up and offer it on AliExpress like the ‘Blue Pill’ boards? STM in my view did a great job with the NUCLEO boards: I wish NXP would have the same, but they have it only with the LPC845-BRK one.

          Like

  84. Hi Erich,
    I’m using a K22FN512 and FRTOS and USB serial. I’m having trouble in that my serial coms work fine one way, but back the other direction it doesn’t seem to work right.
    I took a look at what I thought was the rx buffer, and it had both the outgoing tx bytes in it, and my missing packet from the other direction. the CDC1 component uses both an RX1 component and a TX1 component. why am I seeing (charactors going) both directions in the same buffer?

    This buffer is the argument to the CDC1_app_task() call.

    Brynn

    Like

    • Have you turned on pull resistors on the Rx and Tx UART lines? Not sure if this is the same on your side, but in the past I have seen cross talk if not having pull resistors (at least internally), showing up what I’m sending on Tx in the Rx again.
      I hope this helps,
      Erich

      Like

      • I don’t think there is really a Rx and Tx line at all. This is a USB virtual com port (the FSL CDC device). At one point I wanted to hook an Oscope up to look at the serial stream, then I remembered that it would be trying to look at USB – with which it might be possible to see the serial packets inside whatever the USB wraps around it, but I figured that would be more difficult, and maybe not worth the effort.

        Brynn

        Like

        • ah, I thought it is that kind of UART to USB CDC scenario as on the FRDM boards (target sending to UART to the K20).
          So not sure what it could be (dangling pointer maybe? stack overflow? not enough stack space).
          The other thing is that the USB task pushing the USB engine needs to run at a high frequency/high priority to make sure the USB peripheral is served on time.

          Like

        • This is all from working code that I am transmogrifying to serve a different purpose. The USB engine runs once every 1 to 10 milliseconds. and IIRC the USB interrupt priority is set high.

          How come when (in KDS 3.2) when I put an breakpoint on the second line below
          if (CDC1_GetChar(&user_char)==ERR_OK){
          cdc_buffer[ptr]=user_char;

          That the debugger crashes?

          You can see that I am manually copying the char to the cdc_buffer. maybe this is not how it should be? Also ptr is clamped between 0 and the sizeof the buffer-1.

          Like

        • First: the debugger should not crash or course.
          Below is some bare metal code from one of my examples which echos the received characters, maybe this helps?
          Example from https://github.com/ErichStyger/mcuoneclipse/blob/master/Examples/KDS/FRDM-K20D50M/FRDM-K20_USB_CDC/Sources/main.c

          static uint8_t cdc_buffer[USB1_DATA_BUFF_SIZE];
          static uint8_t in_buffer[USB1_DATA_BUFF_SIZE];

          static void CDC_Run(void) {
          int i;
          uint32_t val = 0;
          unsigned char buf[16];

          for(;;) {
          while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
          /* device not enumerated */
          LEDR_Neg(); LEDG_Off();
          WAIT1_Waitms(10);
          }
          LEDR_Off(); LEDG_Neg();
          if (CDC1_GetCharsInRxBuf()!=0) {
          i = 0;
          while( i<sizeof(in_buffer)-1
          && CDC1_GetChar(&in_buffer[i])==ERR_OK
          )
          {
          i++;
          }
          in_buffer[i] = '\0';
          (void)CDC1_SendString((unsigned char*)"echo: ");
          (void)CDC1_SendString(in_buffer);
          UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"val: ");
          UTIL1_strcatNum32u(buf, sizeof(buf), val);
          UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
          (void)CDC1_SendString(buf);
          val++;
          } else {
          WAIT1_Waitms(10);
          }
          }
          }

          Like

  85. Hi Erich,
    I have a situation where in like if control goes into one function i need to change the value of one global variable present in that file,but as soon as i changed the value performing NVIC_RESET()
    so i am losing the variable value,but i need that variable value to be retained since i have to compare it in another functions of that file.
    How we can achieve it???PLs help me

    Thanks megha

    Like

  86. Hi Erich
    I got a new K64F board and it comes with Mbed. I want DAPLINK. I followed the procedure to download DAPLINK and when I plug in the board it shows up as DAPLINK but the red light on the board goes on and MCUExpresso does not see the board. What did I do wrong and how can I solve this.
    Thanks

    Like

  87. Hi Erich,
    I’m a long time follower to your blog and admire the great web publishing you made. I’m an embedded software engineer for over 25 years. Recently I worked on an RTOS project and willing to share some interested thoughts to public, but I’m a newbie in blog, would you be possible to share little bit your experience on work with WordPress on publish tech blog? I assume that you’re using WordPress? Point to me some links to guide WordPress beginner to build a tech website?
    Thanks,
    Andy

    Like

    • Hi Andy,
      thank you for that feedback 🙂
      Yes, I’m using WordPress and I’m pretty happy with it. The WordPress.com has tutorials including video tutorials: https://wordpress.com/support/video-tutorials/ which are a good starter.
      They apply pretty much for a ‘tech website’ too. You can start with a free account and build up things. I decided to upgrade the package to include a custom domain (.com) because domains with ‘wordpress’ in it might be blocked by some countries in Asia or other regions because wordpress sites are used for articles some governments might not like or are subject of blocking because of political reasons.

      I hope this helps,
      Erich

      Like

      • Hi Erich,
        Thanks for your help. Appreciate sharing your insight.
        A few more questions, after a fresh WordPress installation, what extra plugins you suggest to install? Do you install/use theme other than default? What backup/restore plan and/or strategy for your web site?
        Thanks,
        Andy

        Like

        • Hi Andy,
          I’m using the standard plugins WordPress.com offers (I don’t do a self-hosting, everything is done by Wordress.com). I used and tweaked a little the standard (free) theme.
          Wordpress.com does the backup, but I can do a download/snapshot of all files (did that a few times for my own backup).
          Erich

          Liked by 1 person

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.