Q&A


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

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

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

1,052 thoughts on “Q&A

  1. Related to saving space (on Flash space staved micros)…

    Using Eclipse and ARM gcc (on an STM32 chip, but that doesn’t affect this), I was getting close to the 256K size of the chip and getting worried. I discovered the gcc -ffunction-sections compiler switch. This causes every function to be emitted its own linker section. Then the linker switch -Xlinker –gc-sections tells the linker to throw away unreferenced sections.

    The ST I/O library I was using has a large number of functions, most of which I didn’t use. But calling just one function for a particular peripheral pulls in the entire section and all functions for that peripheral. Since that library is supplied in source code form, adding these switches reduced the code size of my project from 239K to 186K.

    Related to this I searched on Google for a decent way or tools to do static analysis of my code to see what functions might not every be called, and I found really nothing suitable (that is free).
    I have a lot of functions called through pointers and stuff like that, which confused all the simpler tricks with scripts parsing the map file, or ‘nm’ output.

    Bill

    Like

  2. I’m wondering if you ever use the Eclipse feature to install its own updates? I am using Eclipse Juno Service Release 1, from 2012. Eclipse for C/C++ and GDB Hardware Debugger both show up with much newer versions in the Check For Updates.

    I’d hate to find out the hard way something breaks.

    Eclipse doesn’t really “install” anything in the intrusive Windows sense, correct? Nothing in the registry or in some directory that’s non-obvious. So I could make a copy of the entire Eclipse directory tree as a backup, and if things don’t go well, just copy that back.

    Like

    • Hi Bill,
      never did that with CodeWarrior, because this would easily end up in a problem as CodeWarrior has its own Eclipse and CDT extensions. But would be doable for stock Eclipse. And yes: I’m not aware of any registry/etc settings, so if you make a copy of the layout, you have a backup you can revert to.

      Erich

      Like

  3. Eclipse CDT, in the Project Explorer, under a project, it shows a special folder called “Includes”. Expanding that it shows the directories for #include. Both ones I’ve specified in the project’s properties and the system ones for gcc.

    I changed gcc toolchains at some point. (I’m don’t remember how I did this. I combination of properties GUI, vi on the .project files, and changing the Windows/DOS search PATH) Now this Includes folder shows both the old ones and the new ones. I can’t figure out how to get rid of the old ones.

    Running a grep on the entire Eclipse workspace I find the old paths inside files with names like this:
    .metadata/.plugins/org.eclipse.cdt.make.core/.sc

    With contents:

    Somehow I think Eclipse thinks there are two toolchains “installed”.
    I have no idea where that’s controlled.

    Thanks, Bill

    Like

  4. Webinar – Learn how to use the latest Freescale Xtrinsic MEMs sensors with the new low cost sensor development kit from element14.

    http://www.element14.com/community/events/3764

    Vandana Lokeshwar will discuss element14’s low-cost evaluation kit (XTRINSIC-SENSORS-EVK ) using Freescale’s Freedom platform (FRDM-KL25Z ). You will learn how to use this platform to evaluate sensors quickly and with ease for collecting data. Measure pressure, altitude, temperature, magnetic fields, location and motion on a single board using the latest sensing technologies from Freescale.

    Like

  5. Hi Erich,
    Since you have a lot of expereience in working with Freedom board (KL25), I have a small question. While implementing (custom) USB CDC for the Freedom board (KL25), I am seeing that the ping pong buffers are never toggled i,e I am always observing the EVEN buffers are used (for all the endpoints I am using). Why is that so? Am I missing some thing in the configuration? Or am I not doing some thing enough to activate the ping pong?

    Regards,
    Pandian

    Like

      • Hi Erich,
        I am referring to the Even/Odd buffers used in BDT. I am seeing the ODD bit never set in the USBx_STAT register.
        Regards,
        Pandian

        Like

      • Hi Erich,
        Yes, I have already posted it. No responses yet :(. But by any chance have you observed this during your developments?
        Regards,
        Pandian.

        Like

        • Hi Pandian,
          no, I have not observed this, but I have not paid attention to this neither. My understanding is that using the even/odd buffers would increase performance. Is this what you are looking for?

          Like

      • Hi Erich,
        Yes, I want to achieve a higher throughput. Is it possible for you to test that (if you have free time available for this) please?

        Like

        • Hi Pandian,
          for sure I won’t have time until the week after next as my schedule is more than cracy for next week. But what should I test? I mean if you say that the other buffer is not used, then I believe this. The question is more: how to fix/change this? This is more something for Freescale I think. Apart of this: I’m looking into adopting the LUFA open source USB stack. But not much time yet neither on this. 😦

          Like

      • Hi Erich,
        I just wanted to me make sure that I am not missing some thing in my configuration. Any how I have raised the issue with Freescale. Will update you the status once I have some thing.

        Like

  6. KINETIS MCU: WATCHDOG AND AD CONVERSION SIMULTANEOUSLY… FAILURE?!
    I have tried to debug on CW MCU 10.4 a small test program over an FRDM-KL46Z board.
    Few components implemented:
    – AD converter on PTE22 (light sensor), on V_refsh and TempSensor (to monitor the stability of measures),
    – RTI every 10ms to start the AD conversions periodically,
    – WAIT utilities (tnx Erich..) to handle main loop in main function,
    – some BitIO and PWM to lamp leds on PTE29 (red) and PTD5 (green)
    Results:
    if WDog enabled and asyncronously cleared with ad-calibration and measurements active, also with average of 128 conversions, the values of AD entities (Vrefh included), fluctuate dramatically.
    Aborting WDog_Clear during calibration and/or measures of AD subsystem (by means of a flag sw), the analog values remain stables as without WDog enabled… possible?

    Like

      • I dont know, Erich, if that impact the voltage of a pin… likely not, also because if you monitor with on line debug the ad-channel Vrefh and TempSensor, you will confirm this deep fluctuations, but attention… is necessary to kick the wathdog WHILE ad-calibratio/conversion in progress, therefore with interrupt enabled on ad-conversion and with the main program that kick the watchdog during ad-conv… if you want, i can send you my small demo program. My work around is to set a ram status flag, that signal to main program the ad-conv in progress to avoid kick wdog… not elegant, but effective.

        Like

  7. Hi Erich,

    I am trying to figure out how to send and receive data via Bluetooth from my program on the KL46Z. I have the JY-MCU HC-06 from dx.com.

    I have read and reread your two Bluetooth tutorials on MCUONECLIPSE.COM. It appears to me that you are setting up the KL25Z as a remote terminal running RTOS that just sends back what it receives.

    I don’t know if using an RTOS is best in my situation.

    In my application, I am merely running a loop on the MCU that reads several input pins on the KL46Z, sends the data out the USB, listens for commands coming from the USB, and then sets various outputs accordingly.

    (I tried to keep the program simple because there will be non-programmers that will maintain and troubleshoot the production device. I wonder if using an RTOS will make things more complicated than necessary.)

    That being said, I am at a loss as to how to connect Bluetooth to my KL46Z. (The MCU will use BT to communicate to my UI on an Android tablet.)

    I assume I can connect one of the UARTs to the BT module. Is that correct? Also, can I use UART0, or is that dedicated to the debugging port? If so, what is involved in using UART1?

    If I need to use an RTOS, how would I send and receive data from within my program through the RTOS to the BT device?

    I know these questions are beyond the scope of your blog, but can you direct me to where I can find the answers?

    Thanks again.

    Like

    • Hi Injun,
      an RTOS simplifies a lot of things, and makes the application scalable. That’s why I use typically an RTOS: to be able to build up something more capable. But in your case no RTOS is needed, if you just want to run a ‘main loop’ kind of thing. From the KL46Z point of view, the HC-06 is like a normal serial port: send and receive data from there. So yes: you need to connect one of the UARTs of your KL46Z to the Bluetooth module. Just make sure you connect the Tx of the KL46Z to the Rx of the module. You can use either UART0 or UART1, does not matter.
      I hope this helps.

      Like

  8. Hi Erich!
    I love to read your articles! Day by day your posts have something new, innovative and also interesting. Congrats!
    Because you have more experience then me with embedded systems and as I can see with Freescale silicons, I want to ask you for an opinion / suggestion. I want to make a voice controlled robot car – something simple. I am beginner into digital signal processing field, but I am ready to learn new things. For doing this, I am prepared to buy a Freescale development board, but I do not know which. I am afraid that processing power will not be enough, even if I will implement simple algorithms for signal processing. Could you give me an advice related with my fear? For example, can I use a Freedom board, like KL46Z? What kind of board would you advise me to use?
    I forgot to mention that I want something ultra-low-power, which will be battery powered. If you want more details please tell me.
    Thank you.

    Like

    • Hi Mihai,
      many thanks for your feedback: always good to hear that things are useful if posted to the Wild-Wild-Web 🙂
      I have to admit, I have not done any speach recognition work. My thinking is that it all depends on the complexity and the commands: if it is about just to process some simple things, I think a KL46Z (FRDM-KL46Z) could be a starting point. But I think you problably need more horsepower, so better consider the FRDM-K20 (this one has a Cortex-M4 and is more capable).
      But my thinking is that your algorithm might need some amount of RAM, and here you could run against a wall: my guess is that you need at least 64 KByte RAM, if not 128 and more. Because you probaly need to record the signals, and then do processing on it, so you need to store it. But larger RAM and higher processing speed does not go well with low power.
      Again, it all depends on the complexity of things you want to do.
      I hope this helps.

      Like

    • Knowing nothing about DSP, I expect it to be software intensive, therefore, hard to develop with no prior experience. You might look into finding a “front end” that will do the actual speech processing for you. For instance, perhaps a speech recognition program for an Android tablet could be used to register the commands, and then the tablet USB or Bluetooth be used for the external control you seek.

      FWIW, this morning I learned about a voice recognizing operating system that may work for something along the lines you are investigating.
      http://thehackernews.com/2013/09/jarvis-artificial-intelligence.html

      Like

      • You might also start by creating your system without voice recognition, and then add it later when you find exactly what you want.

        Like

  9. Thanks for your replies, guys! I am going to create my system without voice recognition, and after that I am going to try to add voice recognition. Maybe a solution will be to have two or more boards. I will see.
    Thanks again.

    Like

  10. Hello, I’m newbie in embedded software world I’m a .Net guy with that being said here is my question. I’m playing with FRDM-K20D50M board, according to board’s manual target MCU works in SWD debug mode and Processor Expert reserves for that mode pins: PTA0(#22), PTA2(#24), PTA3(#25), also according to board manual on-board Blue Cathode uses PTA2. Does that mean that I will not be able debug any application that uses PTA2.
    If my question is totally stupid, any point to the right direction will be greatly appreciated.

    Thank you in advance,
    Maxim.

    Like

  11. Hi Erich,
    I have simple question that I don’t know where to find the answer to. I have an Android tablet connected via USB to a FRDM KL46Z. How do I determine in the KL46Z when it loses the USB connection? I want to turn all outputs off at that point.

    Under the USB component in Proc Exp I see the OnError method but I don’t know how to use that to do anything in my ProcessorExpert.c program. I gather I am to add code under that method in Events.c but I don’t know how to do add code there that I can use in my ProcessorExpert.c program.

    Or, if I am to use USB1_OnError some other way.

    Once again,thanks for your help.

    Like

    • This is what I use in my examples to find out if I still have a connection:
      while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LEDR_Neg(); LEDG_Off();
      WAIT1_Waitms(10);
      }
      If it returns ERR_BUSOFF, then the enumeration did not happen (yet) or device has been disconnected.
      But in my experience that method did not work on all devices or in all cases, not sure why.
      You might give it a try this way.

      Like

      • Thank you for your suggestions, Erich. I am using that code to establish the initial connection. I tried also putting it in an if statement to see if it would fire upon losing the connection, but I could not figure out how to make it work in my situation.

        I tried using the USB1_OnError method in the Events.c file. I put an “extern” variable in a header file and I set the variable in the USB1_OnError method. I can then read the variable in my ProcessorExpert.c file and turn off the outputs accordingly, BUT, I don’t know under what conditions USB1_OnError is called by the internal MCU programming. It does not appear to be called when the USB cable is disconnected.

        When the USB cable is unplugged, my MCU program appears to hang. I don’t know if an error is being generated at that point, or if the program is just waiting for a read or write function to complete.

        Do you have any suggestions about how I can turn off the outputs when the USB cable is disconnected, or when there are any other USB disconnect issues?

        If not, do you where I might find find the answers to these questions?

        Thank you once again for you kind assistance.

        Like

      • Dear Erich,

        I used your “mcuoneclipse / Examples / TWR-K70F120M / TWR-K70F120M_USB_CDC” sample code. And I found while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
        /* device not enumerated */
        LEDR_Neg(); LEDG_Off();
        WAIT1_Waitms(10);
        }
        won’t return ERR_BUSOFF when the TWR_K70 is disconnected to PC.

        But KL25 and KL26 will.

        Do you know how to reslove this issue?

        Like

        • I have seen this too, but not seen an easy solution. I believe it is because the K70 has a different USB block, and it reacts differently.

          Like

      • Dear Erich,

        In K70, I found when disconnected USB, event_type in CDC1_App_Callback will be USB_APP_BUS_SUSPEND in most time, and sometimes will be USB_APP_BUS_RESET.

        Like

  12. Thank you for your suggestions, Erich.

    Your program works as expected on my Win XP system. Also, I tried a KL46Z with your program connected to my Android tablet and the LEDs indicated correctly when the cable was unplugged, and then reconnected. Ditto Ubuntu 12.04 and Win XP on VirtualBox on Ubuntu.

    (It seems though, that even though the LED indicates the USB is reconnected the MCU no longer communicates with the terminal program.)

    I have spent a great deal of time the last three days trying to figure this problem out. I probably tried a few hundred combinations of different code sequences to duplicate or cure the problem in both your program and mine.

    THE PROBLEM is that in order for the LEDs to indicate connect/disconnect status, the writing statement (such as CDC1_Send_Block or CDC1_Send_String) has to be inside the if(CDC1_GetCharsInRxBuf()!=0){…} statement.

    I don’t understand why this is but it is consistent.

    In my program I have been writing to the USB at a point different from where I was reading from it. My USB reading and writing seemed to work fine for everything but this stupid USB disconnect issue.

    Now, at least, I know how to make the LEDs work right, even if it doesn’t actually reestablish communication. I think I can do that from my Android tablet.

    Thanks for your help.

    Like

    • Not sure if I understand the problem? You say it works correctly with XP and Ubuntu, but not with Android, right?
      And that CDC_Send_Block() and CDC_Send_String() only are working correctly if there are incoming characters?

      Like

      • I apologize for not being more clear.

        I tried to say that with Android (or Ubuntu, etc.), the LEDs in your program act as expected. However, they only work as expected if the write statement is inside the “if” statement.

        Also, even though the LEDs in your program indicate USB re-connection, data can no longer be transfered between the terminal program on WIN XP and the MCU. (At least, in my experience. Perhaps I got something wrong in this?)

        I also tried to share that (except for this LED lighting issue) I have been able to read or write wherever I wanted to in my program.

        My next step is to determine if I can use this new understanding to turn the outputs off upon USB disconnection.

        Sorry for the mix up.

        Like

        • no worries. About the LEDs: I just have fixed the LED handling for the FRDM-K20 as they were not properly showing the status. I have not checked the other examples, so it could be that the LEDs are not correcly reflecting the status (connected or not). Maybe this is where the confusion comes from.

          Like

      • Hi Again,

        I am still struggling to understand your FRDM-KL46Z48M_USB_CDC program. It seems that when the cable is disconnected and reconnected, the statement if(CDC1_GetCharsInRxBuf()!=0) is never again true.

        This seems why, even though the LED comes back on, one cannot write to the terminal program again.

        CDC1_GetCharsInRxBuf() is defined in CDC1.c where it calls CDC1_App_Task(txBuf, sizeof(txBuf))!=ERR_OK).

        (Forgive my ignorance, but does it matter whether txBuf or rxBuf is used in this instance?)

        (Interestingly, I changed the statement to CDC1_App_Task(txBuf, sizeof(txBuf))==ERR_OK) and it made no difference in how the program operated. I don’t know if that is significant or not.)

        I have been unable to figure out how to get CDC1_GetCharsInRxBuf() to read from the USB upon cable disconnection and reconnection. May I trouble you once again for suggestions? Thank you.

        Like

        • Are you unplugging the cable while the Android is sending data and the COM port open? Maybe this is the source of the problem?
          Sounds like a similar issue on Windows.
          And: you need two separate buffers: tx and rx. They need to be distinct, as there there are two streams of data in parallel. CDC1_App_Task() needs a buffer for the data transfer, it could be any buffer. If you swap tx and rx, that’s fine. But you cannot use the same buffer for sending and receiving.
          CDC1_GetCharsInRxBuf() simply checkes if there is something in the incoming buffer. Things are put into the incoming buffer by an interrupt (the USB interrupt). I really don’t know what is going wrong on your end. The fact that it only happens on Android let me believe it is an Android issue. What happens if you close the connection on the Android side before unplugging the cable?

          Like

  13. I’m apologize. I wasn’t very clear again.

    It is not just happening in Android. My last post was exclusively about trying to get your program working with WIN XP on a standard XP machine.

    The tx and rx buffer issue was from your example program.

    Sorry for the confusion.

    I will try adding rx buffers to your program and see if that makes a difference.

    Thanks for the quick response.

    Like

  14. P.S. The suspicious code is in the CDC1.c file in the Generated_Code folder which is generated by CW. (This is in your FRDM-KL46Z48M_USB_CDC program when running on a Win XP machine.) Where does that come from, please?

    Thank you.

    Like

    • CDC1_App_Task() needs a buffer for sending the data. That’s why CDC1_GetCharsInRxBuf() is passing a ‘txBuf’ to CDC1_App_Task(). But this buffer is a static local.
      I still do not understand what the problem is on XP: CDC1_GetCharsInRxBuf() calls CDC1_App_Task() because this will make sure that the current outgoing buffer is sent, and new items are received from the input pipe.
      Is your problem that CDC1_GetCharsInRxBuf() blocks? There is a timeout which can be used for this.

      Like

      • Thank you for taking the time to update your program in order to address this issue. I tried it in the KL46Z connected to my Win XP machine and the MCU still did not reconnect to the terminal program (Termite 2.9).

        With your program in the FRDM-KL46Z communicating with the terminal program on your Win 7 system, if you disconnect the MCU USB cable and reconnect it, are you able to still communicate with the terminal program running in Win 7?

        The MCU LEDs will show a reconnection, but does the terminal window show the returned echo and val number in response to keys typed on the keyboard?

        This is where my problem lies. The MCU will not reconnect to Termite 2.9 in Win XP even though the LEDs on the MCU show it is connected.

        If your MCU program reconnects to the terminal program in Win 7 then the issue is with my XP machine. If it does not reconnect, then I will try to understand more about how your program and the KL46Z handle the USB disconnect and reconnect process.

        Thank you for your time once again.

        Like

        • No, if I disconnect the cable with an open (connected) terminal progam on the host and plug it in again, the communication does not work. To my knowledge this is a Windows issue. You need to close the terminal connection on the host before you re-connect the cable. So with this, you need to detect on your android device that the cable is disconnected, then close the port, and only open it again once the cable is connected.
          I have the same issue with Windows 7, and it exists as well in Windows 8 to my knowledge.

          Like

  15. Thank you very much for checking that out for me, Erich. That answers a lot of questions for me.

    My problem has been to get the KL46Z to recognize it has lost USB connection (in Windows or Android) and turn off its outputs. (Hopefully, I can then program it to reconnect to the USB without a manual CPU reset.)

    I suspect that anyone who wants to use this FRDM board with any kind of USB interface to another program (no matter what OS is running on the hardware) will also want this capability.

    [I can imagine a factory (or a very large machine) having a number of these little FRDM-KL46Z boards controlling various operations in different places. They could all be connected to a central computer (Windows or LINUX) which records data and makes processing decisions which are then sent back to the KL46Z boards. In this context, it would be helpful for the KL46Z to not freeze when it loses USB connection.]

    [This is essentially what I have done, but with only one remote KL46Z in a machine the size of a narrow workbench. We have a prototype going to various shows around the U.S. and it is embarrassing to the salesman demonstrating to a potential customer when there is a glitch in the USB connection and the machine keeps running out of control when it is supposed to stop. This is why I need the MCU to at least turn off the outputs when it loses USB connection.]

    Thank you for all of your time and help on this troublesome KL46Z issue.

    Like

  16. Is there a bug in codewarrior 10.x ?
    If chose RAM mode in K70 PE project, in the .ld file, __S_romp = 0 defined,
    and in __arm_start.c __thumb_startup(), these is a
    if (__S_romp != 0L)
    __copy_rom_sections_to_ram();

    if this true, there will be no code and data copied to ram at system start.
    Or there is something else we can ignore this ?

    Like

    • .ld file explained this, all the code burned into the data_flash area, so there will be no need to copy, all the code and data will run where they are locally ?

      Like

      • Yes, while downloading the code to the target, the debugger stores it in RAM. So if you turn off the power, your program is lost. That’s whay these ‘RAM’ targets do not make sense to me (I always use the FLASH targets, because this is what is needed at the end).

        Like

    • I’m not using the RAM configuration as this is not useful for me. But to my undestanding the code gets downloaded by the debugger into RAM, and there is no copy from flash to RAM.
      __copy_rom_sections_to_ram() is use to initialize RAM variables with content from ROM (the constants), e.g. for
      int i = 3;
      where i is in RAM and 3 is in FLASH/ROM.

      Like

  17. Hi,

    I am trying to work out what is going on in the following:

    #define EnterCritical() \
    do {\
    if (++SR_lock == 1u) {\
    /*lint -save -e586 -e950 Disable MISRA rule (2.1,1.1) checking. */\
    asm ( \
    “MRS R0, FAULTMASK\n\t” \
    “CPSID f\n\t” \
    “STRB R0, %[output]” \
    : [output] “=m” (SR_reg)\
    :: “r0”);\
    /*lint -restore Enable MISRA rule (2.1,1.1) checking. */\
    }\
    } while(0)

    I understand the the asm(“”:::) is using the GCC Extended asm commands.

    I understand that the “MRS R0, FAULTMASK” – Reads the FAULTMASK into R0

    and that “CPSID F” disables the interrupts by clearing the FAULTMASK

    and that “STRB R0, %[output]” stores the saved FAULTMAK into the variable SR_Reg

    What i don’t understand is the “R0” what is this doing??? From the GCC manual the third optional item is the “list of clobbered registers” but what are these and how does the While loop ever exit if it is in a while(0) loop??

    Thanks for you help,

    Like

    • ‘Clobbered’ means that registers are touched/changed. With this, gcc compiler knows which registers are changed inside the assembly block (without knowing the details), so gcc can save/restore registers as needed.
      The while loop is an ‘artifical’ one so it creates a new code block. It only gets executed once because the while(0) at the end. I hope this makes sense now?

      Like

  18. Hi,

    I have been playing with the WAIT library using a GPIO Pin to test the timing accuracy.

    i ended up changing the ms function to the following :

    void WAIT1_Waitms(word ms)
    {
    dword msCycles; /* cycles for 1 ms */

    /* static clock/speed configuration */
    msCycles = WAIT1_NofCyclesMs(1, CPU_CORE_CLK_HZ) – 17600;
    while(ms>0) {
    WAIT1_WaitLongCycles(msCycles);
    ms–;
    }
    }

    When i specify a delay of 300ms using the unmodified code i was getting = 462.8ms

    But with the modified code (i.e. -17600) i am not getting = 300.12ms

    NOTE: I am using a MK10 CPU and the

    Core Clock = 50MHz
    Bus Clock = 50Mhz
    External bus = 50Mhz
    Flash clock = 25MHz

    Could the -17600 be fixing the function as it take into account the while loop overhead, or is it possibly due to the Flash Clock??

    Any ideas??

    Like

    • Such a ‘busy-wait’ never is very accurate, but my experience is that it is in the +/-10% range.
      I just run a 300 ms wait on the KL25Z:
      for(;;) {
      Bit1_NegVal();
      WAIT1_Waitms(300);
      }
      I measured 328 ms signal toggling (20.9 MHz core clock, 20.9 MHz bus clock), and I use the CPU_CORE_CLK_HZ as my timing base.
      I changed the bus clock to 10 MHz, and things stayed the same.
      The L family has no Flash clock, I’ll try with my K20 and let you know.

      Like

      • I tried that wait for 300 ms on my K20 (20.9 MHz cor, 20.9 bus clock, 10.45 external bus clock and 10.48 MHz flash clock), and I get 338 ms.
        Could it be that you use an old version of Wait component? I know that I had fixed something a while back.
        The current version is
        ** Version : Component 01.064, Driver 01.00, CPU db: 3.00.000

        Like

  19. Hi Erich,

    I’m porting a library to the KL46Z and it makes use of the C standard sys/types.h header file. However, mingw32-make is telling me that there is “No such file or directory” when I try to build the project. I know that sys/types.h exists on my ARM GNU installation files and it has the following path:

    “C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q2\arm-none-eabi\include\sys\types.h”

    In addition, my project’s “Paths and Symbols” settings include the entry:

    ${ARM_GNU_TOOLS_HOME}/arm-none-eabi/include

    This path is included by default when I create Processor Expert bareboard projects.

    Additional info:

    If I edit the code to remove the “sys/” part and leave just #include then the compiler doesn’t complain. This concerns me since “types.h” does not exist within the “…/arm-none-eabi/include” root folder for the standard C headers. It exists within the “…/include/sys” folder.

    Is it ok to just remove the “sys/” part? If so, then why is this allowed and why does the compiler complain when I add back the “sys/” part? The library I’m porting over was written in ANSI C. At least that’s what the manufacturer says 😉

    Many thanks in advance and have a good weekend!

    Like

    • “Paths and Symbols” is only for the indexer. The compiler uses the paths in “C/C++ Build/Settings/Arm blah blah compiler/Directories. Try adding “${ARM_GNU_TOOLS_HOME}/arm-none-eabi/include” there, it should work (just ran into this myself, found your post, and tried it, worked for me…)

      Like

  20. There is a problem in KEY or Trigger comp, when add two or more KEYs to the proj, with using one TRIGGER , in the TRG1.h file there should be something like
    “#define KEY_***_Press 0”
    “#define KEY_***_Press 1”
    ….
    Otherwise , there is a complie error.

    Like

    • Unfortunately, the trigger component does not know anything about the Key module. Because I usually have at least one key, the trigger component has one trigger already defined for one key. If you are using more than one key, you need to add it to the trigger component. In the trigger component properties, you can add and extend the list of triggers. Maybe I will find a way to do this automatically, but I think it is not possible (or not easily possible). So I recommend that you add it by hand. Sorry about this.

      Like

  21. Hi Erich,

    I appreciate all the help that you are doing for us.
    I have a small question. I am using freescale K60 module (CW 10.1.2 IDE with PE). I am running my application in that and I am facing some issues in between. Now, I want to attach my debugger and check the variables in the application.
    Can we do this kind of run time debugging with CW IDE?
    If so, please let me know how this can be done?

    Thanks,
    Jagadeesh.

    Like

  22. Hi Erich,
    Its wonderful to learn embedded systems after following your site. Thanks for all. I have a problem using debugger (Jlink Lite) with my target, K60F Tower board, and learning USB with it. I am using your tutorial for setting up the Eclipse based environment along with GCC and Processor Expert. Unfortunately there is always a hard fault exception in the /Project_Settings/Startup_Code/startup.c file which has function __copy_rom_sections_to_ram();
    I believe you have not used GCC but CodeWarrior for your development. Is there any way i can continue my debugging?

    Like

    • Hi!
      I’m using a mixture of different tools, CodeWarrior one of it. But I’m using ARM GNU gcc with CodeWarrior too. Your hardfault sounds like something is not correctly initialized by the startup code. For example using a RTC which is not properly clocked might cause a hard fault, among other things. If it happens during the ROM to RAM copy part, it could be that your memory and bus clocks are not properly set up. I suggest that you try a project set up by CodeWarrior as my experience these projects set up everything correctly. If you are using ad different tool chain, you still could copy then this code to your own (e.g. bare GCC) environment.
      I hope this helps.

      Like

      • Hi Erich.
        I am getting a similar problem on one of my projects. I am coding in Codewarrior 10.5 using GCC.

        I am saving bitmaps as arrays in my flash on the micro, as I am using a MK40DX256 device I have plenty memory.

        What I find is if my firmware gets larger than 128K I get this problem, even though It compiles fine etc?

        Do you have any idea what could be causing this?

        Like

        • could it be that it just takes too long and the watchdog triggers? The other thought is: the copy-rom-to-ram is for things like
          int var[] = {3,5,5};
          so it copies from ROM the constant valuse (3,5,5) and places it into RAM (at the address of var[]). this can take along time. Do you have something like this?
          It would be better to use
          const int var[] = {3,5,5};
          if possible?

          Like

      • Hi Erich.
        I am using:
        const unsigned char Arial_Bitmap_Data[] = {x,x,x,x};
        I did this as the size of the bitmap is larger than the available ram on the device.

        I will investigate the watchdog issue although I am not using it at the moment. This one does have me stumped, I am willing to pass code onto anyone who may know what is causing it.

        I cannot see what data is being moved to the RAM in the debugger view, I can see them normally once the micro has started up though in a smaller program.

        Like

        • So you have it as ‘const’, that looks ok. So I think you need to single step through your code to find out where exactly (for what data/address) the problem occurs. Check the destination address, and consult the linker map to find out what variable/object is causing this.

          Like

  23. Hello Erich,
    You have a really great blog here. I was searching to find out the difference between hc-05, and 06 and you explained things so nicely. Thank you.
    My ultimate question is which Bluetooth module I should use for the product that I am working on. It is a wireless light control system. I am going to make a smartphone application to control two things. One is the ballast for the lighting, and the other one is wall controller that is connected to one or more lighting. Of course, I am thinking about WiFi also, but I am going to deal with Bluetooth first.
    So far, I have decided that the module should be wide range. I am thinking about class 1 or 2. Since it is a lighting system, it really need to be reliable and low cost at the same time 🙂 I need a lot of it, so I think I can get some discount.
    If you answer my question, I will really really appreciate it.
    Thank you.

    Like

    • Hi Tae,
      thanks for you nice comment :-).
      About your question: my honest answer is that you probably should not use Bluetooth for something like this. It depends about the details of this product, but I rather would recommend that you use something like ZigBee or IEEE802.15.4 instead. Or your own proprietary protocol. There are simply to much problems with such a thing and using Bluetooth. Bluetooth is fine for standard components (audio, headset, serial connection), but without the right expertise creating your own class will not be easy. Using a simple web server/wifi is would consider too. But then it all depends on how low power your application has to be. And if it is about lamp control: have a look at established protocols like DALI.
      I hope this helps.

      Like

        • If you are going to use Bluetooth, then you heavily depend on the device class and support implemented. That’s fine for generic classes like ‘headset’. But for example look at the iPhone Bluetooth stack: it is not possible to make a connection as a Bluetooth-to-Serial class. Even more, it is pretty much a 1 to 1 connection. So if you are really looking for a universal protocol, then I suggest to go for a HTML server (TCP/IP): that way you do not need a special application or driver on the phone: all what you need is a web browser which should be available always. Of course I’m talking here about smart phones. If you intend to connect to non-smart phones (like the old Nokia phones/etc), then that would be a different discussion?

          Like

        • Yes, agreed. But here is exactly what I tried to say: “don’t use Bluetooth”: Becaues Bluetooth is *not* Bluetooth Low Energy (BLE). The only common thing between Bluetooth and BLE is that a) it shares the name b) it uses 2.4 GHz and c) it is a wireless protocol. You cannot use a Bluetooth module to talk to BLE 😉

          Like

    • Thank you for this great discussion. Very useful information. I am still deciding whether I should start over the project to have Zigbee and WiFi with own router, or to continue with BLT. I think using BLT on a couple of lights would be better, because it is so simple to connect. As you said, to have a universal system, Zigbee or WiFi is the way to go. From my knowledge, BLE can have maximum 7 slaves. Doesn’t it mean that I can control all seven of lighting at once with my smartphone?
      Thank you
      Tae

      Like

  24. Hello Erich!
    I’m very thankful for stumbling into your blog! As I was searching for jump-start tutorials on the KL25Z board. Right now I’m making a real time clock using the RTC_LDD based on this tutorial freescale community DOC-94734 but the rtc is off as much as 2 sec per 30 min and is the only module running on the 48MHz core. Is there any way to make it to 1 sec/day or less?
    Thanks.

    Like

    • Hi Micheal,
      glad to hear that you find it useful, thanks for that feedback!
      As for the RTC: it looks like your RTC is not really 32 kHz, so slightly off maybe because of temperature. You should be able to add an offset (change the frequency) of the RTC clock input (second image on freescale community DOC-94734). Increase or decrease that 32 kHz value to compensate for the error. That way you should be able to reduce the error. This technique is called ‘trimming’ is used to deal with different clocks. For your final application you might consider to perform this by the application itself (if you have multiple boards).
      I hope this helps.

      Like

      • Hello again erich, thanks for the reply. Though I cant edit the RTC clock input, there was the option to add compensation for the RTC clock input in the component inspector. I measured the RTC clock input and it was at 32.84 kHz. I experimented on the compensation settings to see how it can help me get the right frequency, but I failed, it didn’t changed anything. I still measure 32.84 kHz.

        Also I turned off all other components and modules present in my application. Any thoughts on how I can use the compensation settings?

        Thanks.

        Like

  25. Hi Erich,

    Where could be found the documentation for the components(e. g. Serial_LDD)?
    Also for FRDM-KL25Z on web-site is only one App Note, I think should be at least one for each component/feature on the board.

    Thanks,
    Lucian.

    Like

  26. RIGHT APPROACH FOR MIGRATING FROM STM32 CMSIS style code
    Hi Erich
    a coworker wrote a stable and well tested code for STM32 ,now i have to reply the same structures in a CW project developed with the help of Processor Expert it would be nice if the now code could appear similar to the original one at a glance ,but I don’t pretend it.
    At least it would be nice if i could have functions doing the same job,
    What is your approach having to do with a code to migrate from,based on structures to fill and Init to launch :
    void STM32_EXTI_CTRL_forCC1101(FunctionalState NewState)
    {
    EXTI_InitTypeDef EXTI_InitStructure;
    /* Configure EXTI9 GDO0 line for RX mode */
    EXTI_InitStructure.EXTI_Line = CC1101_FIFOTHR_IRQ_EXTI_LINE;
    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //EXTI_Trigger_Rising, EXTI_Trigger_Falling
    EXTI_InitStructure.EXTI_LineCmd = NewState;
    EXTI_Init(&EXTI_InitStructure);

    /*add rev for EXTI1 GDO2 line for TX e RX mode */
    EXTI_InitStructure.EXTI_Line = CC1101_TRXPKT_IRQ_EXTI_LINE;
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //EXTI_Trigger_Rising, EXTI_Trigger_Falling
    EXTI_Init(&EXTI_InitStructure);
    }

    Many tanks

    Like

    • Hi Diego,
      not sure if I understand what you are asking about. As long as your STM32 code is normal C, then you should not have much troubles to port it. But maybe you problem is about the CMSIS style? Yes, this is a challenge as Freescale does not seem to provide CMSIS compliant libraries and files. This hopefully will change.

      Like

  27. Hi Erich,

    I am trying to read data from two foreign IMU sensors: one uses I2C protocol and the other uses SPI from the K60 Tower Board(the master device). I am aware of the “I2C_LDD” & “SPIMaster_LDD” components from ProcessorExpert, and I have no problem configuring the corresponding static settings. But I’m helplessly clueless on how to even begin with the coding parts that tell the microcontroller how to communicate with the sensors. I’m terribly sorry if I sounded frustrated, this is work related… =\

    Could you guide me on how I should begin? Or point me to any tutorials that might be useful. I guess another question would be can the K60 read and output data from two sensors simultaneously?

    Thank you for your time,
    Dao.

    Like

  28. Hello Erich, right now Im using two portA pins, pta16 and pta17 as external interrupts. compiling the code produces a “redefinition Cpu_vINT_PORTA.” is it possible to use two external interrupts on the same port? Thanks.

    Like

        • I quickly tried this (KL25Z), and it works for me?
          PE_ISR(Cpu_ivINT_PORTA)
          {
          ExtIntLdd1_Interrupt(); /* Call the service routine */
          ExtIntLdd2_Interrupt(); /* Call the service routine */
          }

          Are you using MCU10.5 with the Processor Expert Update 1.0.0?

          Like

      • I apologize for the late reply, I got it working now, thank you so much Eric.

        Another issue I’m having is with the SD card. I’m currently using the PE component that you made, the FAT_FS component. I don’t know how to append files, because when I open-write-close the file and do it again, it overwrites the data on line 1. I want to append the next data on line 2. This is my first time working with SD cards so please bear with me 🙂 Thanks.

        Like

        • This is not all specific to SD cards: it applies to files on your host too. If you do not want to re-create the file, simply open it with FA_READ flag:
          res=FAT1_open(file, (const char*)dataFileName, FA_READ); /* try to open file */

          Like

      • Yes, that would be the case for reading a file, but when writing again the same file for another set of data. It just overwrites the data on line 1, instead of appending it.

        Like

        • Here is an extract how to do this: you need to go to the end of the file with lseek():

          static byte SDC_AppendToFile(const char *path, const char *txt) {
          FAT1_FRESULT fres;
          UINT nof = 0;
          size_t len;

          /* open file for write, create the file if it does not exist */
          if ((fres=FAT1_open(&fo, (char*)path, FA_WRITE|FA_OPEN_ALWAYS)) == FR_OK) {
          if ((fres=FAT1_lseek(&fo, fo.fsize)) != FR_OK || fo.fptr != fo.fsize) {
          //Fatal(“lseek failed”);
          return ERR_FAULT;
          }
          len = strlen(txt);
          if ((fres=FAT1_write(&fo, txt, len, &nof)) != FR_OK) {
          return ERR_FAULT;
          }

          Like

      • Thank you so much for that snippet. I’m real sorry for having you to spoon feed me. I’m really grateful sir. Now I’ll modify the function to fit my needs. thanks again 🙂

        Like

  29. Hi Erich,
    when i use the chLCD or KentchLCD or sharp65 driver components, there is a warning in console
    :{{DEVELOPMENT}} WARNING: Component GenericSWSPI was stored in the template in newer version: 01.018>01.001

    and things not going on any further just stopping at create shared component spi(0%) shown in eclipse status bar.
    I’m using kepler with PE10.3, any idea where is going wrong ?

    Like

  30. Hello Sir,
    I am trying to program a custom board (KL04) via the Multilink.It worked fine, but then it shows the “Device is secure.Erase to unsecure”.I keep pressing Yes.
    AFter doing this twice the “Multilink” not connected is shown. There was another board that was doing the same.

    But, its now, surprisingly working,except this 1 board.

    I tried the Processor halt utility from P&E micro. Still no luck.Uninstalled/installed PE drivers. No luck.

    Also, no where in the code have I modified that register (FTFA_FOPT or any such dangerous registers:) .

    Infact CODE WARRIOR warns you if you make any changes to such registers.).
    Also, is there any way I can ensure such a message/error does not occur in any future boards. Can this be done via s/w code or so.
    I saw in a ur blog that I can look at the Binary files at the location 0x40C. How can I look at 0x40C. Kindly help me out. This is a disaster as 1 board is beyond recovery.

    Another thing that I am planning to do is inspect the intel hex file before programming it into the controller( the 0x40C frame for disable mass erase). You had mentioned you wld so that in one of your earlier posts. Can u tell me how to read an ihex file. For eg – the 1st line is “:10000000000C002025090000C9080000C9080000F4″
    How do I analyse this. Thank u sir.

    Vinod.

    Like

  31. HI Erich,

    Do you think the KL46Z FRDM board would be fast enough to handle a 320×240 color LCD display and touch panel? If not, do you have any recomendations? I need to update our equipment line and need to determine which MCU to base it upon.

    Thanks again.

    Like

    • I have used the ColdFire JM128 with the TWR-LCD, and that works fine (SPI interface). I have example projects on GitHub (TWR-LCD folder). But the speed of the display refresh is not extremely high (it is ok). For higher speed, you should use a parallel interface. Again, it all depends on what you want to do with it. But a KL46Z is doable.

      Like

      • Thank you. I don’t need high performance. It will just be a control panel for a series of specialized medical devices. I guess I will see if it will work on the KL46Z and also learn more about the ColdFire in case I need to move up. Thank you for your advice.

        Like

        • The ColdFire is just an example. For sure using the KL46Z is more ‘future proof’ and will have enough processing power for the usual tasks.

          Like

  32. Hi,
    If I undestand correctly, the USBDM firmware can be loaded on to FRDM-KL25Z board and also on to the FRDM-KL05Z. ¿Do you know if the firmware can also be loaded on to the FRDM-KE02Z? ¿Do you know if there is some way to program (I’m not interested in debugging) a custom board with a KE02 device using the FRDM-KE02Z? The manual for the KE02z board (FRDM-KE02ZUM.pdf) says it can be done by removing a jumper but I havent read of anyone who has actually done so.
    Thank you.
    Juan.

    Like

  33. Hi Erich ! First I thank you for all your job ! I think if I didn’t find your website,my twr kit would be burned more than one time !

    Currently, I have a problem with a project in CW and I did’nt find the solution after hours crying ! So I tried my chance here !

    The project works fine with the ARM compiler but when I’m reussing the same one with the GCC C compiler I obtain errors ! :s

    arm-none-eabi-gcc: error: ./Sources/PROJECT/../cpu/…/the_file.o: No such file or directory

    The project contain .asm and I suppose that I need to change some settings but I’m a bit lost.
    If you have an idea I will be glad !

    Thanks a lot Erich for all your help !

    Like

    • Hi Jeremie,
      good to hear that things are useful for you :-).
      About your problem: what is the source file name for the_file.o? If it is *.asm, can you try to rename it to *.s (or *.S) to see if this makes a difference? I remember that I had probelms if extension was not *.s (or *.S).
      I hope this helps?

      Like

    • The other thought I have: are there multiple source files with the same base name (e.g. the_file.asm and the_file.c)? If so: I know that CodeWarrior is able to handle that, but not the standard GCC/GNU toolchain. Maybe this is your problem? If so, then try to rename one or the other file to a ‘non-conflicting’ source file name.

      Like

      • I passed two day on it… checking every settings … and it was the extension name !!! It works with the .S !
        Thanks a lot Erich !

        Like

        • Yeah, I think I had that problem too, and as far as I know even *.S was not the same as *.s (even on Windows). Glad to hear that we have sorted that out.

          Like

  34. Hey Erich,
    I’m trying to generate custom signals. Currently it’s a sum of 2 sinewaves, one of 80 Hz and the other of 125 Hz. To get a decent period I need 2000 samples but when I change the KL25Z array size (where I store the data points) to 2000 I no longer get any output from my DAC. If I change it back to something like 500 I get the output that I am expecting by obviously incomplete. Do you have any idea why? Thanks in advance.

    More info: I use static LDD_DAC_TData array to store data points for the DAC.

    -Nick.

    Like

  35. Hey Erich,

    I am trying to get the KL25Z to send data wireless using the Arduino WiFi Shield. I have no idea how to start can you suggest something to get me started? Thank you in advance.

    Best regards,
    Nicola.

    Like

  36. hi..my project is to send the data using bluetooth module.is that possible if i want to connect hc-05 from PIC1 as a transmitter and hc-06 as a receiver at PIC2 ?

    Like

  37. Good day!

    I’m currently using frdm-kl25z board. I was able to test the sample program for touchpad using TSS. In this example, the board will go to sleep mode after several second when no touch is detected.
    You can wake-up the board by touching the right electrode. My question is that, is there a way to wakeup the board by touching either one of the 2 (left or right) electrodes?

    Thanks in advance.

    Like

      • Yap that’s really my question. I just want to know If that is possible. If yes, how to implement that interrupt?

        Thanks.

        Like

        • I’m travelling, so I do not have the data sheet/reference manual with me. I suggest you check in the manual if you can have an interrupt on these pins (either directly or throught the TSS module), and if they are available in your low power mode?

          Like

  38. Hi,

    I am having an issue with the second half of my RAM, in regards to how much space it is taking up in flash.

    Basically as I understand it the sum of the “.text” and “.data” areas is how much flash is being used (.text + .data = total flash usage).

    When I define a normal uninitialized array

    static char myBuffer[16];

    the .bss increases by 16 bytes and the .data area stays the same, which is what I would have expected.

    The issue is when I define an array using the second half of my RAM, the .data size increases by 4096 bytes instead of the .bss area. This seems to indicate the compiler is initializing it to zero and storing 4096 zero bytes in flash (need to check the .map file)

    static unsigned char myBuffer[4096] __attribute__((section (“.m_data_20000000”)));

    BEFORE:

    text data bss dec
    0x2304 0x28 0x310 9788

    AFTER:
    text data bss dec
    0x2304 0x1028 0x310 13884

    Do I need to add a command line argument to stop this happening?

    NOTE: I am using an MK10DX32 which has 8KB of RAM split into two 4KB sections.

    Like

  39. Hello Erich!

    With your help to the community, I am now a fan of Freescale microcontrollers!

    Also, with your great help and I can learn and do stuff, and even the complex ones such as USB CDC with a KL25Z!

    I have done this using Processor Expert as you have explained in one of your blog posts. However, I am a little worried since I don’t know much about it. What are the possible disadvantages of Processor Expert? Can I extract USB CDC code only and use it in a Bare Metal Project?

    Like

    • Hi,
      glad to be able to help out these kind of topics. And good point about Processor Expert: I have started writing up a post about Processor Expert, Arduino and mbed in general, where I see they all fit. And you do not need to be worried about Processor Expert: it is all normal C code it produces, so it is up to you and take that source code and do whatever you want to do with it. So yes, you can extract the USB CDC code and use it in another project (not Processor Expert based) or bare metal project. I think I need to spend more time on that (unfinished) article, hopefully in the next days. Will see, but there is so much I need to catch up after FTF….

      Like

  40. Hey Erich,

    I apologise in advance if someone have already asked this question.
    I would like to know how you can set the ADC to sample at a specific frequency (i.e. 10 kHz)? Do you use a wait() or a timer of some sort?
    Thank you in advance!

    Like

    • Hi Nic,
      Typically, a periodic timer interrupt could be used. But 10 kHz is a rather high frequency, so it would be better to use DMA for this.
      See freescale community docs/DOC-96507

      Like

      • Hey Erich,
        Thank you for the reply. I tried implementing the sampling rate with the periodic timer as it seemed like a better idea to start off. I’ve chosen one of the available interrupt rate of 4 kHz.
        I’m trying to make a simple 2 pole IIR filter with the kl25z but this is what I get at the output; I can’t quite figure out what to make of it. Maybe if you don’t mind you can comment on it: http://imgur.com/XWQ7c3l

        this is my current code for ProcessorExpert.c:
        static uint16_t DACvalue, ADCvalue;
        volatile bool sample_interrupt;
        static LDD_TError Error;
        static LDD_TDeviceData *MyDacPtr;
        double x[3], y[3];
        /*lint -save -e970 Disable MISRA rule (6.3) checking. */
        int main(void)
        /*lint -restore Enable MISRA rule (6.3) checking. */
        {
        /* Write your local variable definition here */
        /*** Processor Expert internal initialization. DON’T REMOVE THIS CODE!!! ***/
        int i;
        PE_low_level_init();
        MyDacPtr = DAC_1_Init(NULL);
        for(i=0; i<3; i++)x[i] = 0.0; // Init the registers
        for(i=0; i0; i–) x[i] = x[i-1]; // Shift the delay register values.
        (void)ADC_1_Measure(TRUE); /* do conversion and wait for the result */
        (void)ADC_1_GetValue16(&ADCvalue); /* get the result into value variable */
        x[0]=ADCvalue;
        y[0]=(((-1.8741)*y[1])-(0.937*y[2])+x[0]-(1.8701*x[1])+(0.8781*x[2]))*0.937;
        for (i=2; i>0; i–) y[i]=y[i-1]; // Shift the delay register values.
        DACvalue=y[0];
        while (!sample_interrupt){}
        sample_interrupt=FALSE;
        Error = DAC_1_SetValue(MyDacPtr, DACvalue); /* Set DA converter output */

        }

        This is for Event.c:

        void TI1_OnInterrupt(LDD_TUserData *UserDataPtr)
        {
        extern volatile bool sample_interrupt;
        sample_interrupt=TRUE;
        }

        Thank you in advance.

        Like

  41. Pingback: GNU Linker, can you NOT Initialize my Variable? | MCU on Eclipse

  42. Hi Erich,

    I am using K60 micro controller. I have a doubt and I hope you will have an answer for it.
    Is there any possibility to know the size of the image loaded to K60 Flash after it is loaded?

    Thank you.

    Regards,
    Jagadeesh.

    Like

    • I think this is a universal question, not related at all to the K60? And I think you are interested in the code size?
      If you have the .elf file, than you know it for sure: just decode it or generate an S19 out of it, and you know it. If you do not have this, and only have access to the flash memory, then you need to analyze the memory. Not sure why you want to do this? Maybe reverse engineering? 😉 In any case: check the data sheet of your device for the flash memory block size (1K byte? 4 KByte? etc). Then go through the flash memory map and check which blocks are erased (all bytes 0xFF), and which ones are not. Count the number of block (of each), and you should have a pretty good idea how large the image is.

      Like

  43. Erich,
    The Kinetis processors have a nice flash architecture that safely allows for field flash updates. Are there any processor expert components that help with erasing and updating one flash block while executing out of the other block, and then performing the swap?
    Thanks,
    Greg

    Like

  44. Hi Erich,
    I am trying to get usb cdc host to work with a Telit HR910 modem which is a cdc device and supports 6 endpoints. I am using the cdc_serial example for the TWR K40 board, But the twr board does not detect this usb device. I have checked all the jumper settings. The K40 board works well as a cdc device connected to my computer.
    Thank you.

    Like

    • Hello,
      I only can speculate that your modem seems to do something which is not handled in your K40 CDC host implementation. I guess you would need to deep dive with a USB protocol analyzer to see what is going wrong?

      Like

  45. Hi Erich and others,

    I need to enable the driver for an RS485 connection before I transmit a char to the serial port.

    I can add a line to the SendChar function, created by PE, but of course the tool will remove it the next time it creates that function. Which otherwise works well.
    What would be nice is an Event called before a start of transmitting, but I don’t see an Event to do that.
    What is the best way to handle this ?

    PS I’m using the OnTxComplete event to disable the driver.

    Like

  46. Hi Erich, i see you updated Processor components library recently, i used older one that i downloaded March 22, i worked with fatFs library. But now it doesn’t work anymore, i don’t know i redownloaded codewarrior, maybe its fault if it was upgraded. Problem: SD card SM1_SPIMaster can’t set two clock rates. Even your example for kl25z board with fatfs don’t work. What i mean don’t work is that when i use f_write to SD card it uses init clock speed 375kHz, and component inspector of SM1_SPImaster don’t accept mode1 frequency any more. SM1_SPIMaster is CW component so i think it’s CW fault.

    Like

    • Hi Tomas,
      I only used a few projects with 10.6 (and run into another problem which I have solved on my end). It is getting late here, but I’ll have a look tomorrow. I saw you posted something in the FSL forum too. I keep you updated.

      Like

    • Hi Tomas,
      I think I see your problem 😦 I had use that project in 10.6, and it worked fine. But you are right: the SynchroSerial component is broken: I had in 10.5 configured it for 375 kHz and 12 MHz. But when I check the values in 10.6, then it shows the values of 375 kHz (ok!) and 375 Mhz (yikes!). As long as I do not change or add values, it seems to be ok. But as soon as I change the values, it will be always 375 MHz, and that’s flagged correctly as an error. So I cannot enter a value 😦
      Is this what you see?

      Erich

      Like

      • Yes exactly! And its not displaying error, i checked SPI clock on SD card with oscilloscope and whatever numbers i write to Mode1 it uses Mode0 frequency anyway.

        Like

  47. Thank you for the great posts regarding MCU. These are very helpful for beginner.
    I have FRDM-KL25Z board and would like to add Bluetooth interface to this board. I want to connect Bluetooth board/module/hardware/adapter to KL25Z, what all options I have ? (I am not very much familiar with Hardware, pinouts etc)
    Thanks

    Like

  48. Hi Erich. I would like to know how I do to save measures from Freedom board in a txt File…I am trying to use ‘fopen’ and ‘fprinf’ but it doesn’t work.

    Like

  49. I am having an issue with your FRDM-K64F_SDK_FreeRTOS project. I have imported it into KDS and I have declared the path variable for the KSDK, but I have the following errors, etc:
    Description Resource Path Location Type
    implicit declaration of function ‘msg_queue_get’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 131 C/C++ Problem
    ‘kSuccess’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 128 C/C++ Problem
    ‘kSuccess’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 140 C/C++ Problem
    implicit declaration of function ‘sync_create’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 140 C/C++ Problem
    implicit declaration of function ‘msg_queue_create’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 127 C/C++ Problem
    implicit declaration of function ‘event_wait’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 114 C/C++ Problem
    implicit declaration of function ‘msg_queue_put’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 128 C/C++ Problem
    assignment makes pointer from integer without a cast [enabled by default] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 127 C/C++ Problem
    implicit declaration of function ‘__task_create’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 147 C/C++ Problem
    implicit declaration of function ‘sync_wait’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 65 C/C++ Problem
    unknown type name ‘event_clear_type’ FRDM-K64F_SDK_FreeRTOS line 112, external location: C:\Freescale\KSDK_1.0.0-Beta\rtos\fsl_os_abstraction_free_rtos.h C/C++ Problem
    ‘kSuccess’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 65 C/C++ Problem
    implicit declaration of function ‘sync_signal’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 56 C/C++ Problem
    implicit declaration of function ‘task_destroy’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 78 C/C++ Problem
    ‘kSuccess’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 78 C/C++ Problem
    each undeclared identifier is reported only once for each function it appears in Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 65 C/C++ Problem
    implicit declaration of function ‘sync_poll’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 70 C/C++ Problem
    ‘kSuccess’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 95 C/C++ Problem
    implicit declaration of function ‘event_set’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 98 C/C++ Problem
    implicit declaration of function ‘event_create’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 95 C/C++ Problem
    ‘kEventAutoClr’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 95 C/C++ Problem
    make: *** [sources/Application.o] Error 1 FRDM-K64F_SDK_FreeRTOS C/C++ Problem
    ‘kFlagSet’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 107 C/C++ Problem
    ‘kFlagNotSet’ undeclared (first use in this function) Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 110 C/C++ Problem
    implicit declaration of function ‘event_clear’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 101 C/C++ Problem
    implicit declaration of function ‘event_check_flags’ [-Wimplicit-function-declaration] Application.c /FRDM-K64F_SDK_FreeRTOS/sources line 107 C/C++ Problem

    Any help on this is greatly appreciated.

    Like

  50. Hello, I have just read you article about the hc 06 bluetooth module. I have bought one of that and I have a very strange bug.
    So I would like to communicate between an atmega8 and my PC via this module. So I set up, wrote the basic code ( without interrupts ) but the communication doesn’t work properly.I want to send a character from the PC and then get back the same character from the atmega.
    So if I send a char then I get back wrong data..BUT If I send constant characters from the microcontroller then I get those nicely on PC, this means the controller doesn’t get the correct characer. I tried with an external crystal (8MHZ) too but nothing changes. (I use the default settings: 9600 baudrate, no parity, 1 stop bit)

    I also tested the module with an arduino, and there worked fine..(I got back what I have sent)
    Could you help me? Maybe I have the same or similar issue like yours?

    Like

      • I have problem when I send data from PC to the controller, I don’t get back the right characters. But when I send directly from the controller then I get them. You had the problem with the module TX pin no? You couldn’t send anything from the BT module, right? I checked my BT module, and I have that diode there too.

        Like

  51. Hi Erich,

    Is there a way to save my data in KL15Z32VLH4 even in power lost? It dont have an EEprom?
    Thank you for your usual support.

    Javer

    Like

  52. Hi Erich,

    Is there a settings in CW that can optimize my code? so i can minimize the size of my compiled binary? Something like disregarding any unnecessary file/code

    Thanks…

    Like

    • Hi Javer,
      yes, by the default project settings (as created by the new project wizard), any unreferenced functions and variables will not be linked. Make sure you have -ffunction-sections and -fdata_sections options set in your project (they are enabled by default).

      Like

  53. Hi Erich,
    I’m an electronic engeneer student in Trieste Italy, and i’m approcing to embedded system trough the KL25Z freedom board that ,by the way, is awsome.
    I’ve done a project with accelerometer, distance meter hc-sr04, temperature sensor with ntc 150k termistor and an lcd 20×4 with a menu controlled by slider for going up/down and a phisical button to enter/exit from/to functions.
    My problem is that i’m not an expert of c coding and i would like to have a better response and sensitivity from the slider. can you give me a hint?
    the link with the project files is

    https://dl.dropboxusercontent.com/u/30331977/ProgettoManhattan2.0.rar

    don’t be afraid from the name of the project, it’s just a joke because for me this project is a bombshell 🙂

    If you don’t understand something contact me whenever you want.
    And by the way sorry for my english!

    Adriano

    Like

    • Hi Adriano,
      unfortunately I cannot help you much on this. To dig through your code would require substantiel amount of time (I do not have currently). Guess you should be as student of my class, because then you will get this as part of the course 😉

      Like

      • Thank you anyway. I will try a couple of solution that i have in mind. Just a thing: i can’t understand how it’s working the flags for the touch, i know that there is one flag named YourFunctionName.DynamicMovement.Direction (or something like this) but i can’t understand how it is working because from the debugger i can’t see it change but it should change if you slide from left to right or from right to left.
        I promise that this is my last question then i will keep studying on my own. 😀
        thanks again
        Adriano

        Like

        • Hi Adriano, I stopped using the touch drivers because there are no sources, and I was not able to get it working correctly. It works sometimes, but not always. I stopped wasting my time with it.

          Like

  54. HI, first of all. nice work ! This saved me a couple of hour trying to start my design ! One quicl question, if I want to add my own command to the shell component. How should I do that ?

    regards.

    Like

  55. Hi Erich,

    Does the timeout component in PEx requires the RTOS to be enable?
    I do it like this.
    TMOUT1_Init();
    handle = TMOUT1_GetCounter(4000);
    res = TMOUT1_Value(handle);
    while (TMOUT1_CounterExpired(handle) != TRUE) {
    printf(“%d rn”, res);
    }
    TMOUT1_LeaveCounter(handle);
    printf(“%d rn”, res);

    Unfortunately it doesn’t work. 😦

    Thanks in advance.

    Like

    • Hi Javer,
      Did you know that there is a help for each component?

      Getting Help on Processor Expert Components


      I admit that the help for my components is not the most complete one, but the Timeout component has a ‘typcical usage’ example.
      For your code you have provided:
      No need to call TMOUT1_Init() as this is done automatically.

      Typical example:
      {
      TMOUT1_CounterHandle timeout;

      timeout = TMOUT1_GetCounter(500/TMOUT1_TICK_PERIOD_MS); /* 500 ms timeout */
      for (;;) { /* will timeout */
      /* do something here */
      if (TMOUT1_CounterExpired(timeout)) { /* check for timeout */
      break; /* break for loop in case of timeout */
      }
      } /* for */
      TMOUT1_LeaveCounter(timeout); /* release timeout counter */
      }

      What you probably missed is to call TMOUT1_AddTick()? You need to call this with the frequency specified in the properties (e.g. every 10 ms). This can be done from a timer interrupt. Or from the RTOS tick counter. But you do not need an RTOS for this.

      For more examples, google for
      mcuoneclipse github TMOUT1_AddTick()

      I hope this helps?

      Like

  56. I just start working on embedded system programming.
    I saw many IDEs on Windows. But I want to work on Mac, And I think Eclipse is the best choice here.
    But I have no experiment to setup tool and config to make it work. Everything just looks to complex for me
    I have an IAR kickstart kit for Cortex M0.
    Where should I start, I try to search through but not much how to for Mac.

    Like

  57. PROBLEM WITH FREESCALE CDC DEVICE ON FRDM-K64F…
    Hello Erich,
    after implemented the Segger OpenSDAv2 on my FRDM-K64f board, and after builded a little project with FSL_USB_Stack component as CDC device on CW MCU 10.6 (re-writing an old proj running perfectly on KL25Z MCU, i have ecountered problems to install a right device driver on my windows vista 32b machine for new usb interface presented by K64 mcu.
    The procedure show on Documentation folder (cdc.inf, cdc.inf_readme.txt) not run on my Vista 32b machine… may be? (“device not recognized” after driver installation)
    The version of Freescale USB Stack is 4.1.1 (as CDC device).
    Can you help me, please? tnx.

    Like

    • Hi Antonio,
      the port for the K64F is simply not working yet. I started working on it a few weeks back, but it is not operational yet. Simply not having enough time to debug it 😦
      Erich

      Like

  58. Hi Erich,

    Do you have any example of using TSI without using TSS library. TSS library is very huge make my code bigger and bigger . Besides sometimes it didn’t function well. 😦

    Thanks for your usual support.

    Like

    • Hi Javer,
      I stopped using the TSI library, because it is closed source and not easy to use. And as you say it is huge and complicated. I used an external capacitive touch IC/controller for two of my projects instead.
      I do have a simple example doing simple touch (touch button) detection, but without any special filtering/etc. But that has been a while back.
      Erich

      Like

  59. I have been hired by a to-be rapid prototyping centre’s management and am required straight away to suggest some development/evaluation kits that would be helpful in developing prototypes. The problem is that I don’t know the specific requirements of the prototypes order we’ll get and thus I need to select handful of general purpose kits. Do you have any suggestions as the variety of products (hundreds of them from each supplier) confuses me. e.g. Tower system and freedom development platforms have a lot of products from freescale and similarly products from TI, Atmel, STMicroelectronics etc.

    Like

    • I have spent a great deal of time the last several months sorting through hundreds of MCU kits and can offer a tiny bit of guidance.

      1. You can’t know everything about all the MCU architectures out there so narrow it down to one or two to learn about. Because 32 bit ARM is hot and growing and cheap, I have just stuck with that.
      2. You can’t know everything about all the ARM silicon vendors. It seems to me that Freescale, NXP, and STM have the broadest variety of ARM MCUs.
      3. Some of the MCU eval board vendors that seem to have a good selection are:
      http://microcontrollershop.com
      http://www.embest-tech.com
      http://www.wvshare.com

      The Freescale Freedom boards are an excellent starter platform.

      The STM32F429i Discovery with TFT touch screen is a great value at $24 from Mouser.com. The STM32F line has lots of good cheap options. Their Nucleo STM32F boards are only $10.

      I also like the LPC4300 series from NXP because they have two (or 3!) MCU cores on the same silicon which is great for anything that requires a lot of I/O or graphics. (Some of the LPC4300s actually have an onboard graphics controller.) And there are some very good and inexpensive starter kits available with them.

      You can get the NXP LPC4370 (THREE CORE!) chip on a neat little board for $20 from Mouser. This board can be used as a JTAG programmer or a development board. You’ll want two of these boards to if you want to do development with it.

      With three core technology so cheap and powerful, I expect the market for it will increase greatly within the next 12 to 18 months. In my case, I feel I might as well learn about it now so I can keep up with the curve.

      I also expect there will be a lot of new development boards to come out over the next 12 months or so, so there will always be a need to keep informed. But if you have a couple of favorite vendors and chips, you should be able to find the boards you need to do your new job.

      Congrats on that, by the way.

      If you come up with any better alternatives than I mentioned above, I would be grateful if you posted them.

      Thank you.

      Like

      • One more thing, make sure you know which IDE you are planning to use before you make a suggestion or purchase. If you are planning on mainly using free IDEs, make sure the one you choose works with the board you are suggesting, and that there are no code size limitations.

        And, if you want to do anything other than plain C coding (such as using a graphics library, bus driver software, or anything else) make sure it all integrates with your IDE. I have spent a great deal of time the last few months trying to sort all that out as well. It can waste a LOT of time if you don’t know what you are doing. (I speak from experience. 😉 )

        Like

  60. I had a very simple project last week needing a micro.
    I pulled out an old friend, MC9S08SH8. 20-pin DIP, and programmed with USBDM under CodeWarrior 10.6.

    It was like a breath of fresh air after working with these newer, infinitely more complex chips.
    -Bill

    Like

  61. Hi Erich or other :p

    I have a problem with my FRDM – K64F. I wrote a code in eclipse in c++ and everything works well. However, when I’m trying to have the hardware fpu instead of the software, my cpu hangs. I’ve put the code on github if you want to see.

    https://github.com/ediukill/Hexacopter.git
    Sincerely,

    Like

  62. Hi Erich,

    I have a timer with period of 30us and i want to communicate with uart.
    But, when I a wait, for example WAIT1_Waitms(500); it stucks there. So I have to disable that timer and perform the wait and after it enable timer. But this isn’t the solution that I want because I need timer too.
    So I think that the solution is to implement dma on uart.

    So, can you guide me how to implement uart with dma on kl25?

    Thanks a lot for your work 🙂

    Like

    • When you do the WAIT1_Waitms(500), it will loop there for 500 ms. Your interrupts are still there and working. But this waiting for 500 ms will be a waiting time without the time spent in the interrupts.
      So if you do heavy work in your interrupt (and 30 us are quite a lot of interrupts), then it will wait for 500ms *plus* the time you spend in the interrupt(s). Maybe this is your problem?
      If you need to wait for 500 ms without the impact from the interrupts, then you need to do a different approach: either use an RTOS like FreeRTOS which will do preemption, or use the TimeOut Processor Expert component I have created.

      Like

        • Using the TimeOut component is pretty straigt forward:
          a) add it to your project
          b) Call the AddTick() method from your application.
          For b), use a frequency as specified in the Timeout component properties (Counter tick period (ms)), default is 10 ms (100 Hz).

          I hope this helps.
          And I’m not using UART with DMA, so I had no need for this.

          Like

  63. Hi Erich,

    I am trying to learn how to program freescale microcontrollers using their Processor Expert with little success.
    I have been able to select my board’s MCU, configure all its components and generate Processor Expert code in C.
    The problem comes when I try to build the binary file for the C program.

    What I want is one simple *.bin file that I can drag and drop onto the board when I connect it to my PC via USB (I’m using 64-bit Windows 7).

    I think that I have set up Processor Expert wrong or I do not have the correct ARM compiler/linker/assembler on my machine (or perhaps eclipse is just unable to find them)

    What step-by-step process do you recommend for installing Processor Expert, downloading and configuring the compiler/linker/assembler to work with eclipse, building a binary and loading it onto a board?

    I’m using 64-bit windows 7 and Freescale’s MK60 family of processor (on a custom board).
    (If you’ve already written about this please redirect me)

    Thanks,

    Ryan

    Like

  64. Hi Erich

    I am working on KL26Z USB composite device with keyboard and media keyboard.
    But, PE component only can generate individual HID device.
    How can I create a composite device through PE?

    thanks.

    Like

    • Hi Kyle,
      I have not done that. I know that there is a combined example in the USB 4.1.1 stack, but I have not used it. I started to build a combined USB HID+KBD device, but have not finished it because of other work items.

      Like

      • Hi Erich
        Thanks for your reply.
        Yes, I know there is a combined example in the USB4.1.1 stack.
        But it is not built by processor expert, I hope I can based on PE USB stack to add composite function.
        Because processor expert is very help when develop applications.

        Looking forward your good news.

        Like

        • Hi Kyle,
          Yes, it would be possible to create a Processor Expert component for that. Actually everyone could do that. And it could be even a ‘USB device construction kit’ where you can say “I want USB CDC combined with MSD, and hey, add HID mouse to the mix”. Very well doable. But someone needs to spend the engineering hours actually doing it. Would be a pretty nice week-end project. Unfortunately I only have a number of week-ends every year, and they are already filled up with work. Any volunteers out there?

          Like

  65. Hi Erich,
    I have a question about FreeRTOS 8.0.1 in the latest PE from July 13. I’m using CW 10.6 and a K20DN64. When I include FreeRTOS it is getting an error on the FRTOS1.c &.h files in the huge comment header at the beginning. What it is doing is putting a secondary comment on two lines like this:
    configCPU_CLOCK_HZ : CPU_CORE_CLK_HZ /* CPU core clock from Processor Expert Cpu.h */
    &
    configBUS_CLOCK_HZ : CPU_BUS_CLK_HZ /* CPU bus clock from Processor Expert Cpu.h */

    of course the trailing “*/” is causing the remainder of the comment header to be treated as source and generates lots of errors.

    I’m also getting an error in Port.c at this line:
    SET_TICK_DURATION(TIMER_COUNTS_FOR_ONE_TICK-1UL);
    The reason is CPU_CORE_CLK_HZ is not defined. I can fix this error by adding
    #include “cpu.h” to the file.

    I have modified the files to get a clean compile but each time I add or change a PE component it overwrites them again. I guess I could exclude them from the build?
    Am I doing something wrong here? If needed I can send you these files, screen shots or the whole project.
    Thanks

    Like

  66. Hi Erich.
    Can you helping understand how Zigbee works?.

    I’m currently working on a project, and well, It didn’t go as I’ve through.
    I don’t understand how to use ZCL and how It managed to use multiple endpoints.

    Do you have some note or documents I can use for it?

    Thanks for Advanced.

    Like

  67. Dear all,

    I am using Eclipse Luna with GNU ARM Embedded Toolchain to build Kinetis MK21F12 projects. Since I want to know exactly what happens when compiling my code, I use a self generated makefile and linker script for building my sources.
    So far everything worked as expected. But now I am trying to get newlibs printf() working to use it as a debug console. As long as I type printf(“This is an example.\n”) everything works fine. Typing printf(“This is an example.”) causes and hard fault exception. When using int tmp = 1 and printf(“This is a number: %d”, tmp) to write an integer I get the same hard fault exception. I adapted syscalls.c to fit for my application. Communication uses a standard serial interface.
    As long as I use the bare UART interface, everything works as expected.

    Is there anybody who had similar problems using newlibs printf()?

    Best regards,
    Philipp

    Like

    • I solved the problem by using newlib-nano instead of newlib by adding the linker flag -specs=nano.specs.

      It seems to me that I had some major memory problems regarding heap and stack sizes. I’m going to figure out the exact reason why I have received these errors.

      Best regards,
      Philipp

      Like

  68. Hi Erich,

    Good day.
    Can you share some example code on how to enter LLS mode using processor expert “(i dont have an external reference clock)”. Im having a hard time setting all parameters in CW. 😦 .. Also my problem is to wake-up from this LLS using TSI interrupt.

    Thanks you very much.. Hope you can help me…

    Like

  69. Hi Erich,
    I just come to embedded system for about 4 months. I don’t have much basic knowledge.
    Although at this time I can come up with how to use tool, and develop some basic application ( almost base on my software experience and code example I can find online )
    At this time I feel that I need more basic knowledge. But I don’t know where should I start.
    Can you give me some suggestion about book or course for embedded system.
    I currently work on STM32F0
    I have a STM32F0 evaluation board, Nordic bluetooth evaluation board, arduino, raspberry and some custom build board of STM32F0 that I got from my friend old project.
    Thank you so much

    Like

      • Hi Erich,
        I currently got in problem when using ADC to record audio and then play back use DAC. It’s kind of have electronic noise in background. I don’t know if my code did something wrong. or it’s problem of hardware.
        Do you have any suggestion for my situation.
        It’s a custom board.

        Like

      • leobin1989,

        You may also want to check all your ground paths. There might be a loose connection.

        Do you have any ripple on your DC lines?

        You may want to try putting a variety of filter caps across all of your chips and power supply inputs.

        Like

    • Hello Tran,

      For just starting out, I think getting a couple of Freedom boards from Freescale and then following Erich’s tutorials is a great place to start.

      I have been trying to learn the STM32 line for the last few months and have found that all of their example programs require paying several thousands of dollars for an IDE. They don’t have anything for eclipse.

      After you get familiar with the Freedom boards, you may want to learn about the NXP line if you need more MCU power. They have a free IDE and some MCU chips with two or three MCUs inside the same chip, specifically the LXP4300 series.

      But, if you don’t need high speed I/O, video processing and computation all at the same time, the Freedom boards will go a long way for you, and Erich’s blog here is the best I have found in the last three and a half years of web surfing the MCU educational marketplace.

      Liked by 1 person

      • Thank you for your suggestion.
        But as I told above. I already bought some board. And the product of my boss is use stm32 too.
        And for IDE i think that the free edition of keil is good enough for me. Although It’s kind of not good enough in key shortcut. So I only use it for compile my code. I use an IOS IDE name Appcode as editor.
        They will have a special edit for C at the end of this year. So I’m good with this.

        Like

      • Good luck on your projects. I hope it works out for you.

        Unfortunately, I wasn’t able to use the Keil IDE because the free version is too code size limited. And the cheapest general version was about $3500, if I remember correctly.

        Like

    • Yes, indeed a nice board. I have used so far the NXP PCA9554 I/O expander in several of my projects. I have a Processor Expert component for it too. I prefer it over an SPI based I/O expander it is much easier to be used. Of course, SPI would provide higher speed, but this was not needed for my use cases (checking buttons, toggling relais and LEDs, etc).

      Like

  70. How do you to view the version of component installed/imported on CW MCU 10.6?
    I try any options of views of Components Library and Components Inspector, but without succes…

    Like

  71. MEMORY BUDGET
    Hi Erich,
    in the old version of CW (tipically for S08, S12 mcu), i remember an utility very good… the amount of memory engaged (RAM and FLASH) by the project under development.
    Is possible to activate a particular perspective/view on CW MCU 10.6 (or KDS) to obtain same informations about my (K64F) project?

    Like

  72. uint8_t buff[64];

    void storeData(){
    int i=0;

    if (RxBuf_NofElements()!=0) {
    SendString((unsigned char*)”stored data is: “, &deviceData);
    while (i!=sizeof(buff))
    {
    unsigned char ch;
    (void)RxBuf_Get(&ch);
    buff[i]= ch;
    i++;

    }
    SendString(buff, &deviceData);
    SendString((unsigned char*)”\r\n”, &deviceData);
    }

    }

    i did it thanks the problem is that
    if i write a characters lesss than 64,
    eg hjlk
    it will write k to fill the array up
    hjlkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
    which is n ot what i want.

    Like

  73. Hello Erich,

    I get this eror from CodeWarrior 10.6, when I try to build FRDM-KL25Z_USB_DCD_Shell and Freedom_UsbCdc.

    Description Resource Path Location Type
    Generator: FAILURE: Unexpected status of script: Drivers\Kinetis\Kinetis_ProjectInfoXML.drv, please contact Freescale support. Freedom_UsbCdc _PE_ProjectInfo Processor Expert Problem

    File Kinetis_ProjectInfoXML.drv was not referenced in .ProcessorExpert.g_c.
    It generates elf, but I was just wandering is this some licence problem or some settings.

    Thanks,

    BR,
    Zoran

    Like

    • Hi Zoran,
      not, that is not a licensing issue. More of something Processor Expert internally. Are you using my exact projects from GitHub? And do you have any MCU10.6 updates installed?
      Erich

      Like

      • Yes, its your projects and your PEupd files from git.
        Its just CodeWarrior 10.6:
        Installed Products:
        – CodeWarrior for MCU
        Version: 10.6
        Build Id:140329
        Part1_Beans_19.09.2014.PEupd
        Part2_Beans_19.09.2014.PEupd
        I also installed USB_STACK_V4.0.3.exe and Imported that components.

        Strange thing is that In Processor Expert view on USB1:FSL_USB_stack it says its v4.0.2.

        Like

      • Now I got USB1:FSL_USB_stack to v4.1.1 (reinstaling Part1_Beans_19.09.2014.PEupd and
        Part2_Beans_19.09.2014.PEupd).
        But still, I get same “error”.
        Its not a big deal, since I get elf file anyway.
        Thank you for reply :-).

        BR,
        Zoran

        Like

      • Ok, there is one way, that it will not display this error:
        Build Project>Close Project>Open Project>Build Project>no error
        Clean Project>Close Project>Open Project>Build Project>error
        Clean Project>Close Project>Open Project>Build Project>Build Project>error
        I guess its this CodeWarrior IDE bug.
        Thank you, we’ll talk on another page 🙂

        Like

        • Hi Zoran,
          I remember that there was an issue with Processor Expert a while back, and it sounds like it is this problem. But for me that problem was fixed in 10.6.
          So not sure what is causing this for you.
          Erich

          Like

  74. Hi Erich
    Your blog is really interesting and helpful, tou give really good tips.So, I felt free to ask you if you’ve already worked with TRF7960atb and a FRDM KL25Z. I’m trying to develp the code to connect both devices, but it is really hard for me, since I’m a begginer with codewarrior, and not that much experient with C. Do you have any tips for me?

    Liked by 1 person

  75. I’m trying to compile your blink example for the KL25Z using the included makefile. I’m getting the following error:

    /usr/libexec/gcc/arm-none-eabi/ld: LED_Toggle_flash.elf section `.interrupts’ will not fit in region `m_interrupts’
    /usr/libexec/gcc/arm-none-eabi/ld: region `m_interrupts’ overflowed by 36 bytes

    I’ve looked in the .map file and though I don’t really understand how to read it it appears to be allocating an extra 0x24 bytes for… something… before the vector table.

    .interrupts 0x0000000000000024 0xc0
    0x0000000000000024 __vector_table = .
    0x0000000000000024 . = ALIGN (0x4)
    *(.vectortable)
    .vectortable 0x0000000000000024 0xc0 ./Project_Settings/Startup_Code/kinetis_sysinit.o
    0x0000000000000024 InterruptVector
    0x00000000000000e4 . = ALIGN (0x4)

    Any thoughts?

    Like

  76. Hi Erich,

    Basic quaestion here, but I need help.
    I can’t make your Quadrature component work. Well, I don’t know how exactly use it.
    Any sugestion advice?
    Thanks in advance.

    Like

  77. How i can initialize the MMA8451Q component?, I don´t use a SHELL, and I initialize a I2C_LDD. But I don´t now how to configure the components. You done a great job with this blog, I´m from Mexico and I read every post ;D. Greetings!

    Like

  78. I am guessing this is on the Freescale website, but cannot find it anywhere.

    Does The Kinetis Design Studio (KDS) have a code limit / licencing model like CodeWarrior (CW)? as the free version of CW (i.e. Special Edition) only allows 128Kb for the K series.

    Also as you can install and use the PE component manager / designer as a standalone is there a licencing model attached to this?

    Which is the best IDE to use in your opinion?

    1) CW – Code size limit
    2) KDS – not sure what constraints this has??
    3) A self configured Eclipse with PE installed (i.e. Eclipse Kepler and GNU ARM Embedded tool chain)

    is there really any reason to use KDS or CW as it is reasonable easy to configure Eclipse Kepler and GNU ARM Embedded tool chain and install PE as you have shown in a blog post.

    Thanks

    Like

  79. Hi,

    I have run into an interesting issue with CW 10.6, I have selected the following options in the project properties:

    “Create Flash Image”
    “Create Extended Listing”
    “Print Size”

    But when I do a build only the elf file is created and there are no errors displayed in the console window but the flash image is not created nor is the size information created.

    I have several other projects that have these options selected and they work fine (i.e. the image is created and the size information printed out in the console).

    Can anybody suggest other options to check as this seems like a project properties issue?

    Thanks

    Like

  80. Hi Erich,

    I started using a FRDM KL25Z and I would like to thank you because your blog has been helping me a lot!
    I’m trying to deal with a 2×16 LCD display and I used your LCDHTA component. I need to go foward and back with the cursor. I saw that the component does not have this function. How could I write a function to make this and add it to the LCDHTA component?

    Thanks in advance.

    Like

  81. Hi Erich,
    a small question about problem-programming with CW MCU 10.6 (or KDS) over a kinetis mcu (but is a generic problem..):
    – is it a method to write into a variable, (but also into flash memory), the time-date of system pc when build the project? I need to know the date-time of last building/flashing to mcu…

    Like

  82. We have a project to be designed and quotation.
    Pls provide e-mail address that I could be written Inquiry letters.
    And do you have Asian area agents may contact ?

    Like

  83. Hi Erych,

    I have an issue modifying my component for the FXOS8700CQ sensor (accel/mag combo). I implemented the use of the internal FIFO but when I don’t want to use the FIFO, I uncheck the box to disable a group with different properties. The problem is, I have references to some properties in my .drv file (to generate the header file) and I don’t know how to remove these references when the box is disabled.

    Here is what I’ve done :

    #if defined(FIFO_MODE)
    #define %’ModuleName’_FIFO_MODE %FIFO_MODE
    #endif

    But %FIFO_MODE is not defined when I don’t use FIFO so the code generation can’t work.

    To you have a simple solution ?
    Thanks !!

    Like

  84. Primarily, thank you for your library. I tried run TFT screen that driving with ili9341 but i coudn’t. Do you plain any tutorial for TFT screen or what must i do ?
    Thank you for everyting .

    Like

  85. Hello again Erich, I’m currently using the mbed system to program some KL25 and Nucleo boards hopefully with the prospect of making a commercial product. Are the Freedom boards able to be used in applications where you sell them or are they for evaluation purposes only. I don’t really want to get too involved in the hardware side and hope to just fit shields and sensors to a ready made platform. I’ve asked this question on mbed but thought I’ld ask a guru as well.
    Cheers
    Mike

    Like

    • Hi Mike,
      Personally, I would not use the FRDM boards for a commercial product. The boards are for evaluation purposes. Sure you can use them for a small batch of ‘proof of conecpt’ boards (I did the same), but if you are going after >20 or >50 boards you probably are better positioned with your own board: you can make it smaller, have only the components on it you need, and you can provide proper warranty. Keep in mind that for a commercial product you need to comply with rules and regulations (CE, safety, etc) too. Same thing applies to other boards like Raspberry and BeagleBone. I know that especially the BeagleBone is used for commercial products, because that board is much more complex and difficult to produce yourself. The FRDM board is really, really simple compared to that one. The other thing you need to keep in mind with evaluation boards is that they might change or not be available any more. So what happens if you need to deliver 500 for your products and cannot get them? But again, for a small batch: why not. For everything else you need to think about doing things differently.

      I hope this helps?
      Erich

      Like

      • I love the BeagleBone Black. For $55 US you get a complete industrial Linux computer with lots of IOs, and which fits into an Altoids tin. It also has lots of add-on boards (capes – named after the “cape” that Underdog wore).

        I expect it will be a market leader for the next year or two and hang around for years to come.

        Who can guess what will come after that? A Linux, Mac, and Windows computer with monitor and 1 Tbyte ramdrive that you wear on your wrist and comunicate with via Bluetooth enabled brainwaves?

        Then 3 years later, perhaps an implantable computer that not only lets you communicate via the Internet of things, but has the capacity moderate ones neurotransmitters and body hormones, and connect everyone to a central world government computer?

        Oops. No, wait. That’s from a story I just read.

        😉

        Like

        • Yes, I love my BeagleBone Black too. It is just that I did not had much time to play with it. The BeableBone board is small, inexpensive and has a lot of processing power. It is so good that I see companies buying many boards, and some vendors restrict orders that you only can order one board at a time. Because the boards are so popular, other vendors have started to manufacture them to fullfil the needs. Definitely an interesting board. There are already some small implantable computers available today, but not to the masses in 3 years 🙂

          Like

  86. I have used a few components from MCUoneclipse and would like to look at and possibly modify the PID component source. Before jumping into the CDE I wanted to ask if this is allowed and if there is tutorial on this?
    Thanks

    Like

    • Hi dale,
      yes, this is allowed and even encouraged :-). I do not have a tutorial on PID. If you are asking about a tutorial on CDE, there is one here:

      Tutorial: Creating a Processor Expert Component for an Accelerometer


      However, all the components on this site have been created with the previous ‘BeanWizard’, because the Eclipse based CDE was not compatible with the older components (or even corrupt the components).
      So be free changing things, but if you contribute back, we need to be careful not to break anything.

      Erich

      Like

  87. Hi Erich
    I try to use KDS build a MK22FN128xxx12 project with PE.
    But I have to enable KSDK when I want to use PE.
    If I choose MK22FN256xxx12, I can only use PE without KSDK.
    What is going on KDS?

    Like

Leave a reply to Maxim. Cancel reply

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