Requests


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

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

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

1,034 thoughts on “Requests

  1. hi,
    Do you have an example of how to use USB Host CDC (FSL_USB_CDC_HOST) and how to configure it with Processor expert?

    Thanks Thomas

    Like

  2. Hi Eric,

    I have come across a great Extension for Visual Studio 2012/13/15 call ed VisualGDB
    http://visualgdb.com/tutorials/arm/kinetis/

    They support Kinetis devices, I have been able to run their basic Blinky test on a FRDM-K64F.

    As I have done many embedded projects with Visual Studio in the past I am comfortable with its IDE and would like to stick with it and use it for development of NXP Kinetis based projects.
    Other benefits of doing embedded development in Visual Studio is for example; that you can develop USB or TCP/IP windows applications that communicate with your Kinetis based device within the same IDE. In some instances I have also created Simulators that test embedded code.

    I would like to setup larger projects to test out VisualGDB that use the KSDK and ultimately a project with LAN and USB connectivity. It appears there will be a lot of manual setup to achieve this. my hope is that it will be as effective a tool as Atmel Studio.

    What are your thoughts on this technique?

    Like

    • Hi Chad,
      I have been a great fan of Visual Studio at the time when I developed desktop software. I admit that after I switched to the embedded word I have left VS behind. Looks like it is time to look at it again. My experience in the past was that doing everything in a single IDE might not be always ideal, especially if it goes with debugging. I had good experience with that using Eclipse especially with cross-platform/Linux development, but I had not tried that with the Visual Studio CS edition yet. As you say, this might need some manual setup, maybe even running two instances of VS. But I think it should be very doable. My only concern with VisualGDB is if it will be able to catch up with all the devices and boards which exist, as this is already a challenge for the other IDE’s out there.

      Like

  3. I’d like to hear your opinion on plain Processor Expert projects vs KSDK 1.3 / 2.0, why they are so different, when you should use them, when you might not need to, etc.

    Like

  4. Hi Erich! It’s been a while : ) How is it going?

    I want to ask you about USB. Is it possible to connect two KL25Z via USB? I mean, usually I connect my FRDM-KL25Z to PC via USB with CDC, but I want to connect one KL25Z via USB to another KL25Z through its USB.

    Is it possible?

    Thanks in advance!!

    Like

  5. Hi Erich,
    I just finished one project with the help of your great tutorials, and when now I’m starting a new one it really makes me want to keep on working with FS(or NXP) so first of all thanks again for all the tutorials.
    I noticed that PE have components for UI (LCD screen, touch screen buttons etc…).
    I was wondering if you could make some project demonstrating the use of those components?
    Thanks!
    Avner

    Like

  6. Hi Erich
    This is Ganesh again. In ( https://mcuoneclipse.com/2013/04/28/serial-bootloader-for-the-freedom-board-with-processor-expert/ ) this article you have explained clearly about designing a serial bootloader for KInetis L series controller. I got lot of my doubts cleared through comments in that article. I just have one last doubt to be cleared.
    1. First of all I am using a Kinetis Design Studio IDE and my internship title is to build a bootloader for Kinetis E series controller (MKE02Z64VLD2). They have given me a segger J link for dumping codes into the controller fitted on to a customized board (not a freedom board). I am in my final year of undergraduation so my previous experience with embedded,KDS, Bootloader are “ZERO” .
    2. With the help of the article I successfully completed step 1 and step 2. But when I came to the third step that is the step where you use a “Terminal Program” I got confused. There is no COM port in my PC. So I asked you what should I do. You replied, ” If you are using a Segger J-Link to program your device/board, then you don’t need a serial bootloader.” I was still confused. Are there 2 different bootloaders ? A serial one and a normal one ?
    3. From other article of yours, I installed all updates to my processor expert. I included shell from that list and again faced few problems so I again asked you and you replied, ” if you want to add USB or Asynchro serial as configuration channels you should disable Kinetis SDK ”. I tried adding Segger RTT as referenced components without disabling SDK. It never showed any error this time. Is that okay ?
    4. In a nutshell, I have limited the flash memory and protected the lower regions of flash, now when I get to the third step, it asks me to use a terminal program which is not possible for me as my pc has no COM port, what is the alternative ?
    Sorry for the long post, but you are my only hope Erich.
    Thanks & Regards
    Ganesh R

    Like

    • Hi Ganesh,

      On 2): That bootloader requires that you have a serial/UART/USB CDC connection to your board. Your device should have a UART/serial port, so with the proper level shifter you can get a real RS-232 out of it. If your notebook does not have a physical serial port, then you need to use a USB-to-Serial converter. See that cable for example shown in this post: https://mcuoneclipse.com/2012/03/10/usb-or-not-cdc-with-processor-expert/. There are many other available on the market.

      On 3): the Segger RTT is a communication channel through the Segger debugger: you won’t be easily able to use that for the bootloader as this requires a debugger connected, plus you don’t have any control over the communication speed with the Segger RTT terminal program. See https://mcuoneclipse.com/2015/07/07/using-segger-real-time-terminal-rtt-with-eclipse/ for details about RTT.

      On 4): as said above, you have to have some kind of communication to the target. I recommend that you use an UART on your device with a Serial-To-USB converter cable. This will create a virtual COM port on your machine you could use.

      Erich

      Like

  7. It looks like my KL05 Timer/PWM Module is not running when I use STOP power mode (=LLS) with FRTOS and tickless idle mode. I want a simple tone generator to run a buzzer and this works fine if I stay in RUN mode:
    TPM1_SC = (TPM_SC_CMOD(0x01) | TPM_SC_PS(0x00)); /* enable counter */
    FRTOS1_vTaskDelay(200/portTICK_RATE_MS);
    TPM1_SC = (TPM_SC_CMOD(0x00) | TPM_SC_PS(0x00)); /* Disable counter */

    It also works in STOP mode if I replace the vTaskDelay() with:
    WAIT1_Waitms(200);
    Is there a more elegant way to run the timer other than with WAIT1_Waitms()?

    Like

    • I would prevent FreeRTOS to enter the low power mode while your buzzer is running.
      You could set a ‘startedBuzzer’ global flag.
      Now in the FreeRTOS component, under Tickless Idle mode there is a Idle Decision hook setting: if you turn that on, you have to provide a function like this:
      BaseType_t XEnterTicklessIdleMode(void);
      /*!
      * \brief Callback called by the RTOS from the IDLE task to know if it can go into tickless idle mode.
      * \return pdTRUE if RTOS can enter tickless idle mode, pdFALSE otherwise.
      */
      In that hook, return pdTRUE as long the buzzer is running. And then you can use vTaskDelay() instead of Wait()
      I hope that helps?

      Like

  8. Hello Erich,
    I would like to make some workshops about FreeRTOS using one of FRDM boards. My plan was to use KL25Z and show some simple bare metal applications and compare them with FreeRTOS apps. May I ask you, as experienced teacher, for some advice? Is this board a good choice? Am I allow to use your port of FreeRTOS during workshop?

    Like

  9. Hi Erich,
    Its just my humble request. If its possible and if you have time, one day post an article about designing bootloader for Kinetis E series controller using Kinetis Design Studio with Processor expert. I am not asking yout to do. Its just my request. Thanks
    Regards
    Ganesh R

    Like

  10. I have apparently just destroyed three boards: I inadvertently programmed a KL05 image into a KL15 processor. The programmer now gives “connecting to target fails” errors when I try to program them with their correct images: the programming does not start.

    Has anyone else seen this, or understand why the chips won’t respond? Any ideas for fixing the problem other than changing the chips? I use a J-Link with Eclipse.

    Like

    • Could it be that you have secured the device? If mass erase is disabled and you have secured the device, then the device will be lost ☹.
      If not, I have pretty good luck with trying to reset the microcontroller/device while connecting to it with a J-Link.
      You might need to try this several time to get the correct time: the idea is to keep the microcontroller in reset while the debugger tries to access it, then at the right time release it from reset.
      Good luck!
      Erich

      Like

  11. Hi Erich,

    I am planning on using the low power UART’s on KL17Z and/or KL27Z for a current project using KSDK 2.0. The reference manuals for these parts proudly proclaims that the LPUART’s support programmable 8-bit, 9-bit or 10-bit character lengths, however the SDK doesn’t expose this feature. I think it will be a fairly simply task to modify the relevant SDK files (fsl_lpuart.c and fsl_lpuart.h) to allow this functionality, but I am wondering if you have any suggestions for an approach for modifying SDK files ? Making and editing a local copy perhaps is the only option ?

    thanks
    Geoff

    Like

      • Andy, yes but only by making a set of customised SDK functions. Start by adding in additional fields to the config structures (eg added “lpuart_data_bit_count_t dataBitCount;” to lpuart_config_t), add the required code to set the relevant registers, then extend the read/write functions (and any related functions) to use a 16-bit word rather than 8-bit byte for transfers.

        It wasn’t as much work as I was expecting, but it is a pain to update between SDK releases.

        Liked by 1 person

  12. Hi Erich,

    How to print the revived data from HC05 using FRDM K64F?

    I am struggling with this, I can not print the received data on terminal?

    Thank you

    Sam

    Like

  13. Hi Erich,
    have a FRDM-kl03z board. Is there any way I could enable it to use mbed compiler (embed.org)?
    Something like a firmware update or SDA application that let me download .bin files (mbed compiled) to it?

    Thanks for your response.

    Like

  14. Hi, Erich
    I tried downloading several firmware to my frdm-lk03z board without success:
    1. CMSIS-DAP_OpenSDA.S19 from NXP FRDM-KL03 Quick Start Package: result=> my board does not appear as a drive in my PC, but virtual COM port appear in device manager.

    2. DEBUG_OpenSDA_for_MBED_Bootloader_by_Pemicro_v108.bin from PEmicro web site: result=> same as above.

    3. 20140530_k20dx128_kl05z_if_opensda.s19 from mbed.org: result=> my board appears as an MBED drive in my pc, but when I drop a binary file in it, a file named “fail” is creaed that contains the words ” SWD error”
    I tried this firmware but my board is FRDM – KL03 , because the two boards have the same amount of flash memory;

    Any idea?

    Like

    • Hi Miguel,
      yes, both the CMSIS-DAP and P&E debug app do not provide you a MSD device, ‘only’ debug and virtual COM.
      If 3) fails, then something might be wrong with your bin file. And it has to match *exactly* the device/amount of flash/etc. Same amount of flash might not work, as the flash algos are different (different RAM location, different flash technology, etc).
      Erich

      Like

  15. KL25Z128M4 Registers for timer, interrupt, watchdog and PWM

    I research registers which are useful to use timers, interrupts, watchdogs and PWM. I already searched on the mkl25z datasheet (807 pages) but this datasheet is really hard to use to find the required information. Of course i have to do it without the use of the processor expert. Could you please help me ?

    Thank you,
    Maxime

    Like

      • I try to use my mkl25Z without the Processor Expert to better understand how it works. I already did some prog for LEDs, Timers, and interrupt however i really want to do it by the raw way.

        Did you write that i can see which registers are used in my Processor Expert program ? Because i know that : to write my code i need to set up these registers : TPMx_SC, TPMx_CNT, TPMx_MOD, probably registers of GPIO (LEDs : GPIOx_PDOR, GPIOx_PDDR and PORTx_PCRn) to see the interrupt.

        I want to do a interrupt program which count to 5 seconds then it turn on the blue led (PTD1) for exemple.

        Like

      • I did a PWM code with registers, but i have some difficult to understand how to give a value to have a specific duty cycle. If i want a 50% duty cycle, what i have to put in binary ?

        void PWM_set(void)
        {
        SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
        SIM_SCGC6 |= (1<<26); //TPM2 Clock enable
        SIM_SOPT2 = (1<<24); /* Select main clock source for the TPM module : MCGFLLCLK */
        PORTB_PCR3 = PORT_PCR_MUX(3); // Configure le mux de PTB3
        PORTB_PCR2 = PORT_PCR_MUX(3); // Configure le mux de PTB2
        TPM2_SC = 0x0c; // 0000 1100 : divided by 16 and LPTPM counter increment on every LPTPM counter clock
        TPM2_MOD = 0x12b; // PWM period
        TPM2_CONF = 0xc0; // 1100 0000
        TPM2_C0SC = 0x28; // 0010 1000 Bit 3 : edge or level select / bit 5 : channel mode select
        TPM2_C0V = 0x12b; // Duty cycle value
        TPM2_C1SC = 0x28; // 0010 1000 Bit 3 : edge or level select / bit 5 : channel mode select
        TPM2_C1V = 00111; // Duty cycle value
        }

        And i still don't know what registers to use for doing an interruption…

        Could you help me again please ?
        Thank you for your help.

        Like

  16. I found the answer to my question : i put the value 12b to my PWM so i need the half for a 50% duty cycle. 12b = 299 so the half is 149.

    I’m still trying to do an interrupt code without PE. I know that i have to use the LPTMR register. At each interruption, i want that the green LED turn on. I got some difficulties to understand how to set NVIC and LPTMR register.

    Thank a lot for your helps and past answers.

    Maxime

    Like

    • I try to do an example of an interrupt without PE. I use a KL25Z.
      The program has to do a timer which count to 5seconds, then the interruption turn on the blue LED and the timer restart. The second time, the blue led turn off, and the timer restart and again and again …
      I got some difficult to do this program as a beginner.

      Could you help me to do it, this is what i did for the moment.

      #include “MKL25Z4.h”

      static int i = 0;
      void delay(void);
      void TPM_Init(void);
      void GPIOBlue_Init(void);
      uint16_t getTPMCounter(void);
      void ResetTPM(void);

      int main(void)
      {
      uint16_t delayTimerTick;

      /* Write your code here */
      /* This for loop should be replaced. By default this loop allows a single stepping. */

      TPM_Init();
      ResetTPM();
      delay();
      delayTimerTick=getTPMCounter();
      __asm(“nop”); //set a break point here

      for (;;) {
      i++;
      }

      /* Never leave main */

      return 0;

      }

      void GPIOBlue_Init(void)
      {
      SIM_SCGC5 = 0b01011110000000; // Enable clock for PORTA, B and D
      PORTD_PCR1 = 0b00100000000;
      GPIOD_PDDR = 0b10;
      GPIOD_PDOR = 0b10;
      }

      void TPM_Init(void)
      {
      SIM_SCGC6|=0x03000000; //enable FTM0 and FTM0 module clock
      SIM_SCGC5|=0x3E00;
      SIM_SOPT2|=0x1000000; //select TPMSRC clock source as MCGIRCLK clock
      TPM0_CONF=0x00; //set up BDM in 11
      TPM0_MOD=0xFFFF;
      TPM0_C0SC=0x14; //FTM output signal toggle when the FTM counter matches with //C0V registrer
      TPM0_C0V=500;
      TPM0_SC=0x08; // system clock driving, dividing by 1
      }

      void ResetTPM(void)
      {
      TPM0_CNT=0x00;
      }

      uint16_t getTPMCounter(void)
      {
      uint16_t temp;
      temp=TPM0_CNT;
      return temp;
      }

      void delay(void)
      {
      uint16_t delayCounter;
      for(delayCounter=0; delayCounter<1000; delayCounter++)
      {
      __asm("nop");
      __asm("nop");
      }
      }

      //void PORTD_IRQHandler(void)
      //{
      //DelayFunction();
      //GPIOD_PDOR = 0b10; /*Turn Off Blue Led*/
      //GPIOD_PDOR = 0b00; /*Turn On Blue Led*/
      //DelayFunction();
      //GPIOD_PDOR = 0b10; /*Turn Off Blue Led*/
      //DelayFunction();

      //PORTD_ISFR = PORT_ISFR_ISF(0x40); /* Clear interrupt status flag */
      //}

      //void DelayFunction(void)
      //{
      //int cnt;
      //for(cnt=0; cnt<1000000; cnt++)
      //{

      //}
      //}

      Like

      • Hi Maxime,
        the easiest and simplest way for this is a) do this with Processor Expert (it is a matter of minutes). Then you can b) look at the generated code and use/change with it your example you have posted here.
        That way you can understand what is necessary. If you don’t want to do a), then you have to read the relevant parts of the reference manual (TPM timer module) to get it done. Should take you a few hours that way.
        Both ways is very doable in my view.
        I hope this helps,
        Erich

        Like

      • Hi Erich,

        I try to do my interrupt program without PE with the generated code of my interrupt program with PE which works.
        However, i’m stuck by the NVIC which is really bad explain in the datasheet. In the generated code, i don’t find where is declared NVIC_IPR7 and NVIC_ISER.

        Like

  17. Hi Erich,

    I saw in many examples of code the derivative.h but i do not understand how it works. I saw that inside there is only #include “MKL25Z4.h”. So what is the aim of replace derivative.h with MKL25Z4.h ?
    Thank you for your last help.
    Maxime

    Like

    • Hi Maxime,
      the derivative.h serves the purpose of information hiding: the application includes derivative.h but does not need to know which device is used (e.g. KL25Z).
      If you change the device, you only have to change that include in a single place (derivative.h).
      I hope this makes sense?
      Erich

      Like

  18. Hi again Erich,

    Sorry if i annoy you with my help requests and my poor English 😦

    I’m again on an internal interrupt code which turn on a led after 1 second but i have so much difficulties to do it. Please could you correct my code in the LPTMR.c part.

    #include “LPTMR.H”

    unsigned int count_val = 10000000;

    void lptmr()
    {
    SIM_SCGC5|=SIM_SCGC5_LPTMR_MASK;/* Make sure the clock to the LPTMR is enabled */
    LPTMR0_CSR=0;/* Reset LPTMR settings */
    LPTMR0_CMR = count_val;/* Set the compare value to the number of ms to delay */
    LPTMR0_PSR = LPTMR_PSR_PCS(1)|LPTMR_PSR_PBYP_MASK; /* Set up LPTMR to use 1kHz LPO with no prescaler as its clock source */
    LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;/* Start the timer */
    while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));/* Wait for counter to reach compare value */
    LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;/* Disable counter and Clear Timer Compare Flag */
    return;
    }

    With this way, don’t i have to set an IRQ ? RIght ?

    Maxime

    Like

    • New code for LPTMR.c

      /*
      * LPTMR.c
      *
      * Created on: 22 juin 2016
      * Author: Maxime
      */

      #include “LPTMR.H”

      unsigned int count_val = 0;
      int count = 1000000;
      void lptmr_init(int clock_source)
      {
      SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;

      LPTMR0_PSR = ( LPTMR_PSR_PRESCALE(0) // 0000 is div 2
      | LPTMR_PSR_PBYP_MASK // LPO feeds directly to LPT
      | LPTMR_PSR_PCS(clock_source = 0)) ; // use the choice of clock
      if (clock_source== 0)
      printf(“\n LPTMR Clock source is the MCGIRCLK \n\r”);
      if (clock_source== 1)
      printf(“\n LPTMR Clock source is the LPOCLK \n\r”);
      if (clock_source== 2)
      printf(“\n LPTMR Clock source is the ERCLK32 \n\r”);
      if (clock_source== 3)
      printf(“\n LPTMR Clock source is the OSCERCLK \n\r”);

      LPTMR0_CMR = LPTMR_CMR_COMPARE(count); //Set compare value

      LPTMR0_CSR =( LPTMR_CSR_TCF_MASK // Clear any pending interrupt
      | LPTMR_CSR_TIE_MASK // LPT interrupt enabled
      | LPTMR_CSR_TPS(0) //TMR pin select
      |!LPTMR_CSR_TPP_MASK //TMR Pin polarity
      |!LPTMR_CSR_TFC_MASK // Timer Free running counter is reset whenever TMR counter equals compare
      |!LPTMR_CSR_TMS_MASK //LPTMR0 as Timer
      );
      LPTMR0_CSR |= LPTMR_CSR_TEN_MASK; //Turn on LPT and start counting
      }

      void lptmr_isr(void)
      {

      printf(“\n****LPT ISR entered*****\r\n”);

      // enable timer
      // enable interrupts
      // clear the flag
      LPTMR0_CSR |= LPTMR_CSR_TCF_MASK; // write 1 to TCF to clear the LPT timer compare flag
      LPTMR0_CSR = ( LPTMR_CSR_TEN_MASK | LPTMR_CSR_TIE_MASK | LPTMR_CSR_TCF_MASK );

      }

      void lptmr()
      {
      SIM_SCGC5|=SIM_SCGC5_LPTMR_MASK;/* Make sure the clock to the LPTMR is enabled */
      LPTMR0_CSR=0;/* Reset LPTMR settings */
      LPTMR0_CMR = count_val;/* Set the compare value to the number of ms to delay */
      LPTMR0_PSR = LPTMR_PSR_PCS(1)|LPTMR_PSR_PBYP_MASK; /* Set up LPTMR to use 1kHz LPO with no prescaler as its clock source */
      LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;/* Start the timer */
      while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));/* Wait for counter to reach compare value */
      LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;/* Disable counter and Clear Timer Compare Flag */
      return;
      }

      Like

      • Hi Maxime,
        I’m sorry, but I simply do not have the bandwidth to check/look into that much code. If there is a single small mistake with the registers, then things won’t work. Again I recommend you look at the working code Processor Expert can generate for you. Then use that as a starting point or as inspiration point.
        I hope this helps,
        Erich

        Like

  19. Hi Erich,
    Could you please tell me how to print the value of a touch pad in the FRDM-KL05 in Code Warrier. I tried it alot usig this “Temp = tss_au16InstantSignal[n];]” and TSS1_cKey0.Position but I didn’t get the result. Please help me on this….

    Like

  20. I have tried this tutorial and I get output. But that is not I need, I want to test my touch pad of FRDM-KL05Z.
    For that I want to print the value when I touch on the touch pad in the terminal. Could you please tell me how?

    Like

  21. Hi Erich,

    How about this for a topic for a blog article?

    I am looking to implement generic USB HID functionality for the purpose of transferring configuration information over USB. USB HID offers the ability to connect without a driver having to be installed on the PC first. HID also has an advantage over USB CDC it avoids the need to go into the device manager to work out which Com port to connect to. Connecting to Generic HID devices on the PC is where the solution becomes less trivial. Some Silicon vendors have gone as far as providing a windows DLL and example applications to make things easier for customers.

    In the KSDK for K24f and K64f devices there is demonstration code for USB Generic HID device implementation, so I am looking on the NXP software pages for demo Windows PC application code that works with these HID demo’s to verify connectivity and data transfer and then integrate that functionality into a application that can send/receive data structures holding application specific information.

    I looked into the code for the new Kinetis Bootloader 2.0 that works over USB-hid to see how that is implemented and noticed it uses HIDAPI – Multi-Platform library for communication with HID devices written by Alan Ott Signal 11 Software. I had previously considered using this library so can review the bootloader and flash loader code and develop based on the principles used, this approach could take considerable time. If NXP released a simple windows demo application that works with the Generic HIS device code in KSDK2.x that would be ideal.

    Like

    • Hi Chad,
      yes, such a HID device and article is something I have in mind for a very long time. I had no immediate need for this (but it would be a great thing), but I simply did not had the time as you said this can be very, very time consuming to get it up and running. I’ll keep the generic HID topic high on my list.
      Erich

      Liked by 1 person

      • Chad,
        I modified Erich’s PEx HID Mouse Driver to work with my application in which I have two devices talking to each other. I added an endpoint so that each device can transmit packets to the other (using the control endpoint to pass data in one direction doesn’t work very well).
        I haven’t programmed my changes into PEx so what I have to do is build the application with Erich’s driver and then substitute 9 files with my modifications in the Generated_Code directory. It works pretty well.
        Greg

        Like

  22. Erich, Now I am trying to control the brightness of an LED using touch pad of FRDM-KL05Z, is there any tutorial for that, if not could you tell me how?

    Like

  23. Hi Erich,
    I’ve used the FSL_USB for a custom K22F circuit board and love it. The last time I designed a USB peripheral, I wrote my own custom stack from scratch which was a time consuming job. The FSL-USB_Stack made life soooo much easier this time around. 🙂
    I have one issue with the device descriptor and that is I’d like to set the Device Subclass to 0x02.
    I can manually edit the usb_descriptor.c, however if I or anyone in the future regenerates the Processor Expert Code, it will of course set that back to 0x00.
    Is there an easy way for me to make sure this doesn’t happen?
    The reason is this quote for Windows 10 from the Microsoft hardware Dev Center webpage (https://msdn.microsoft.com/en-us/library/windows/hardware/dn707976(v=vs.85).aspx)
    “If you want to load Usbser.sys automatically, set the class code to 02 and subclass code to 02 in the Device Descriptor. ”
    While on the subject, has anyone found any way to make Windows 8.1 accept the device as a CDC peripheral without having to use the generated cdc.inf file? Alternatively a way to make Win 8.1 use the cdc.inf without having to reboot into Advanced Startup Options, and disable Driver Signature Enforcement?
    Best Regards and thanks so much.
    Barry.

    Like

  24. Thanks Erich, awesome work. That’s perfect. When I look at the device descriptor from my Windows machine the device subclass now comes up as 0x02, which is what I set it to be . You’re a legend.
    Cheers,
    Barry.

    Like

  25. Hello,

    I have an annoying problem with the Codewarrior for Coldfire 10.6 (Eclipse on Win7).
    In my Projects I have several .cpp files and for many of them “Ctrl+O” or the Class view on the left works great (also the options while writing, giving the class member overview). But for some files I get nothing. I can compile them without errors, but thingk the parser might have some problems parsing the file. DO you have any Ideas why this could be or is there an option to “rescan/reparse” these files or find the problems the parser has?

    Any Ideas would be aprreciated.

    Regards Moritz

    Like

    • Yes, that should be possible. The difference is on the electrical side (to provide 5V power). The USB device on the JM60 is able to perform host functionality. Altough I would use the ColdFire variant for this. I have implemented a host with the V1 and V2 of the ColdFire, but not for the S08 device.

      Like

  26. Hi Erich,
    I would like some USB Stack integration advice.
    I have a requirement to use a Bare Metal K60 processor with Freescale Version 5.0 USB stack. I want to have USB device functionality for a Virtual COM port running over the USB0 and USB Flash drive connecting to the USB Host interface running with an external ULPI transceiver chip.
    Ideally I was looking for an available KDS Processor Expert component but most examples seem to use the Legacy Version 4.1.1 USB Stack.
    Can you point me at any relevant references/examples please using Version 5.0 USB stack?

    Like

    • Hi Les,
      there is no Processor Expert for USB and V5.0 to my knowledge. Even my 4.1.1 USB stack is newer than anything else available. I have not really looked at the 5.0 stack because the 4.1.1 was working fine for me.
      You might have better luck if you look at the USB stack inside the Kinetis SDK V2.0 (but it does not have Processor Expert).
      Erich

      Like

  27. HI Erich,
    Thanks for quick response.
    NXP are telling me that the USB stack that comes with the KDS SDK is a “unified” stack with inputs from all previous years so hence my decision to port the Version 5.0 stack.
    We are trying to achieve USB functionality that utilises the K60 USB0 interface as a Virtual COM USB device together with simultaneously interfacing the K60 with an external UPLI transceiver to provide USB Host functionality for a memory stick component.
    Is this possible with a single USB stack configuration?
    Les L.

    Like

    • Hi Les,
      yes, that USB stack has been completely rewritten, and apart of using it in the provided examples, I have not used it in any production systems. Simply because the 4.1.1 worked very well (I’m using CDC, HID keyboard and mouse and MSD).
      So I don’t know if that 5.0 is able to do what you need.

      Like

  28. Hi
    I am using CW10.7 and the FRDM-KL25Z.
    I am trying (unsuccessfully) to implement your example of “Using the FRDM-KL25Z as USB Keyboard”.
    The first thing I noticed is that in the Component Inspector for USB1:FSL_USB_Stack

    Component name USB1
    Freescale USB Stack Version v4.1.1
    SDK KSDK1

    whereas in your example it shows

    Component name USB1
    Freescale USB Stack Version v4.1.1
    USB Init_USB_OTG_VAR0

    Is this because I am using the FSL_USB_Stack component as it came with CW10.7 and not your version of it.
    I am also not sure where to get the latest version.

    Just to let you know, I am actually trying to connect a barcode reader (instead of the keyboard) to the Freedom board. I am going to use the “USB Host Mode Hack for the Freedom KL25Z Board” to provide power to the barcode reader.
    I hope it works.
    Thanks
    Eli Naiman

    Like

    • Hi Eli,
      the components are available on SourceForge, see https://mcuoneclipse.com/2014/10/21/mcuoneclipse-releases-on-sourceforge/. These components do not come with CodeWarrior, you have to install them from SourceForge. For me, the supplied USB components by Freescale had to many issues, so I developed my own version of it. From the time I wrote that tutorial, several things have been changed a little. I recommend you load and try the latest project for CodeWarrior from GitHub, located in https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/CodeWarrior/FRDM-KL25Z/Freedom_USB_HID_Kbd.
      As for your project:
      a) you very likely will not be able to power a barcode reader that way, so you will risk destroying the FRDM board if you draw too much current. Definitely not recommended that way! You need a proper power supply.
      b) In my example the FRDM board is a USB HID *device*, and not the USB *host*. Your reader very likely is a *device* too, so you cannot connect two devices that way. You would need first to implement a USB CDC *host* stack on the FRDM-KL25Z.
      I hope this helps and helps you that you don’t damage your board.

      Like

  29. Hi Erich – not your problem I know, but I have a tricky problem with a KM14 processor resetting when I try to erase a flash sector. Documented here: https://community.nxp.com/message/843354

    Any tips appreciated.

    FYI, although the KM34 and KM14 are not supported by Processor Expert, I have found that I can build PE components for a KL15 processor and import the .c and .h files from the PE Generated_Code directory into a KM14 Bare Metal Drivers project, and so use the PE functionality. In some cases the porting work involves only fixing up .h file references, though in other case (e.g. serial ports) more work is required as the hardware is different.

    Like

    • Hi Charles,
      I have not used the microcontroller. I recommend that you have a look at the flash block size and boundaries. I had some strange resets on other parts if the flash blocks I wanted to write to were not aligned (1k, 2k, 4k, 8k, depending on the flash on the device).
      I hope this helps,
      Erich

      Like

      • It turns out to be an interrupt issue: it turns out that taskDISABLE_INTERRUPTS() prior to the critical code did not disable them – I have to use DisableInterrupts() instead. More details at the NXP link. Perhaps a footnote in your recent FreeRTOS interrupts blog?

        Like

        • Hi Charles,
          I have posted a question on the FreeRTOS forum. Indeed on M4 it does not mask all interrupts (it does on the M0+ ports I’m aware of). In my article about FreeRTOS and Cortex interrupts I have mentioned that current implementation already (that it does not mask all interrupts on M4). But to me the description on the website is not matching the implementation. So not sure if the implementation is wrong or the documentation?

          Like

      • Tracing through the PE and KM34 Bare Metal Drivers freertos_config.h files, I think (though you might check) that in PE taskDISABLE_INTERRUPTS() results in a “cpsid i” instruction that disables (all) interrupts, but in the KM34 Bare Metal drivers taskDISABLE_INTERRUPTS() results in *(portNVIC_ICER) = configSYSCALL_INTERRUPT_MASK (disable interrupts on a case-by-case basis). By default configSYSCALL_INTERRUPT_MASK = 0, so no interrupts are disabled.

        The concealed comment says:
        /* The configSYSCALL_INTERRUPT_MASK defines masks of all interrupts that call */
        /* FreeRTOS API functions. Select zero or one or more OR’ed interrupt masks: */

        In other words they suggest users set a value for configSYSCALL_INTERRUPT_MASK but the default is
        “don’t disable any interrupts”. You can see an explanation for this in the NXP thread. Grrrr.

        Like

        • Hi Charles,
          yes, in the FreeRTOS port (generated by Processor Expert and the others I’m using), on ARM Cortex-M0(+) taskDISABLE_INTERRUPTS disable all interrupts (cpsid i), while on ARM Cortex-M3/M4/M7 interrupts are only disabled up to configSYSCALL_INTERRUPT_MASK. I don’t have a KM34, but from the documentation this is an ARM Cortex-M0+, so interrupts shall be disabled with cpsid i. If NXP changed that (for whatever reason?), then in my view this would be simply wrong and dangerous.

          Like

  30. Pingback: McuOnEclipse Components: 30-Oct-2016 Release | MCU on Eclipse

  31. Hi Erich,
    I’m having a problem with startup of a K40DN512 processor.
    I use Processor Expert to initialize the CPU. It is clocked with a 4 MHz external crystal.
    With the debugger the program always starts up normally.
    When I remove the debugger the processor starts running intermittently.
    The reset button, hardwired to the reset pin on the processor, can have no effect.
    Powering down and then powering up can get the processor running.
    I’ve tried about 25 boards made with this processor and they vary with their ease of startup.
    Some start running right away when powered up.
    Others can take many power cycles before they start running.
    I’m not sure what causes the difference, but I wonder if it is something in the Processor Expert initialization that needs to be changed?
    Thanks,
    Greg

    Like

    • Hi Greg,
      with ‘debugger removed’ you mean that you have the debug cable removed? This sounds like an electrical problem to me, as the debug cable provides GND and senses the 3.3V. Maybe your board power supply is not stable or has other issues?
      I hope this helps,
      Erich

      Like

  32. Erich, your pages are very helpful! We are hitting a lot of issues with the tools, particularly KDS on the KL02z. Could you please add a bit of detail on each page specifying the *version* of tools that you are using? For example, you used the stock tools on this page: https://mcuoneclipse.com/2015/04/18/uart-with-the-frdm-kl02z-board/
    But you cannot build a KL02z project using the current stock tools (PE Micro) now, as its broken for the KL02 (Q3 2016). You have to use the USB-DM debugger. Or go back to older versions of KDS. How far back we aren’t sure, but will know with enough trial and error….

    Like

    • Hi Brian,
      Usually I’m using the latest and greatest versions at the time when I write things up. I need to see how I could report the versions I’m using. This might get be difficult to which extend. Unfortunately there are many different components and version numbers included. I quickly tried that example project on my FRDM-KL02Z and it works fine, using the P&E 2.6.0.20161006322 version. I’m right now checking if there is a newer version.
      PS: this discussion might be better placed on https://mcuoneclipse.com/2015/04/18/uart-with-the-frdm-kl02z-board/, but I cannot move it. So if you have any follow-ups, can you post it there?

      Like

  33. Hi Erich,
    I’m finding I need flow control for the USB CDC, as the PC is sending data too fast for my board to deal with and I’m losing lots of bytes. Just FYI, the MCU itself isn’t actually the problem, it’s that the data is being used to flash the memory in a peripheral attached to the MCU, and the flash operations are relatively slow. Is there any example of implementing flow control with The USB CDC such as emulating RTS/CTS for the virtual COM port?
    Thanks in advance for any advice.

    Like

    • Hi Barry,
      I have not used flow control with USB CDC. I’m just aware that using it (or not using, that depends) might be a problem on the host.
      I saw some forum comments on that subject, and I believe the Freescale/NXP USB stack (at least the 4.x I’m using) does not properly implement it.
      I would recommend that you look at the NXP Kinetis SDK USB stack as this one could have it implemented.

      Like

  34. Hi Erich,

    I am sure you have plenty of things to keep you busy, but here is something that I would find interesting. I would like to integrate some assembly code, written using the ARM Thumb instruction set, into a regular c function using Kinetis Design Studio. The code is an optimised CRC16 routine (here http://oneweekwonder.blogspot.com.au/2015/11/parallel-crc16-collection-3.html). Google doesn’t offer me much useful information. Is this something you might be able to provide some hints for ?

    thanks
    Geoff

    Like

  35. Hi Erich

    I have a project with KL25Z and SDK V2; i need suport from uSD over SPI and FATfs. CAn you tell me how can I write the functions required by FATfs and what consideration I must have?

    Best Regards

    Like

  36. Hi Erich,
    I thought I had already posted this, but it seems to have vanished into a cyber void.
    Anyway, I need to handle the case in the FSL_USB stack for SET_LINE_CODING
    When the host changes the baud for the virtual com port, USB_Other_Requests() in usb_cdc.c fires but I need to break out to my own handler so I can change the parameters on the K22 Uart to match. Essentially I need to emulate a proper USB -> Serial converter.
    Right now I’m putting a callback to my code after case SET_LINE_CODING:
    That all works fine but I will lose it every time I regenerate the processor expert code of course.
    Is there any clean way to do this where I don’t have to remember to make those changes every time usb_cdc.c is regenerated?
    Best Regards,
    Barry.

    Like

  37. Hi Erich,
    Thanks for the reply.
    What I’ve done is a bit of hackery to suit my needs. I’m happy to share but it was quite basic:
    I just added my own callback in usb_cdc.c like so:
    case SET_LINE_CODING :
    status = USB_Class_CDC_PSTN_Set_Line_Coding(controller_ID,
    setup_packet, data, size);
    USB_Set_Line_CodingCallback(controller_ID);
    break;

    Then in my USB_Set_Line_CodingCallback() function I get the new port params like so:
    USB_Desc_Get_Line_Coding()
    Voila : I have everything I need to set the K22 serial port to the correct Baud etc.

    What would really suit me, and allow others to expand request handling to suit their needs would be to remove the “static” from the callback function pointers in usb_function.c so I could “extern” them i.e.
    USB_CLASS_CALLBACK g_framework_callback=NULL;
    /* Other Requests Callback pointer */
    USB_REQ_FUNC g_other_req_callback=NULL;

    From a neater API standpoint, simply adding some Get() and Set() functions for those pointers would be more socially acceptable I suspect 🙂
    That way I could choose to override the handling for whatever requests I wanted to, then call the generated callbacks to handle the rest.

    Like

  38. Hi Erich,
    Would you mind looking at this thread:
    https://community.nxp.com/message/849820?commentID=849820#comment-849820
    Ignore most of the remaining posts because someone else popped in and hijacked the thread.

    I posted that on Nov 1 after I started getting the error on the KL25_CPU. As my post stated I was able to manually make a change to CPU.c to enable the watchdog since that source file was no longer updating. Fast forward to today (Nov 10). Over the last 9 days I have made more code changes but when I went to compile it threw an error because it could not find CPU.h. When I looked in the Generated Code folder CPU.c and CPU.h are gone. I have tried making changes to the component and I also went in the Hardware Perspective and changed the CPU and clicke Generate Code to no avail. Is this a PE issue? Any ideas on how to get it to re-generate CPU.c and CPU.h again?
    Thanks

    Like

    • Hi Simon,
      I have to check our project (but it is getting late night here, so probably tomorrow). But that message “Generator: FAILURE: Unexpected status of script:” clearly is a bug of Processor Expert: it bascially means that the internal Processor Expert script somehow fails.

      Like

    • Hi Simon,
      I have checked your project, and took me a while to find out what is going on. Such a “Generator: FAILURE: Unexpected status of script:” message is an internal assertion in the code generation script and shall not happen. To me, this is clearly a bug in the script. I have responded to the Community thread with my findings: basically the problem happens with the Init_UART component if there are different interrupt priorities assigned for the Rx/Tx and error interrupt. You had this in two Init_UART component settings. When I used the same priority levels, the error was going away.
      I hope this helps you to continue your project,
      Erich

      Like

      • Hi Erich,
        I was aware of the I2C issue. They both seem to working just fine for many months now. The sensors are read every 100mS. I have the pre-scaler set to 1. I thought that was the item required or am I missing something else?
        Thanks.

        Like

        • Hi Simon,
          yes, you have to set the prescaler to 1. I just saw a warning from Processor Expert about it, so I thought that the setting might be wrong. Sounds like you have everything under control now :-).
          Is the fix I have provided for you working?
          Erich

          Like

  39. I posted an updated ZIP on the NXP thread. I still have the issue of CPU.C and CPU.H no longer generated and no longer there.
    Thanks

    Like

    • Hi Simon,
      because you have renamed your CPU component to KL25_CPU, the generated files for it are KL25_CPU.c and KL25_CPU.h, and not just CPU.h. The names of the source files generated are based on the name you give for the component.
      Probably you have not realized that?
      I hope this helps,
      Erich

      Like

  40. Pingback: Thank You for Commenting, Thoughts and Feedback! | MCU on Eclipse

  41. I guess when I replaced the KL25 component trying to fix the original error I must have changed the name. Thanks for your help.

    Like

  42. Hiya ,
    I am a newbie just started basics in FRDM-KL25Z, I need to learn more. For now, I got a task to do. I have somehow took some codes from different sources and trying to complete it. What happening is now I can flash it and when I type in terminal , I gets it as echoing but led doesnt works. I tried with single keystokes like press “r” or “g”. That works fine. but when it comes to array, i just tried giving value manually to loops, it works but when I try to get it using keystokes, echoing alone works but nothing else. My Task is as follows which is followed by my code.
    I use uvision to code, the below is the only logic way I can understand since I am a newbie, so I expect to get a reply likewise. thanks.

    Task => Controlling LED from a PC via the UART0 over USB
    The FRDM KL25L board is able to receive and determine the following commands and take appropriate actions to control the LED accordingly:

    Command string Actions to be done
    g onrn Turn on the green LED
    g offrn Turn off the green LED
    r onrn Turn on the red LED
    r offrn Turn off the red LED
    b onrn Turn on the blue LED
    b offrn Turn off the blue LED
    a onrn Turn on the LED with amber colour
    a offrn Turn off the LED with amber colour

    My Code:

    #include

    void UART0_init(void);
    void delayMs(int n);
    void LED_flash(char val);

    int main (void) {
    char c;
    char msg[] = “Hello World!rn”;
    char buf[9];
    int i;

    UART0_init();

    for (i = 0; i S1 & 0x80)) { } /* wait for transmit buffer empty */
    UART0->D = msg[i]; /* send a char */
    }
    delayMs(10); /* leave a gap between messages */

    while (1) {

    for ( i = 0; i S1 & 0x20)) {
    } /* wait for receive buffer full */
    buf[i] = UART0->D ; /* read the char received */

    while(!(UART0->S1 & 0x80)) {
    } /* wait for transmit buffer empty */
    UART0->D = buf[i]; /* send the char received */

    if (buf[i] == ‘r’ || buf[i] == ‘n’)
    {
    if(buf[0] == ‘r’ && buf[1] == ‘ ‘ && buf[2] == ‘o’ && buf[3] == ‘n’)
    {
    LED_flash (‘r’);
    }
    else if(buf[0] == ‘g’ && buf[1] == ‘ ‘ && buf[2] == ‘o’ && buf[3] == ‘n’)
    {
    LED_flash (‘g’);
    }
    else if(buf[0] == ‘b’ && buf[1] == ‘ ‘ && buf[2] == ‘o’ && buf[3] == ‘n’)
    {
    LED_flash (‘b’);
    }
    else if (buf[0] == ‘a’ && buf[1] == ‘ ‘ && buf[2] == ‘o’ && buf[3] == ‘n’)
    {
    LED_flash (‘a’);
    }
    break;
    }

    }
    }
    }

    /* initialize UART2 to transmit and receive at 9600 Baud */
    void UART0_init(void) {
    SIM->SCGC4 |= 0x0400; /* enable clock for UART0 */
    SIM->SOPT2 |= 0x04000000; /* use FLL output for UART Baud rate generator */
    UART0->C2 = 0; /* turn off UART0 while changing configurations */
    UART0->BDH = 0x00;
    UART0->BDL = 0x17; /* 57600 Baud */
    UART0->C4 = 0x0F; /* Over Sampling Ratio 16 */
    UART0->C1 = 0x00; /* normal 8-bit, no parity */
    UART0->C3 = 0x00; /* no fault interrupt */
    // UART0->C2 = 0x08; /* enable transmit */
    // UART0->C2 = 0x04; /* enable receive */
    UART0->C2 = 0x0C; // enable Tx and Rx

    SIM->SCGC5 |= 0x0200; /* enable clock for PORTA */
    PORTA->PCR[2] = 0x0200; /* make PTA2 UART0_Tx pin */
    PORTA->PCR[1] = 0x0200; /* make PTA1 UART0_Rx pin */

    }

    void LED_flash(char val)
    {
    if (val == ‘r’)
    {
    PTB->PSOR = 0x80000; /*green off */
    PTB->PSOR = 0x40000; /* red off */
    PTD->PSOR = 0x02; /* turn off blue LED */
    PTB->PCOR |= 0x40000; /* turn on red LED */
    }
    else if (val == ‘g’)
    {
    PTB->PSOR = 0x80000; /*green off */
    PTB->PSOR = 0x40000; /* red off */
    PTD->PSOR = 0x02; /* turn off blue LED */
    PTB->PCOR |= 0x80000; /* turn on green LED */
    }
    else if (val == ‘b’)
    {
    PTB->PSOR = 0x80000; /*green off */
    PTB->PSOR = 0x40000; /* red off */
    PTD->PSOR = 0x02; /* turn off blue LED */
    PTD->PCOR |= 0x02; /* turn on blue LED */
    }
    else
    {
    PTB->PSOR = 0x80000; /*green off */
    PTB->PSOR = 0x40000; /* red off */
    PTD->PSOR = 0x02; /* turn off blue LED */
    PTB->PCOR = 0x40000;
    }
    }

    /* Delay n milliseconds */
    /* The CPU core clock is set to MCGFLLCLK at 41.94 MHz in SystemInit(). */

    void delayMs(int n) {
    int i;
    int j;
    for(i = 0 ; i < n; i++)
    for (j = 0; j < 7000; j++) {}
    }

    Like

    • I recommend that you use the debugger to see what is going on. I think your problem is that you are not fast enough with polling to get the characters if they are sent together.
      Use an interrupt with a ring buffer instead. Have a look at how the Processor Expert AsynchroSerial component is doing it, it uses a ring buffer filled from the UART interrupt handler.
      I hope this helps,
      Erich

      Liked by 1 person

      • since I tooo newbie, I didnt understand anything. Anyway thank you so much for the reply. Could to send me any link to study in detail about programming in FRDM-KL25Z without processor expert and all.

        Like

        • As a newby, I highly recommend that you use Processor Expert: it makes things a lot easier for you, and that way you don’t make mistakes with the microcontroller peripheral registers.
          Otherwise you have to read thousands of PDF pages about the KL25Z to fully understand that device. Just my 1$.
          And the first thing you have to use is the debugger: just programming, downloading and see if it goes won’t get you far: debug the code and step through it to see what happens.
          Good luck!

          Like

  43. Hi Erich.

    First of all, I’d like to to thank you for all your very informative regarding Kinetis design studio. MCU on Eclipse is a resource unlike any other.

    I have a question for you however: What is the “normal” tool chain you use for building and compiling projects? I understand you use a variety of IDE’s including Kinetis, but I want to know if you use the GCC tools or the KEIL tools or the IAR tools and which you prefer.

    Thanks,

    James

    Like

    • Hi James,
      I’m mostly using Eclipse based IDE’s (99%), e.g. for NXP Kinetis the Kinetis Design Studio (free and unlimited, and I can build that one myself too, see https://mcuoneclipse.com/2013/07/20/dyi-free-toolchain-for-kinetis-part-1-gnu-arm-build-tools/). I’m using Keil and IAR only sporadically (free/code size limited) edition in case someone reports a problem for my component source code for these IDEs. These days everyone seems to have settled on Eclipse as the IDE standard. There are multiple different vendors providing their own Eclipse based solutions. The Eclipse knowledge then can be easily applied to other vendor and tools. There has been a reason in the past using proprietary Keil and IAR tools mainly for code size reasons (the key selling point of these tools are the compiler). However, with GNU gcc and especially LLVM getting better and better, that advantage already is very much gone in my view. At the end if drills down how much money you can (and want) to spend, and what you really need, and how much indepenence is required.
      I hope this helps,
      Erich

      Like

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

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

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

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

    Thanks,
    Greg

    Like

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

      And you can affect the code generation. First you can disable code generation for a component (see https://mcuoneclipse.com/2012/03/23/disable-my-code-generation/). Second you can directly change the code base used for the code generation, you only need to find out where the component sources are (see https://mcuoneclipse.com/2012/06/30/cde-hacking-where-is-my-stuff-a-dissection/). In my case the USB stack sources are in C:\ProgramData\Processor Expert\PEXDRV_PE5_3\Drivers\FSL_USB_Stack. So you could directly modify the sources there if you want.

      I hope this helps,
      Erich

      Like

      • Erich,

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

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

        Greg

        Like

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

          Like

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

    Alex.

    Like

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

      Like

  46. Hi Erich
    I am trying to communicate between FRDM-K64F and JY-MCU V1.06. I read your article about a pull-up resistor on the RX line that has to be pulled up. I am using KDS and processor expert. It wont allow me to enable the pull-up. CodeWarrior does allow. Does the Bluetooth_EGBT component do it?
    Is there an example I can follow.
    Also what is the advantage of using the Shell component?
    Thanks
    Eli

    Like

  47. Hi again
    Your program FRDM-K64F_Demo does communication between FRDM-K64F and JY-MCU V1.06.
    I think the download from GitHub needs to be run with Eclipse Kepler.
    What has to be done to compile it with KDS.

    Like

    • I’m using it in several projects with KDS, but probably have not published one of these projects.
      But simply create a new Processor Expert project with KDS, and add the bluetooth component to it and configure it for the UART you are using.

      Like

  48. Hi Erich
    I am trying to create a FreeRTOS project that has 3 tasks. If I enable 1 task it works. 2 or more tasks and it does not work. What am I doing wrong.
    I uploaded the project to GitHub under the name FreeRTOS example. (I think it is there)
    As always, your help is greatly appreciated.

    Like

    • Hi Eli,
      where did you upload it on GitHub?
      Have you checked your heap size (or checked the application in the debugger). I think your heap size is too small so you run into the ‘out of memory’ FreeRTOS hook.
      Erich

      Like

  49. The project is on GitHub at EliNaiman/FreeRTOS-example
    My code does not allocate any memory.
    Once it is working, this should be an example for beginners like me.

    Like

  50. Hi Erich
    In the FreeRTOS-example that is working, I added the following lines in main.c just before going to Run_Applications();

    /* pull up Rx pin (PTC14) for Bluetooth module */
    PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 14, PORT_PDD_PULL_UP);
    PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 14, PORT_PDD_PULL_ENABLE);

    The system hangs. I think it is causing an interrupt to occur. How do I take care of this.
    I am using the K64F.

    Like

  51. Hi Erich
    I have a question about Bluetooth. I am using the K64F with HC-05 as master and I am communicating with an android tablet.
    If the two are not paired, I use the LINK command, I get a prompt on the tablet to enter a passkey and the two are paired and I am able to send messages back and forth.

    I then turn off the power and then turn on the power on the K64F, I would like the two to reconnect without the prompt. How do I do that?
    As always, I truly appreciate your help.
    Eli

    Like

  52. Hi Erich,

    I am interested in the one-wire library but to use on an ESP32 platform with FreeRTOS.
    I looked at the github repository as well as on sourceforge but could not find the “normal” source code files.

    Any hints where I must look?

    Thanks

    Like

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

  54. Hi Eric

    A second question please… I over looked. What would be the starting point to get the IDE working? I have KDS installed but also Atollic and would like to use Atollic if possible. Is there a guide to follow to install all the bits and pieces? It used to be a lot of loading of modules into eclipse and I am not sure I remember the steps. I tried to use KDS V3.2 recently with another group and we could not even read the registers of the core peripherals. We tried various google suggestions but failed so we used IAR instead. But I realize eclipse is the key requirement for starting with PE and following your teachings so that is where I want to begin. Thanks again.

    Robert

    Like

  55. Hi Erich!
    I’ve beeing reading your stuff and it’s wonderful what you’ve done here…
    I’m new in this story of embedded system… but I’m enjoying about it in your website.
    I want to use event counter in KL25z, but I always fall into a Cpu_ISR, It looks like int cannot convert some value and stop there.
    Can you please publish a post about event counter. to count external event?

    Thank you!

    Like

  56. Hi Erich,
    I am doing my Master thesis at Lund University, Sweden. I need to design a debugger for a customized Processor. I know what all the things i need to do at the hardware part. But coming to software part i came to know that i need to use GDB and OpenOCD. I am unable to find the design information about these debuggers and what all changes i need to do in them so that i can debug my processor. If you can help me to know about these debuggers in detail will be helpful for my thesis.

    Thank you!
    Dinesh

    Like

      • Hi Erich,
        Thank you so much for the reply.

        I can explain you my thesis in detail.
        I am doing my thesis at a company. They have a customized Processor built on their own. They want me to develop a debugger for that processor. I have implemented Jtag to AHB which connects to the processor. This is on the Hardware part.

        I am using Bus blaster from Dangerous Prototypes to debug this Processor and this Bus blaster uses GDB,OpenOCD and Telnet. In my research i understood that this OpenOCD is compatible to only MIPS and ARM Processor’s. Now i need to make their customized processor also compatible to this OpenOCD. I am stuck at this point. I don’t know what all changes i need to do in these debuggers so that these are compatible with that processor. Most of the sites are explaining oh how to use but not how to add a New target to these debuggers.

        My questions is Do you know how to add a New Target to GDB and OpenOCD debuggers?

        Like

        • I’m affraid that I don’t know that level of details. In any case, as long as your processor uses the standard JTAG access method, you don’t have to change OpenOCD itself. All what you have to do is to add the flash programming and low level register access to it. On the GDB side you should not have to do much (if anything), as this should be handled by the plugin. However, as you have a custom processor with a different instruction sets, you would have to add that to GDB, but I would have to dig into details for this first, but I doubt I won’t be able to do this in the near term.

          Liked by 1 person

  57. Dinesh, how much work you have to do depends on your definition of “custom processor”.
    If their processor is a custom part built around a stock ARM Core, then its not really custom, only the peripherals are.
    But if the core itself is custom (running its own instruction set) then you have a big job.
    I suspect its the former.
    In which case you need to make sure that the registers in the processor that identify the specific ARM Core are presenting that data correctly. Then the debugger should adapt. You may have to select the core when configuring GDB as well.
    That’s my 2 cents.

    Liked by 1 person

  58. Hi Erich,

    I am trying to port code written for stm32f10 MCU in the IAR embedded workbench to codeblocks that has GCC. Could you help me with the same? I do not seem to find a free plugin for the same.

    Thanks,
    Aakash

    Like

  59. Hi Erich,
    I have a K64F with an HC-05 module communicating to a tablet via Bluetooth. The HC-05 is a MASTER and the tablet is a SLAVE. (working great)

    If the slave shuts down, how can I detect that on the K64F when the HC-05 is in automatic connection work mode.

    Thanks
    Eli

    Like

  60. Hi again
    I found the solution. The STATE pin on the HC-05 goes LOW when the slave disconnects.

    I now have to figure out what to do when the slave starts up again.

    Thanks
    Eli

    Like

  61. hi erich, im making a car with navegation per compass and i would know ,how set up the component MAG3110 is a magnetometer and i need the information of cardinal point for be guided per bluetooth for example i send that the car go 5 meter south , 2 noth etc

    Like

    • My feedback is that this will be very hard to accomplish unless you have an absolute position sensor. The compass alone will not help you to reach that goal as it will not be accurate enough.

      Like

      • Yes, but I know it will not be so accurate because it is for practical purposes only demonstration or with you recommend me to do? There is another component that I can use besides the mag3110 but I would still like to know if you can help me to configure this component.

        Like

      • But the compass I only need it to indicate the points and with the programming, with the variations that the compass can make in those points as a starting point to say so.

        Like

      • ok im read the information but can you say me ?whats device or component or sensor can i use for this project i was thinking in giroscope but is there any way to do something similar.

        Like

        • As I don’t know your requirements, I only can give a very generic advice. If you want to move on the ground something to an absolute position, you need an absolute position sensor. Accerlerometer and Gyros will give you only relative information. Due the nature of intergration, you are inherently accumulating the errors: the more error and the more time, the bigger the delta. You can reduce the error with better sensors, sensor fusion and with using an absolute reference point.

          Like

        • A GPS module and antennae is well under US$10 in modest volume. (like 1k)
          If you use a board-mount antennae, then balancing the load, or signal matching, can take a few weeks (we’ve done that). But if you just run to an SMA-A connector (and feed your 3.3v supply through a ferrite to the antennae signal to power an “Active Antennae”) then its easy.

          We use Venus modules from SkyTraq in Taiwan. It has the receiver, LNA, crystal, and passives all in one device that looks like a plain chip. There is a breakout board with the module mounted available for $50- online @ Q=1 from … SparkFun, I think (googling) here it is:
          https://www.sparkfun.com/products/11058

          connect the antennae, apply power, and seconds later the Serial TX pin will start pumping out an NMEA message @ 9600 baud exactly once-per-second. You don’t have to do a thing.
          Message has lattitude, longitude, altitude, and ground-speed IIRC.
          And its all plain ASCII text, readable, with a CR at the end of each line.
          As my buddies from Hong Kong would say: “Piece of cake, man!”

          Like

      • yes, But what would be that sensor to achieve that absolute position would be the accelerometer or the gisroscope?

        Like

      • Excuse me, I better have to ask what sensor I can use to achieve the absolute position or no solution

        Like

        • if you have minimal or no slippage, use an high resolution quadrature encoder for the wheels. In addition to that, use an absolute distance sensor to a known reference point. Outdoor, you could use a GNSS or referential GNSS system. You could use a laser scanner or ToF sensors. It really depends on you requirements: how accurate, for how long, etc.

          Like

      • maybe for 10 or 20 minute but is there a form for save the moves in the area for example the first move or that you propose

        Like

      • hi erich, i managed to configure the componet mag3110 and investigating from there i found that magnetic field of the motors can be isolated but when i try the sensor it does not give me any value or any thing i only have the freescale connected only and still does not give me a value of anything

        Like

  62. Hi Erich,
    I have a doubt in the Hardware Breakpoints. While i am implementing the Hardware Breakpoint i came across the address comparison. The address where you want to put a break point will compare with the PC and if both are equal then it is a Break point.

    Is this the only way to implement hardware break point or there are any other ways to implement hardware break point at the RTL level.

    Regards,
    Dinesh

    Like

        • I’m not sure if I can (or even should) give you an advise on such a general question? The thing is that designing a debug architecture in a processor is for sure not a simple thing. Think about bus access, propagation delays, possible caches and other impacts.

          Like

        • Dinesh, take a look at some of the open-source processors, such as the H32 and see if they have the debug features that you need. You should be able to “borrow” the features that you need from another completed, fully debugged, project. And then (ideally) use their GDB drivers and interface as well.

          Liked by 1 person

  63. Erich,

    Thank you so much for the time you have invested in making these processor expert components so useful and easy to use! I’m currently working on an older project that uses the USB CDC Device component version 1.045. I’m wanting to update the components in my project to the most up to date version released. My problem comes with the shell and xformat components that must be added to the project. I want to make sure that I’m not using any flash/ram for components that I do not plan on using. Is there an option I can use to disable the shell/xformat? Thanks in advance!

    Like

    • Hi Ryan,
      thanks 🙂 !
      There is no impact on RAM and Flash size if you add these two components, as long as you are not going to use the Shell or its functions. The reason why the Shell and Xformat components are referenced is because most users want to use the USB CDC with the Shell, and that way it is more easier and simpler to use it. Otherwise, the linker will remove any not used function or variable so there is not impact for you.
      I hope this helps,
      Erich

      Like

  64. Hi Eric,
    I have been reading your post on “Tutorial: Secure TLS Communication with MQTT using mbedTLS on top of lwip” . Its nice to see a port to a embedded processor and an example where someone actually works though the example. I have struggled to find any real examples on porting the mbed tls code to embedded processors and those running an rtos. The folks at ARM just say its light weight open source configurable library and have no real examples. You ever considered porting to another processor family like renesas synergy or doing an example of connecting to something like amazon or google cloud services?
    Thanks
    Matt

    Like

    • Hi Matt,
      I’m using that library connecting to Azure and MQTT brokers (several providers). I have not used Amazon or the Google could services yet, or using it with a different processor. I would love to do it, but my time is limited, and what I have to direct my time to is guided by what we get funding for at the university, and Renesas did not provide any (yet?) ;-).

      Like

      • Hi Erich,
        Yeah I know what you mean by limited time and funding. I would love to see an example that is more processor independent but understand getting the bills paid. Ill keep and eye on your posts and examples. I like what you do. Take care.
        Thanks
        Matt

        Like

  65. Hi Erich,

    We need to find good “hands on” training for an IDE such as MCUXpresso or CodeWarrior for a project using the MK10DX128VLQ10. Don’t care which IDE at this point as NXP support for MCUXpresso is almost nonexistent and an extensive search for training has turned up nothing in North America! Not interested in a “bucket” of incoherent poorly orchestrated tutorials. Have been trying to build a bare metal project based on a system I built 10 years ago using CodeWarrior, using both the MCUXpresso IDE and Configuration Tools only to find the config tools “project” cannot be imported into the IDE? Kevin Meyer at PEMicro was kind enough to spend a hour of his time to try and get the IDE to talk to my PCB only to find several “bugs” with the MCUXpresso IDE within the first 10 minutes. The MK10DX128VLQ10 apparently will not be supporter in CodeWarrior going forward?

    Please advise.

    Thanks,
    Mike

    Like

    • Hi Mike,
      I have not used any K10 in my projects, so I cannot comment much about this device, so not sure what problems you have faced. Usually connecting with P&E debug probes has been rock solid for me, unless I had an issue with the hardware/board itself. I see that the MK10DX128VLQ10 is supported in CodeWarrior, and it even has Processor Expert support :-). So it is supported in CodeWarrior. However, as pointed out in my blog, NXP does not plan to invest in CodeWarrior and Processor Expert, and everything going forward is with the MCUXpresso IDE, the MCUXpresso Configuration tools and the MCUXpresso SDK.
      About importing the configuration tool projects: at least currently, the tool generates sources files which then can be used by any IDE. I have used that approach (see https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/) and that worked for me. I’m sure there might be some closer intergration coming.
      Speaking about ‘hands on’ trainings: That’s what my students get here at the Lucerne University :-). I have created in the past trainings for external university partners or companies as a service. The challenge is that usually it cannot be a kined of ‘canned’ training, as every user/company needs special things. And the tools landscape is changing so fast (new Eclipse version, new features, …) that makes it hard to update things (or have paid for it). For more general tutorials I have decided to put things up on this blog which seems a good way. If you have any other suggestions or ideas, please let me know.

      Thanks!
      Erich

      Like

  66. Hello Erich,

    I am working on porting code from IAR EWARM to Atollic Truestudio (based on GNU ARM toolchain and Eclipse IDE) for STM32F103RD microcontroller. I have a few questions regarding porting of __ramfunc (IAR extension) to Atollic.
    I have added __attribute__((section(“.RAMFN”))) to all function prototypes and definitions that need to be run out of RAM and modified the linker script to
    { . = ALIGN(4); _sdata = .; /* create a global symbol at data start */ *(.data) /* .data sections */
    *(.data*) /* .data* sections */
    . = ALIGN(4);
    _ramfn_start = .;
    *(.RAMFN)
    *(.RAMFN*)
    _ramfn_end = .;
    _edata = .; /* define a global symbol at data end */
    } >RAM AT> FLASH
    However, I am not sure if/how the startup file needs to be modified to complete this port. It would be great if you could help me with this issue.

    Thanks,
    Aakash

    Like

  67. Hi Erich
    I enjoyed your description of the hike in the Dolomites. I hike too but here in Toronto we do not have mountains like the Alps. Nevertheless, it is still beautiful and rewarding to spend a day with nature.

    I want to report some finding. I am using the K64F and I have read that J2-18 and J2-20 are mixed up.

    I wanted to use one of them to drive a relay.
    When using J2-18 as an output line, on start up there is a pulse on the line and this activated the relay prematurely. Doing the exact same thing on J2-6 there is no pulse.
    I hope this could help someone trying to use J2-18.
    Eli

    Like

      • Erich is right, but its a bit trickier.
        The start bit is a 0.
        Then there is typically 8 data (and with no parity) a stop-bit = 1
        But you don’t know what’s coming between.
        If you get an odd number, then the bit after the start is 1, so you can measure the start-bit width to get the bit period.
        But if you receive “0”, then you have 9 bits in a row that are low (start plus data) … so its more complicated.
        Basically, you have to measure the time between transitions.
        Using those (and optionally the differences) you can find the narrowest, and that gives you the bit period.
        Some protocols have addressed this explicitly in order to build adaptive systems.
        The CAN bus in a car operates on a fixed clock, and micros on the bus needed a real crystal (before the days of internal clocks that are lazer tweaked on the production line) to communicate reliably.
        That drove up the costs.
        So, in the case of a convertible top, if you wanted sensors on the CAN bus at the front corners, you have 2 switches: “Seated” and “latched” (for manual) and maybe a couple outputs: “latch” and “un-latch” at each corner.
        They didn’t want to spend money on a crystal with every processor, so they invented the LIN BUS, which is a “sloppy CAN bus”.
        In LIN, the data starts off with a stream, equivalent to a UART sending 0x55, which as a data stream is just a square wave.
        The processors on the bus count the bit widths on the start of the data stream and use those to adjust their CAN receivers, and then communicate using that timing.
        Of course, these ultra cheap MCUs would operate from a simple oscillator that varied in frequency over temperature and over time, but that didn’t matter.
        The time period was adjusted for every message on the bus, which is much shorter in time than temp. changes.

        If you are designing your owns comms protocol, you can consider things like starting a message with “0x55” sent a couple times, so that you can easily put tiny micros with bit-bashed SW UARTs on the network.
        (NOTE: Sending 0x55 also “balances” the line, so if you’re on a differential line, such as RS-485 on long cables [I once deployed credit-card payment terminals over a SW network on RS-485 spanning 2 ski-hills, so several miles of cable] then you give the cables time for the voltages to settle around the middle, increasing the odds of receivers seeing proper timing, and reducing HW data errors … but that’s getting a bit esoteric relative to the original question, so I’ll stop here 😉

        Like

        • Thank you for your time Erich and Brian!

          You really added some useful information, sending the 0x55 message would really be the best way if I were working with my own protocol, I was thinking in a generic solution so it could be used like a “plug-and-play” listener.

          Like

  68. Hi Eric

    Do you know of any bsp setup for the FreeRTOS-IO and Kinetis kxx. The sourceforge forum appears to be down on doesn’t exist anymore and the only example is for the LPC processor.

    I am trying to use their code base for the i2c driver but there are references to pin specific structures that I don’t know how to map to pin_mux.c,h that I using.

    Can you advise on any example for kinetis or even a working support forum please? Thank you.

    Robert

    Like

    • I have not used the FreeRTOS I/O, and I think while the intention was a good one, I don’t see how this could be relevant without a massive effort. Instead, I’m using the vendor (NXP) provided SDK (MCUXpresso SDK) or Processor Expert with FreeRTOS as low level I/O for all the kxx (and other) devices. The MCUXpresso SDK comes with FreeRTOS and FreeRTOS enabled drivers. The easist way to start with it is with using the MCUXpresso IDE: download the SDK and add it, then you can create examples with (or without) FreeRTOS and with all the drivers. Reference: https://mcuoneclipse.com/2017/03/28/mcuxpresso-ide-unified-eclipse-ide-for-nxps-arm-cortex-m-microcontrollers/
      I hope this helps,
      Erich

      Like

      • Thank you for the reply Erich. The reason I wanted to try FreeRTOS I/O was I could not get the simplest i2c driver to work with the V3.2 SDK for our custom board. There is a labyrinth of board specific definitions for multiple projects and configurations in the SDK example code and in my estimation is a completely confusing mess.

        I can set the NXP whole system up to build and assign all the ports and so on but I do not get a working driver in the end. There are a multitude of callbacks and internal references with no explanation of design or significance. All I want to do is read a value from an accelerometer at address 0x68 which I can do with MQX relatively easy. However with the SDK I do not get a response with the single board master slave configuration. The choice was to try and sort out the NXP mess when I came across the FreeRTOS I/O and it’s promised simplicity. This was very close to the POSIX model that I am familiar with, so I paid the $195 and bought the license (I found out later I didn’t need to pay to try the software, my mistake). But after getting into the details, I find this code base is targeted to the LCP processor group with no explanation as to how to set up the BSP to work with another processor. The BSP was the main thing I wanted to avoid when I changed from MQX to FreeRTOS. I would not have gone down this path if I knew a BSP was a requirement for FreeRTOS I/O. Thisk product is promoted as very simple and easy to setup. I think it is easy to use when setup, but the setup is proving to be impossible in any reasonable amount of time. I think this is misleading in my estimation. Then also the SourceForge link has been down for two days which is used for support.

        Your site is the only one that has a good explanation for all the code examples. I wish that PE was still available, that worked correctly and was simple to setup. I think NXP has outsourced all the support off shore hence the convoluted single example for multiple boards, processors and configurations all wrapped up as one large ball of fuzz.

        What I am trying to find is a working SDK v3.2 i2c driver that I can understand and implement to read a few values. Any reference to that would be of great help. Right now I have been on hold for support at RealTime Engineers (Canada –> London) for 30 minutes. I am going to hang up, I don’t think there is anyone there…

        Thanks

        Robert

        Like

        • Ha ha! “I think NXP has outsourced all the support off shore hence the convoluted single example for multiple boards, processors and configurations all wrapped up as one large ball of fuzz.” We feel your pain!
          My programmer, James, fought with the I2C code for a couple of weeks. Eventually I sketched out a simple SW stack on paper with I2C string, word (start/stop/ack), and bit handling in 3 layers, and he implemented it using bit-bashing in less than 2 days.
          We used the same pins as the I2C function so that maybe, in the distant future, we can come back and use the HW support.
          But in general, we found the Kinetis code to be overly complex. You may find it worthwhile to study the CMSIS interface, write your own code to that, and then use CMSIS as your HAL for portability, and just ignore the higher-layer functionality from Kinetis which adds services, but is not portable across brands (we’re using STM32f, Kinetis, and Renesas Cortex parts)

          Like

        • Hi Robert,
          sorry for the late reply. What I are going through with the I2C driver is something I had to fight with on the SDK UART driver side: lots of not well documented interfaces, not clear callbacks, even wrong information in the documenation of the SDK. I had to do some reverse engineering and debugging to find out how it works to get a UART driver working with interrupts and a ring buffer (did not try the DMA version yet, as even more complicated).
          All this was very easy with Processor Expert, and now is very complex and ‘trial and error’ with the SDK. FreeRTOS is very easy for me, but here again how the SDK drivers implement that ‘RTOS driver version’ is not clear to me and overly complex too? I cannot give you much help on the I2C side (I have not managed to get to the I2C part yet, I wish I could. I plan to write an article about my UART experience, but tied up with too many things so I won’t be able to get to the I2C very soon :-(.

          Like

  69. I am developing firmware for an SAM4E8E,with Atmel studio 7. My software consists of a bootloader and an application. When I debug the application I place the firmware starting from the address 0x00400000, When I build the release version the application goes to a different address and at 0x00400000 I place the bootloader.
    To do this I manually modify my linker script “flash.ld” according with the need.
    Is it available a conditional compilation, or any other automated method, to define different address accordin to DEGUG or NDEBUG definition.
    Thanks
    Samuele

    Like

  70. Hello friends,

    Has anyone attempted to use Erich’s PEx component implementation of the FSL_USB_CDC component to implement multiple CDCs in a single part?

    Is this even possible?

    Thanks,

    -Mike

    Like

    • We didn’t exactly do that. But if you want multiple communications devices in a Kinetis part, I’d suggest looking at the sources for the open-source debugger USBDM.
      Like the Kinetis debug boards, it presents a composite USB device with:
      * serial data port (using K20 UART)
      * debug port (compatible with the Eclipse debugger used with Kinetis tools)
      * mass-storage device interface, but not the storage. Its just used to drag-and-drop binary files from the PC to the target device, where they are programmed using the SWD interface.
      But it works great, and everything is provided in source-code. And its been ported to support many target devices.
      If you need more end-points to be CDC it should be fairly easy to hack (famous last words…)
      https://sourceforge.net/projects/usbdm/

      Like

  71. Hello Erich,

    I am in the process of doing a project with the MCUxpresso IDE with the K82f SDK.
    I am writing the code in C++ and was wondering what subset of C++ is actually supported.
    Unfortunately there is little to no documentation about what does actually work on the MCUs, especially regarding STL, RTTI and Exceptions.

    Maybe you are able to shed a little light on this topic

    Kind regards
    Aron

    Like

      • Thanks for your reply.
        I am working with 10.1.0, but I was wondering what would happen when I use C++ features that need a hosted environment like Exceptions? Does MCUXpresso provide a simplified hosted environment for the chips (possible code size problems?!?) ?

        Like

  72. Hi Erich

    It seems like there is now “Amazon FreeRTOS” – which they appear to be marketing alongside their IoT cloud services. I wonder if you have any comment, either on the FreeRTOS angle, or how Amazon IoT cloud services compares with others?

    Regards – Charles

    Like

    • Yes, I saw that yesterday in the news. Not sure where this is going, but at least I see the change to the MIT license as a positive thing. Well, that move explains a bit why there has been no update to the 9.0.0 FreeRTOS until now. I’ll see how I could upgrade my component to the new 10.0.0 version on the weekend if possible. I had fears for a long time that a silicon or tool vendor could acquire FreeRTOS and ‘kill’ it that way (kind of what happens in my view ith uCOS/Micrium). With Amazon behind FreeRTOS, I think we have to see what happens. I have used Azure and of course MQTT and I’m very happy with MQTT. I have not used the Amazon services as I have the feeling this is all about making money. Maybe there are other thoughts about this?

      Like

      • Interesting happenings.
        In one of my positions, as CTO of a nation-wide franchise company, we manage 10 private servers across the country. We’ve reviewed the cloud offerings.
        Our servers have better uptime than MS Azure or AWS.
        AWS is the discount option. If you’re hosting a shoe-store or such its the way to go with lowest price. Good for hobbiest play too.
        Azure failed till they offered Linux, then took off. But you can’t trust MS to not suddenly make free features a paid-for option (as they’ve done with Skype and are doing with LinkedIn).
        If you are dealing with “big data” then Google and IBM are the way to go.
        Both are also more reliable than the bottom-feeding AWS and Azure.
        If you’re dealing with financial info and concerned about hackers, then IBM is the only way, with the best security out there. (though Google is a very close second)
        You’ll pay a bit more for IBM, but what does it cost if you get hacked?
        Anyway, that’s what we’ve learned from researching options.
        I have other businesses that will use cloud services, so its an important topic for me right now.

        Like

  73. Hi Erich,
    I noticed you had a thorough guide on how to implement middleware stacks for KDS and SDK1.x . However as you know nothing stays the same for long. I would really love an example of how to do this (specifically FatFS for SDHC and USB) for the new MCUXpresso IDE with SDK2.2. Alternatively If you know of somewhere where this is explained in an application note or a ‘how to’ video I’d love to know the link.

    Like

    • Hi Paul,
      yes, indeed things do not stay the same for long. I do have lwip running with the SDK2, but I did not had any bandwidth to write something similar for the SDK2 and MCUXpresso IDE. I recommend that you create with the IDE an example project from the SDK as a starting point, at least this worked for me to some level. And I don’t have a video: videos are even more effort to produce and even faster out of date :-(.

      Like

      • Thanks Erich. I’ll give that a try. I wasn’t expecting a video from you – just thought you may have come across something on line about this and could forward me a link.

        Like

  74. Quick Question Erich: Have you done ANY work with the i.MX-RT processors?
    They look appealing for low-end GUI APPs, though without an LCD I think they’re over-kill for the common end-points of the IoT world, unless you’re actuator requires motion control or fast PID control, etc.

    Like

  75. Hi Erich,

    One problem that I face more and more often with Eclipse is the build configuration when using a Makefile project. I often have Makefile variables to configure what is built, e.g. to define the optimization (debug vs release), to enable/disable a specific feature (which is then forwarded as a define to the compiler), to enable/disable some debugging tools, or even to select between variants of a piece of code. I usually create Build Targets, however the number of targets required is getting bigger and bigger every time I add an option (“build release + RTT + featureA + featureC”, “build debug + systemview + featureB + featureD”, etc). With only 3 binary options we end up with 8 build targets.

    I wonder if you’ve already encountered such complexity issue and found a solution The most logical one that comes to mind would be to configure the build with a configuration panel and simple switches for every choice instead of creating one target per set of choices, however I’ve never seen such a possibility, neither in Eclipse CDT or any plugin.

    Like

    • Hi Tim,
      yes, I have such kind of complex projects. I have solved this with set of #define’s in a header file (I usually call it ‘platform.h’ or ‘config.h’ which then is included by the compiler.
      e.g. with things like
      #define PL_CONFIG_HAS_RTT (1)
      an if this is set to 1, it will use RTT in the code, and not if it set to 0.
      I usually write my code that I can turn on/off features that way.
      That way I can turn on/off features in the code. It does not help for special compiler/build switches, for this I still use build targets. But using that header file simplifies things a lot.
      I hope this helps,
      Erich

      Like

      • Hello Erich, thanks for your answer. I already use such headers but they can be (and often are) overwritten by the Makefile which gives the same defines to the compiler. This allows easily to perform builds for all the configurations through continuous integration tools. Then the header only contains the default configuration and everything else is managed through the Makefile, so we can build for a specific configuration without to modify the configuration header.

        I think this approach is very convenient but it has the disadvantage of the high number of build targets, hence the question. It’s even worse if I put every specific build in a dedicated output folder (useful if I don’t want to rebuild the whole app when the config changes).

        Like

  76. Hi,

    Trying to find a good example of ptp handling for k64f and not having much success, seems to always end up looking at linux or paid for libraries.There seems to be a lot of implementation in fsl_enet.c but not a good example as to how to use it.

    Any pointers you can offer?

    David

    Like

  77. Hello Erich,
    Thank you for your great posts. I have a small inquiry if possible.

    At the end of last year, you posted a comparison between different wheels for SumoRobots. You got the highest force using Fingertech wheels.

    However, I found a comparison by Jsumo showing a different results by comparing the friction coefficients: http://blog.jsumo.com/wheel-report-2015-our-wheels-slt20-slt20p-against-to-banebots-fingertech-wheels/

    Could you please give me your opinion on that? Did you do your tests on laminated wood also? Were you maintaining static friction for all types (no wheel slipping) and same motors and weight?

    Thank you!

    Like

    • In my opinion, both the FingerTech and the JSumo wheels are comparable from the friction level, and that report you mention supports that. To me the JSumo ones have the advantage that they are more heavy (metal) wheels while the FingerTech ones are made of plastic: having more weight means I have to pack less extra weight to the robot for the 500g limit, and means as well as soon as the wheels are spinning there is more kinetic energy.
      But if you are located in Canada or the US, it might be easier for you to get the FingerTech wheels than the JSumo ones. I recommend that you have a read at https://mcuoneclipse.com/2017/12/28/making-perfect-sticky-diy-sumo-robot-tires/ where I have created my own polyurethane weels, with the same friction as the JSumo and FingerTech wheels.
      I hope this helps,
      Erich

      Like

  78. Hi Erich. Do you have any information regarding the status of FRDM-K64F dev boards ? They’re pretty much out of stock everywhere, with Mouser showing stock only due in October 2018 ! Are they being replaced/superseded ??

    Like

  79. Hi, Nice to meet you.
    I emailed you 2 weeks ago, but no reply yet.
    We have been searching some application references in which WIZnet solution is applied, and found your project “Arduino Shield with SD Card”. In the Ethernet Shield WiZnet’s W5100 chip is embedded. Your development looks very cool & smart.
    Recently we have devloped WIZnet Museum site. This is a academic-purposed collection of open projects, tutorials, articles and etc from our global customers.If you are O.K. we would like to introduce your projects in here. Hopefully, you will allow this.If you don’t want our posting, then we will undo that just after your email.
    Hopefully, keep contacting us for the friendship. Thank you very much

    Like

  80. Erich,

    Your tips, tricks, and insights have been very helpful to me on many occasions. Thank you.

    I know you have a love/hate relationship with printf. Don’t we all? I have written (yet another) printf replacement that we use in a shipping product. I’ve MIT licensed it so it’s available to use and modify. It’s written cleanly and well commented. What makes this printf different is that it only generates safe strings (snprintf) and it can compute the string length without actually generating the string, to allow you to allocate the perfect-sized buffer for the output. It also handles 64 bit integers which we use for high-precision fixed point values rather than floating point, and generates output in hex, decimal, scientific, and engineering formats.

    I’ve written blog entry on it and the source is on the ee-quipment.com github site.

    Happy printf-ing! 🙂

    Like

  81. Hi Erich, I love your tutorials and they’re helping me get back into the world of ARM MCUs years after I learned them in school.

    I have an issue that I’m trying to work out and I’m not sure if it is a combination of old and new software but you may know what is going on.

    I’m following your KL25z keyboard tutorial, using MCUxpresso 10.2.0 on Linux. I have installed the Processor Expert components, as well as the newest release of your toolset from sourceforge. My issue seems to be in building the code before adding anything of my own.

    Following all of your steps, it fails to compile at a point in CLS1config.h, saying USB1_SendChar is undeclared. There’s a handful of other small errors such as an include for USB_Config.h which is generated as usb_config.h. I’m currently trying to build with the Cross ARM GCC and PE configuration debug builder.

    Lastly, I’m not sure what bootloader to use to interface with MCUxpresso, I’m using the latest DAPlink openSDA version from NXPs site for the kl25z.

    If anything from what I described seems off to you, I’d be really happy if you could point me in a good direction, or even to a blog post I may have missed(you sure have a lot of them, I would suggest a page with a nice long list!)

    –Matt

    Like

    • Hi Matt,
      sorry for my late reply (busy days….). About the errors you see: have you generated Processor Expert code first? The files should be placed in the ‘Generated_Code’ folder. The error message sounds like you did not?

      As for the debug application on the FRDM board: I suggest you use either the P&E or Segger J-Link firmware (https://mcuoneclipse.com/2013/05/16/freedom-board-with-segger-opensda-debug-firmware/): they are faster and usually better than the CMSIS one.

      I hope this helps,
      Erich

      Like

      • So I generate the PE code but I think the issue comes into play when I add the component, there are several messages that appear including:
        “The component “CLS1” uses another shared component for item “Console Interface”. You can use existing component or create a new one” >> I pick USB1

        ” The component “CLS1” uses another shared component for item “Critical Section”. You can use existing component or create a new one.”>> i pick CS1

        “The component “TMOUT1” uses another shared component for item “Critical Section”. You can use existing component or create a new one.”>> i pick CS1

        Following the rest of the tutorial, the project won’t build due to various naming issues I mentioned above, which leads me to believe I’m doing something wrong at this stage and I should be creating new components rather than using the first option shown.

        Also, I’ll try out the firmware versions you mentioned.

        Thank you for all the help!

        –Matt

        Like

  82. Dear Erich: Very impressive of your long time dedication to the community of embedded system especially of using Processor Expert. Just wondering if you had or could post an example of how to use PEx to complete a CAN communication for the FRDM or TRK ARM board. Such as setup the pertinent parameters needed to complete the CAN transmit and receive. Best regards ! Huang

    Like

    • Hi Huang,
      thank you! Unfortunately I have not used any of the FRDM or TRK boards with CAN, so won’t be able to help out with an existing project or example.
      But I’ll keep that on my (growing) list of things, because this would be interesting to explore.
      Erich

      Like

  83. Hi,

    Do you think it might be possible to write something short about my campaign? It is great to use with every arduino or microcontroller so it fits perfectly to your loved webpage.
    It read often articles on your page and it would be awesome to see my own.
    Let me know!

    Like

    • Hello,
      this looks like a nice project! Altough for my projects I prefer to directly generate the sound. Could you potentially update the campain with more technical details, that would be great.

      Like

  84. HI Erich, not sure if this has anything at all to do with you, but I’d be grateful for a response.

    I have some Processor Expert code that uses the RTC on an MK21FX512VMC12. On one of our systems (chip rev ID = 1) this works with no problems. On a newer system (chip rev ID = 9) the code hits an exception:

    PE_ISR(Cpu_Interrupt) { PE_DEBUGHALT(); }

    When we disable the RTC and comment out the referencing code it works fine.

    Apparently there is some significant silicon difference that breaks this, but would expect PE components probably to know about it and adjust accordingly. Perhaps I’m being naive about this.

    This is a concern because I don’t know when our working code will stop working on systems with (x revision) K21, and what other similar latent faults might bite us later on.

    Any thoughts? I’ve asked the NXP forum the same issue, and will cross-post any results. https://community.nxp.com/message/1049661

    Thanks in advance.

    Like

    • Rhys, that’s really scary! Manufacturer’s HW mistakes, embedded in the silicon, are the worst to debug. We’ve battled the broken reset in Freescale (NXP)’s i.MX28 series. The issue is a power dip below 3 volts, but not down to zero. Even with a hard, hard /RESET, when you remove reset the chip fetches a few dozen instructions and then the oscillator locks up. This affected thousands of installs of our clients’ from Alaska to Florida. In a truck, the battery has to be disconnected to perform a power-cycle to get the computer back to life. When you have union drivers in 5-ton trucks, they can’t open the hood. The truck has to be taken out of service to the union mechanic to power-cycle it. A very expensive fix to a recurring problem.
      And a decade back, with Samsung’s s3c2410a ARM-920T processors, there was another reset HW bug. In a silicon revision, the JTAG reset was not connected to main reset. But it wasn’t an issue for most chips for years. Then, due to a process change at the factory, we had devices that would start up, fetch a few instructions, and halt. Power-cycling them usually fixed it. Turns out they were booting into JTAG test mode. The JTAG circuit wasn’t reset. It took half a year to get word of the problem and cure out of Korea. And all it took was a 100 ohm resistor straddling a 10-pin, unused (in production) debug connector pad (1mm pitch) from the main /reset to the /test-reset and they were cured. (making the connection that got lost internally in the revision).
      But we’d shipped over 50,000 of those computers, and one client was placing them into nuclear power facilities and mines in Australia and everywhere. The Australian mines ran off giant generators in 20-foot shipping containers. Each day they were started in the morning, and killed at night. Some days the equipment powered by our computers simply did not work for the entire day.

      Like

      • Oh my goodness, these are absolute nightmare scenarios. At least our product hasn’t gotten out into the wild yet.
        Thanks for sharing. Somehow checking errata should probably be a part of our quality system checklist somehow. Not sure how yet…

        Like

    • Hi Rhys,
      I think you might already have checked the chip errata/revision list? I usually do not use rev0 or rev1 silicon in products, as ‘the dust has to settle down’, at least for rev0. Can you turn on ‘one for every’ (see https://mcuoneclipse.com/2012/02/20/oh-my-an-interrupt/) so you know what interrupt has fired? The RTC is depending on the clock gates and external VBAT pin (should be the case for the MK21 too, but I have not used that device), so maybe you have an issue with the power supply or VBAT pin.
      I hope this helps, as this one could be a really nasty one.

      Like

  85. Hi Erich,
    Do you have any advice as to the best ARM MCU to use as a USB mass storage host? I want to connect a USB memory stick to a board and log data to it. This is very easy to do with an SD card but it would be great to have the convenience of USB.
    I have not yet located a good software library for USB mass storage host, nor am I sure which MCUs have good USB host hardware,
    Many thanks, Ian

    Like

Leave a reply to Simon Machell Cancel reply

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