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:

914 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 on\r\n Turn on the green LED
    g off\r\n Turn off the green LED
    r on\r\n Turn on the red LED
    r off\r\n Turn off the red LED
    b on\r\n Turn on the blue LED
    b off\r\n Turn off the blue LED
    a on\r\n Turn on the LED with amber colour
    a off\r\n 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!\r\n”;
    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

What do you think?

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

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

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