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. I need to interface frdm-fxs-multi sensor board with frdm-kl43z kinetics MCU,before interfacing these two boards i need to get the best interface between these two boards.And also what is the best serial termination port in frdm-kl43z board?? USB or RS232??…Can we see the output of sensors in LCD otherthan 4X2 segment LCD??…Is there any power adapter coming with this MCu pack???.

    Like

  2. Hey Erich,
    I want to interface DHT-11(Temperature and humidity sensor module) with my frdm kl25z MC.
    Is there a library available for that? Or could you help me out with it ?

    Like

  3. Hi Erich,

    What is the future in your opinion of the Freescale Kinetis range now that NXP will buying Freescale as when the bean counters and business NBA types bet involved i can see them making 50% of the staff at Freescale redundant, which will likely mean poor product support and or a reduction in the number of Freescale products.

    Is it time to look for another go to ARM micro controller? maybe Atmel, Cypress or TI

    Like

    • Hi Andy, I think it is simply too early to know about this. The good thing with ARM controllers is that they are the same on the core side, so moving from one ARM family to another is not that big of a learning curve. Of course, the work is in the peripherals which are different.

      Like

  4. Hi Erich,

    I am new to Eclipse/KDS, and am trying to port portions of an application to a FRDM-K64F. All has gone well, as far as the porting is concerned, thanks in large part to your tutorials, except that the resultant elf file is apparently too large – over 1.5MB – and will not deploy for debugging. (at least size seems to be the problem)

    However, I’ve found that linking with the “Omit all symbol information (-s)” flag results in an executable that is only 75KB! That’s a lot of debug information 🙂 And most of it is symbols for generated processor expert code that is already solid, and that I don’t need to debug.

    So my question is whether or not there is a way to selectively control generation of debug information for various source files, and/or if you’d be kind enough to explain how to build and use a separate symbol file with KDS – if that would work.

    I tried to build a separate library, thinking I could just compile it with debug information, and the other not, but it’s size was huge – 4MB. (not sure what I did there).

    I’m thinking there should be plenty of room to deploy and debug, if the only symbols loaded are those for my code.

    Is there a way to do this?

    – Ben

    Like

  5. I am curious as to the preferred image format when sending that image over some communication method to a bootloader, which is then used to place the image contents in flash. I have read about various choices from bin to srec to intel hex and cannot see a good reason for one over the other since the image will have the size and CRC embedded in the image Thank you in advance. =)

    Like

    • Hi Rob,
      S19 and Intel hex files are very comparable. It all depends on what your build tools are able to generate easily, and the file parser you have or want in your bootloader. Personally I prefer S19 files, as more ‘readable’ for me as a human. Intel hex are ok too. From the overhead are both files about the same. Just keep in mind that with S19 and Intel hex basically every code byte is encoded in *two* ASCII bytes, e.g. the byte 0x12 will be ‘1’ and ‘2’. So if communication bandwidth is a concern, you should transmit the Intel Hex/S19 in a binary (and not text) format.

      Like

      • What is your opinion of binary files? I only see a potential con of not having addressing tied to the bytes in the file (Which the bootloader will know the starting address). Without that tying to bytes, one only loses the ability to fragment an image without required filled data (wasted transmission to achieve it). The binary is also readable with a hex editor.

        Like

        • Yes, because of the gaps not handled efficiently with binary files I usually do not use them for bootloaders. For production programming they are fine, as speed/bandwidth is less of a concern.

          Like

  6. Erich,

    Do you know of any sample code for *interrupt-driven* i2c slave mode on a KL25Z? The driver in MBED is only able to use polling, and that’s useless when there are other tasks to perform in the background.

    Like

  7. I don’t want to install another eclipse. I have one eclipse installation where I can develop code for the PC and I added all the necessary to program STM32F mcus and I’d like to “add” to this installation all the necessary to develop for the kinetis mcus.

    Is it possible to integrate KDS to an already existing eclipse installation since I don’t want to install another eclipse just dor the KDS?

    Regards.

    Like

  8. Hi Erich,

    I have a tower twr-k70f120m and I want to use USB port of the TWR-SER module. I use KDS with Processor Expert.
    I followed your tutorial, but when I send a word (like QWERTY) on the terminal, I receive only the first character (Q) of the word after “echo:”
    When I debug, I can see that ” in_buffer ” contain only the first character.

    Could you help me please?
    Thank you.

    Like

  9. Erich,
    I’m trying to use SPIMaster_LDD with Macronix MX25L6406E on a custom board running MK22FN1M0VLL12 connected to SPI0 (PTA14-17) and I’m having trouble reading data from the flash. I have doubts about the timing configuration, which are set as follows:
    Clock rate: 374.491kHz – 10.48576MHz
    delay, CS to CLK, & CLK to CS delay: 0.095367 us

    Any thoughts or insights?

    Thank you

    Like

      • Couple of things did not understand with the logic analyzer output: 1) The MOSI seems to be sending ‘5’, ‘0’ irrespective of the byte I’m sending. 2) The CS signal seems to pull up right after sending while still the application is blocking and waiting for response. I did look at the configuration of the CS and it is not checked to toggle CS after each byte and actually I checked to see if it makes any difference but it did not. 3) Never seen data coming back on MISO.

        Like

        • Are you looking at the correct signals? Does the clock make sense? And if you step through the code, does this reflect some output on your MOSI pin?

          Like

  10. Erich,
    Being new to embedded programming and the required tools, this may be a simple question but how can I configure a FRDM-KE06Z board and Eclipse to work with a PEMicro Multilink debugger rather than OpenSDA? I’ve found in the user guide that the J7 header can be used for SWD protocol and I’m able to find the board in Processor Expert but I must be missing some steps since I keep getting debugger configuration errors. Any suggestions on how to proceed are appreciated.

    -Chuck

    Like

  11. Erich,

    I mistakenly removed R58 from the board, once I replaced it, all is good. I inferred the solution from your reference where a similar issue could occur if a trace was cut.

    Thanks,

    Chuck

    Like

  12. Last year(?) you did an article that included getting the runtime stats from freertos. I’ve searched all over your site but now I can’t find it. I’m trying to figure out how to setup the RuntimeCntrLDD required.
    Thanks

    Like

    • The latest version of the FreeRTOS component does not need a timer (LDD) any more for the runtime statistics for ARM: it is able to re-use the Systick timer register for this. To enable runtime statisics, turn on ‘Use Trace Facility’, enable ‘Collect Runtime Statistics’ and have ‘Use Tick Counter’ set to ‘yes’ in that group.
      For non-ARM devices, simply configure either the LDD or non-LDD timer, and use a frequency of about 10 times faster than the FreeRTOS tick counter.
      I hope this helps.

      Like

    • Yes, nothing prevents you to use the DS18B20 temperature sensor with any microcontroller. It is all about the driver/software :-). There is a contributed Processor Expert component for it, but I admit I have not used it.

      Like

  13. I noticed all the kinetis mcu’s flash speed is not up over 25Mhz, but for some mcu with high speed up to 120MHz or 180MHz, will the flash speed slow down the system’s run speed ?
    should we copy some code needed run in fastest speed to ram ?

    Like

  14. Hey. i found your site great resource for MCU on eclipse, DAAA!
    any way, i made it to run eclipse install wizard, but running cwide does nothing.
    i cant find any solution for that.
    running the script in the installation folder shows me some warning about morphoXPCOMPlugin.
    please advice.

    thank you.

    Like

  15. Hi,

    Anybody know where the recommend footprint for the Freescale Kinetis range is hidden?

    I have found the following website:

    http://www.freescale.com/webapp/search.partparamdetail.framework?PART_NUMBER=MK20DN32VLF5&buyNow=true&fromSearch=true

    which contains the following pdf which is of no help as it does not contain the pad length and width.

    Click to access lqfp48.pdf

    I am specifically looking for LQFP 48 7*7*1.4P0.5 the website contains a *.dra* file which i cannot open as i don’t own a copy of Cadence Allegro.

    Thanks,
    Andy

    Like

    • Hi Tom,
      So far I had no need for I2S, so have not used it. But it should not be more difficult than I2C? As for that board: Unfortunately I do not have that one, so I cannot try it out.

      Like

      • it seemed far more difficult than i2c to me actually, more pins, dma buffers to deal with, (not to mention the PE stack overflows on the osx version of KDS 😉 ) and so on. The wolfson chip actually uses i2c for its configuration and this part was the easy bit to set up. I’ll happily buy you that board if your interested, least i could do in return for all i’ve learned here

        Like

        • Hi Tom,
          Let me check my contact at MikroElektronika, I should hopefully be able to get a board. But not sure when I will be able to get a handle on it. For sure next week I will attend the Freescale FTF in Austin, TX, and won’t have any time 🙂
          Erich

          Like

      • Well no rush at all, thank you for even entertaining the idea! and if MikroElectronika wont give you a board as i say i’ll happily get you one, Enjoy the freescale FTF!

        Like

      • Hi Erich, just wondered if you ever managed to get your hands on one of these audio boards?
        Also have you used the ethernet on the K64F at all, a tutorial on using that with PE would be really great.

        Like

        • Hi Tom,
          no, nobody donated me such a board ;-). Seriously, I would not have had the time (gee, I need to work harder I guess…). Why do nights only have a limited number of hours and weekends are too short :-(.
          Ethernet on the K64F is on my wish list for a very long time. Again, no time for it.

          Like

    • I know the feeling Erich 😉 That being said I will happily donate you a board if you would like one. I assume you have my email from these comments so if you drop me a line with your address i’ll buy one for you.
      One of my issues with freescale is that they provide something as great as PE but then use it in none of the examples that they provide, their ethernet examples for the K64F are seriously limited imo.

      Like

      • Yes, thank you for that offer. But I did not want to take advantage of it, as I simply do not see any chance to get me hands (or head) around that audio board. I’m no Ethernet expert by any means, but: what are you missing in the current examples? My thinking was to get an lwip stack running on the K64F. There is as well the FNET stack (http://fnet.sourceforge.net/) which I considered using. Any thoughts?

        Like

      • FNet seems really great because of all the functionality it offers (update over ethernet would be fantastic for example) and the provided examples work fine once you have run them through the upgrade assistant, however if you try to add FNet to a KDS/PE project it will fail on initialization. Calling fnet_init(&init_params) fails in fnet_eth_io_init() and will trigger the WDOG_EWM_IRQHandler(). I think this is related to the interrupt vectors and the instructions at the end of this page http://fnet.sourceforge.net/manual/how_to_add_fnet.html but im not sure how to apply that to a KDS/PE based project

        Like

  16. Hi Eric,

    I am using the ADC module on the FRDM-KL05Z dev board to perform conversion on a pin. i am able to initialize and successfully use it from the main loop using AD1_Measure(TRUE). I have a timer interrupt running as well every 2 secs. The moment i transfer the ADC measure from main to this interrupt, it stops working.

    I made sure the interrupt works by itself by blinking a LED. I am not sure why calling the ADC measure function from the timer interrupt wont work and I am running out of ideas.

    any leads?

    Thanks,
    Gaurav

    Like

  17. Hi Erich,

    Thanks for the reply. I tried upgrading to v3.0.0 but that did not help. i will look into getting the debugger going. is there any other way to disable the ADC every so often so as to save average power that the chip would otherwise consume if the ADC is ON all the time.

    Thanks,
    Gaurav

    Like

    • Hi Gaurav,
      yes, you can disable the ADC any time. One way is to set a flag, and check that flag in your main loop. It all depends how you architect your software, but that should be very doable.

      Like

  18. Hi Erich,

    At FTF today in the Kinetis experts session you mentioned that you have an article for people who haven’t used Processor Expert about why they might want to. Could you provide the link?

    Doug

    Like

  19. Hi Erich,

    I’m looking for any guidance you have around setting up a KDS environment in a way that makes it easy to distribute to other team members.

    When we add a member to our development team, it can take a half day to walk them through downloading and installing KDS, KSDK, Segger drivers, USB to UART drivers, SVN (version control), etc.

    Is there some way to replicate that on another machine without having to go through all the individual steps?

    I think I’ve seen a few hints in some of your prior posts, but have been unable to find them again.

    Doug

    Like

    • Hi Doug,
      You might get some inspiration here: https://mcuoneclipse.com/2014/05/18/constructing-a-classroom-ide-with-eclipse-for-arm/
      Basically, you can build up your eclipse installation/folder once, zip it and pass it around. Same thing for the Kinetis SDK: zip that SDK folder too. The only thing which is not covered by that are the USB drivers needed to run Segger or P&E/etc. So you will need to make sure that they are installed at least once on the target machine.
      The P&E drivers/installer you can download from the PEmicro web site, or use the one inside KDS (C:\Freescale\KDS_3.0.0\pemicro).
      The Segger drivers can be downloaded from segger.com, or use the one inside C:\Freescale\KDS_3.0.0\segger\USBDriver

      The other hint I have: you can download all the packages/installers once, and then distribute them. If you are using online Eclipse updates, then there is a way to make a local copy too, see https://mcuoneclipse.com/2014/07/03/replicating-an-eclipse-update-site-for-offline-usage/. That’s especially useful if you want to store/save the used software/setup somewhere, and you do not want to run into the risk that a software setup gets removed from the web later on.

      I hope this helps,
      Erich

      Like

  20. We are using MKL25Z128VFT4(powered with 3V supply.) along with IAR IDE and I JET debugger. During initial flashing, we are getting the following error:
    “Failed to Load Flash loader”.
    The controller goes into locked state frequently. We are able to perform mass erase operation using “Kinetics_unlock_jtag.bat” file.
    But not able to flash/write the application code.

    please help.

    Like

    • As I do not have an iJet, I cannot really comment. But I would verify the state of the reset pin with a logic analyzer/oscilloscope. Maybe the iJet is not able to keep the device properly in reset?

      Like

      • on an un-flashed board,we could see that the Reset is going from 0V to 1.9V and dropping back to 0V. This waveform is repeating every 34us. Its staying high for 3uS.

        During this condition, the SWDIO is ‘H’ and SWD CLK is ‘L’.

        Can you let us know the points to be check wrt reset?

        Like

      • Hi Erich,
        I understood that this is due to the watchdog timer that comes enabled from factory.

        We have 10k pullup resistor and 0.1uF capacitor on reset pin.

        After mass erase operation, the MCU reset is ‘H'(approx 2V). If i power cycle the board(supply ON –> OFF –> ON), the reset behaviour restarts.

        I got the log from the debugger tool this time..

        Tue Jul 14, 2015 15:11:51: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\arm\config\flashloader\Freescale\FlashKLxx.mac
        Tue Jul 14, 2015 15:11:51: Loading the I-jet/JTAGjet driver
        Tue Jul 14, 2015 15:11:51: Probe: Probe SW module ver 1.40
        Tue Jul 14, 2015 15:11:51: Probe: Option: trace(Auto,size_limit=8M)
        Tue Jul 14, 2015 15:11:51: Probe: I-jet-Trace SW module ver 1.31
        Tue Jul 14, 2015 15:11:51: Probe: Found I-jet, SN=79345
        Tue Jul 14, 2015 15:11:51: Probe: Opened connection to I-jet:79345
        Tue Jul 14, 2015 15:11:52: Probe: USB connection verified (7941 packets/sec)
        Tue Jul 14, 2015 15:11:52: Probe: I-jet, FW ver 4.2, HW Ver:A
        Tue Jul 14, 2015 15:11:52: Probe: None or IJET-MIPI10 adapter detected
        Tue Jul 14, 2015 15:11:52: Probe: Versions: JTAG=1.64 SWO=1.31 A2D=1.58 Stream=1.40
        Tue Jul 14, 2015 15:11:52: EARM v.3.71
        Tue Jul 14, 2015 15:11:52: Emulation layer version 3.71
        Tue Jul 14, 2015 15:11:52: SWD clock detected: 12MHz
        Tue Jul 14, 2015 15:11:52: Connected DAP on SWD. Detected IDCODE=0xbc11477.
        Tue Jul 14, 2015 15:11:52: Connecting Cortex-M core ID = 0x4770031 on DAP port 0
        Tue Jul 14, 2015 15:11:52: Recognized CPUID=0x410cc600 Cortex-M0+ r0p0 arch ARMv6-M
        Tue Jul 14, 2015 15:11:52: Debug resources: 2 instruction comparators, 2 data watchpoints.
        Tue Jul 14, 2015 15:11:52: CPU status – IN RESET
        Tue Jul 14, 2015 15:11:52: INFO: Configuring trace using ‘Auto,size_limit=8M’ setting …
        Tue Jul 14, 2015 15:11:52: MTB, Not configured
        Tue Jul 14, 2015 15:11:52: CPU does not have TPIU – SWO cannot be enabled
        Tue Jul 14, 2015 15:11:52: LowLevelReset(system, delay 200)
        Tue Jul 14, 2015 15:11:52: Connected DAP on SWD. Detected IDCODE=0xbc11477.
        Tue Jul 14, 2015 15:11:52: Connecting Cortex-M core ID = 0x4770031 on DAP port 0
        Tue Jul 14, 2015 15:11:52: Recognized CPUID=0x410cc600 Cortex-M0+ r0p0 arch ARMv6-M
        Tue Jul 14, 2015 15:11:52: Debug resources: 2 instruction comparators, 2 data watchpoints.
        Tue Jul 14, 2015 15:11:52: CPU status OK
        Tue Jul 14, 2015 15:11:52: CPU status – IN RESET
        Tue Jul 14, 2015 15:11:53: Connected DAP on SWD. Detected IDCODE=0xbc11477.
        Tue Jul 14, 2015 15:11:53: Connecting Cortex-M core ID = 0x4770031 on DAP port 0
        Tue Jul 14, 2015 15:11:53: Recognized CPUID=0x410cc600 Cortex-M0+ r0p0 arch ARMv6-M
        Tue Jul 14, 2015 15:11:53: Debug resources: 2 instruction comparators, 2 data watchpoints.
        Tue Jul 14, 2015 15:11:53: CPU status OK
        Tue Jul 14, 2015 15:11:53: CPU status – IN RESET
        Tue Jul 14, 2015 15:11:55: Fatal error: Reading CPU status failed Session aborted!
        Tue Jul 14, 2015 15:11:55: Failed to load flash loader: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\arm\config\flashloader\Freescale\FlashKLxx128K.flash
        Tue Jul 14, 2015 15:11:58: Loading the I-jet/JTAGjet driver

        I am still struggling to know y the controller is resetting even after mass erase.

        Like

        • Hi Ravi,
          your problem might be related to IAR and I-Jet firmware. Make sure you are using the latest version and debug probe firmware. I have seen that vendors were struggling with getting hold of new Kinetis devices with their debugging probes, as the device constantly resets, so an update might help. Or try the free Kinetis Design Studio with P&E and/or Segger (KDS does not support i-jet).
          The other thing you could try: keep the reset line/button pressed during connection. Maybe this helps the i-jet to take control over the target.

          Like

  21. Hello Erich,

    I am following your tutorials while a moment and I have a question you don’t answer with its ^^

    I would like to use to K64 Micro USB (not the OpenSDA Micro USB) to obtain a communication between my PC and the K64 Microcontroller. I saw lot of tutorials to use the OpenSDA port as CDC, MSD, HID but none for this USB port. Are there solutions? 😦

    Like

      • I already watched it but the driver created is not recognized by this port, I can only update the OpenSDA port with it… In more in my programm it’s well written pin 10 pin 11 for USB and I did twice your tutorial :/ IDK why it doesn’t work for this micro USB.
        When I plug the board it says “Unknown device” which is a new step because before it sayed nothing but I can’t update driver in “devices configurations”.

        Like

        • Hi Loic,
          have you used the the cdc.inf generated in the Documenation folder of the project?
          Important: follow the steps below to install/update the driver:
          – Go to the Device manager and identify the device. Perform an ‘update driver’
          – IMPORTANT: Select ‘Browse my computer for driver software’
          – IMPORTANT: select ‘let me pick from a list of device drivers on my computer’
          – use ‘show all devices’, use ‘have disk’ and to browse to the cdc.inf file
          – this will show up as ‘Freescale CDC device’ 🙂

          Erich

          Like

      • Yep I already did that steps and it works for OpenSDA port and not K64 Micro USB port 😦
        When I show all devices and want to select the folder where cdc.inf is it says it’s not compatible. But when I do it for the OpenSDA it says it’s OK and i see ‘Freescale CDC device’

        It’s really weird :/

        Like

        • Hmm, that’s weird. That driver is not supposed to work with the OpenSDA port. Are you sure you are using the correct USB port/connector (just asking ;-)).

          Like

      • Lol, yep this opposed to the reset button ^^
        I try on USB2.0 and USB3.0 (idk, all solutions are possible now :p )

        Is it because I use the SWD Connector JTAG to debug?

        Like

        • LOL, sometimes the issue is on layer 0 :-). Yes, the connector close to the reset button is the OpenSDA one 🙂
          it should not be a problem if you use the SWD connector to debug. However, that might trigger a point: can you make sure that the OpenSDA connector is connected too (to have the K20 on the board powered)? I remember having issues with OpenSDA circuit not powered.

          Like

      • When both USB are connected debug crashes (I think it’s normal).
        But what do you mean about SDA Connector connected? I connect it to what? I am already using SWD Connector to debug :p
        I am definitively in a no-issue :/

        Like

      • For a later use I just want to use the K64 Micro USB so if the OpenSDA has to be supply it’s bad for me ^^
        I tought thanks to DP and DM of the K64 I could get a CDC without the need of K20

        Like

        • Yes, that’s possible. You can use the USB of the K64F without the K20. But your problem is that your setup is not working. You need to get back to a working environment, then you can optimize it. I hope this makes sense.

          Like

      • Thanks for you help, it was a pleasure to work with someone my brain gonna explode.
        I’ll contact you when it works. 🙂 I hope it will!

        Loïc

        Like

        • No, you don’t have to use Kinetis SDK to program Kinetis devices. Although Freescale is pushing it as the standard way of programming the Kinetis.

          Like

      • Hey Erich,

        Guess What!
        I stop to program on Eclipse, I have gone on KSDK, I have done the same program with same components same code lines. Results: IT WORKS!!!!!!!

        Does Eclipse add a layer or something like that perturbing the K64?

        Like

      • I now program on Kinetis Design Studio, I gave up Eclipse.
        The driver installed directly as expected contrary on Eclipse where the driver didn’t want to install and USB Device was not recognized.

        Like

  22. Hey there,

    I participating on a project which we’re developing for a FRM board K64F. My collegue was using KDS 2, and I decided to use KDS 3. After porting the project to KDS 3 I reached a debug error very similar to the one in that thread: freescale community thread/329710.
    My console tab shows:

    Open On-Chip Debugger 0.8.0-dev (2015-01-09-16:22)
    Licensed under GNU GPL v2
    For bug reports, read
    http://openocd.sourceforge.net/doc/doxygen/bugs.html
    Info : only one transport option; autoselect ‘cmsis-dap’
    Error: unable to open CMSIS-DAP device
    Error: unable to init CMSIS-DAP driver
    Error: Error selecting ‘cmsis-dap’ as transport
    Runtime Error: C:/Freescale/KDS_3.0.0/openocd/bin/..//scripts/kinetis_application.cfg:3:
    in procedure ‘script’
    at file “embedded:startup.tcl”, line 58
    in procedure ‘interface’ called at file “C:/Freescale/KDS_3.0.0/openocd/bin/..//scripts/kinetis_application.cfg”, line 3

    In that thread you suggested to update mbed’s firmware version, but I’m already using the latest (0221). Do you have any other suggestion to way might be causing the error?

    Like

      • Hello Erich,

        the problem was that I hadn’t installed mbedWinSerial driver.

        I read about your preference to P&E and Segger firmwares, but the platform I’m working has been configured with mbed and right now my collegues don’t want to change it.

        Thanks for you fast reply!

        Denis

        Like

  23. Thank you Erich for your incredible site! You are brilliant in your communication of very complex concepts to the masses and appear to be well respected by your peers. Your insights have been invaluable in decreasing my learning curve! #42

    Like

      • Thanks? Erich. 🙂 By the way, I’ve looked all over your site as well as the Freescale site, I’ve had a bunch of problems with getting the K64F I2C ISR/driver working in MQX with their CRTouch controller. Apparently they don’t have an example of that particular combination. Do you have an article that might help? I really do appreciate all the work you do.
        -Duae

        Like

  24. Hi Erich,

    I am playing with KDS and the embedded component project. I can find no user guide, or and instructions what so ever on this feature, only the older CDE. Have you used this? Does it work the same way, or if not, any idea where information is on this feature?

    Like

  25. Hi Erich,

    I am having a problem with freeRTOS in combination with the watchdog_ldd component.
    I want the watchdog to do a event first and then reset the cpu. But when the watchdog kicks in the debugger shows me “No source available for “0xFFFFFFFE (0xFFFFFFFE)() ” ”

    What am I doing wrong or do you have any suggestions?

    Like

  26. Hello,
    I’m working with kinetis design studio and a FRDM KL25Z.
    I try to program the led with the LED component. Unfortunatly impossible to change the component name, I have LEDPin1 in grey an a red message near: the component is not supported for selected processor!!
    Any idea?

    Like

    • Have you installed the McuOnEclipse components from SourceForge (see https://mcuoneclipse.com/2014/10/21/mcuoneclipse-releases-on-sourceforge/)?
      The thing is that there is a LED component in Processor Expert (for DSC), which is wrongly used by Processor Expert (a bug in my view).
      So you need a) install the McuOnEclipse components and b) load the project. It might be that you need to restore the original project, as you might have it configured/changed now to use the wrong DSC LED components :-(.

      I hope that helps.

      Like

      • Hello Erich,
        First, thanks a lot for all your work. So, after your message, I have uninstalled all the programs about my KL25Z4 (IDE, SDK …etc), reinstalled all. And now the LED component is working!!! Now I’m trying the PWM mode, it’s strange for instance but I will find.
        My new problem is with serial component. There is no event when a byte have been received? How to know if a byte is ready to be read. In fact my program should know when an order has been sent via serial link, but the program is going to do other things in the same time.
        On my arduno UNO32, I check a flag fot that goal, but I am a little lost on KL25Z.
        Thanks a lot for your help.

        Michel

        Like

  27. Hello,
    So now serial problems are solved. The last problem is MMA8451. I have used your component, but it doesn’t worked properly. As I can’t send images here, I have just mad a small web page:
    http://www.etoiles-a-bleau.fr/transfert/MMA8451.html
    Thanks again for all your work and help.
    To explain, the goal of my program, I want to find the position of my telescope in case I loose it, to be able to phase properly the direct drive motors of the telescope.
    Michel

    Like

  28. hi I am trying to compile using your turorial i have taken project from kea128 I am getting the following errors which i cannot fix can you help me out

    C:\Users\user1\workspace\makeprj/Project_Settings/Startup_Code/__arm_start.c:179: undefined reference to `__init_registers’
    C:\Users\user1\workspace\makeprj/Project_Settings/Startup_Code/__arm_start.c:231: undefined reference to `__copy_rom_sections_to_ram’
    C:\Users\user1\workspace\makeprj/Project_Settings/Startup_Code/__arm_start.c:251: undefined reference to `__init_cpp’
    C:\Users\user1\workspace\makeprj/Project_Settings/Startup_Code/__arm_start.c:257: undefined reference to `__init_user’

    Like

  29. Hello Erich,
    A little question about your code for MMA8451, when I use the fonction MMA1_MeasureGetRaw*, the result is allways even, between 4096 and -4096, it seem that the resolution is 2048 per g and not 4096.
    Thanks
    Michel

    Like

  30. Hello,
    I tried to create LwIp project on K64F board according to this tutorial: https://mcuoneclipse.com/2015/10/28/tutorial-lwip-with-the-freertos-and-the-freescale-frdm-k64f-board/
    Then I added I2C and GPIO component for reading data from accelerometer in neverending loop. Everything works fine but only several ms then my task ends. Without I2C component the LwIp works fine all time. Any idea why reading accelerometer data stops program?
    The similiar accelerometer project is here: http://www.element14.com/community/community/designcenter/kinetis_kl2_freedom_board/blog/2015/09/16/interfacing-freescale-s-frdm-stbc-agm01-sensor-module-to-frdm-kl46z-using-kinetis-design-studio-30-kinetis-sdk-12-processor-expert

    Like

  31. Hi Erich,

    I need to use a Kinetis (MK20DN512VLK10) to measure the pulse width of 4 signals down to a resolution of 1us (the pulses are typically 30-40us long with a 250us gap between each pulse, although this can change / vary).

    Currently I am considering simply starting and 4 timer / counters in each of the IO interrupt routines when the signal is HIGH and stopping them when the signal goes LOW, is there a better way of doing this? using some of the internal HW of the MK20, if there is I may need to change my routing as the 4 signals simple go to standard IO port pins at the moment.

    Thanks for any time you can spare on my question.

    Like

      • Hi Erich,

        Thanks for the fast response 🙂

        Will i be able to use:

        TPM0_CH0
        TPM0_CH1
        TPM0_CH2
        TPM0_CH3

        for my 4 signals or will i need to split them up? as i am not sure if one timer can handle all 4 signals (sorry i am being very lazy not reading the 1000pg reference manual).

        Many thanks for your help.

        Like

        • At a 10’000 feet level, this is what you need. But I recommend that you a) at least read the relevant chapter about the Flex Timer module which desribes the functionality and b) that you implement the software first and for example a FRDM board to verify that the pins are really capable doing this for you with the needed timing before you do the hardware.

          Like

  32. Hi,

    Any idea what the difference is between :

    MK20DN512ZVLK10
    and
    MK20DN512VLK10

    What does the extra “Z” indicate? (larger temperature range)

    Like

  33. Hi Eric,

    I am using the FSL USB Stack from your components with an MK0DN512VLQ10, but the CPU list only has the following MK20 support:

    1. “Kinetis K20D50”
    2. “Kinetis K20D72”

    I have tried “K20D50” but this produces a Windows “USB has malfunctioned” warning message. Using “K20D72” seems to work and i have a working CDC device. Is it okay to carry on using the “Kinetis K20D72” option even though i am using a MK0DN512xxx10 (100MHz device)?

    Thanks

    Like

    • Hi Andrew,
      I don’t have the 100 MHz device, so was not able to confirm if it works. There is no issue using the K20D72 for the 100 MHz one. All what this selection does is to use the proper interrupt vector numbers (it seems they are compatible with the 72 MHz version), and that’s it.
      I plan to add the K20D100 option in a next release.
      Thanks for telling me that it works 🙂

      Like

  34. Hello mr Erich, i’ve just read your article about Nrf24L01+ and for now I do my final project at college using that RF module, but I’ve got a problem. in my final project I use GPS module to get GPS data and than trasmit the data to Roadside Unit for identification and then the Roadside unit will Transmit again the Data after identification process, so the RF module at Roadside Unit should be a RX and TX. I have a question is that possible to use the Nrf24L01 to be a RX and TX ?

    thank you
    Zakiy

    Like

  35. Hi. I need some help using the Device Initializacion feature. I use CodeWarrior, and created a project with the “Device Initialization” feauture enabled. If I click on some peripheral, I can configure it. After that, I select Generate Code. My problem is that if I then make some changes to a peripheral and generate the code, there is no change in the behaviour of my code. The changes I make do no apply. I even tried disabling the peripherals and the program still works, after saving and recompiling.
    Am I missing something? Maybe I misunderstood the use of the Device Initialization. In such case, How can I change the settings of a peripheral and apply those changes to the code. I appreciate any hint.
    Thanks in advance.

    Like

    • Hi Carlos,
      disabling the peripheral will not remove the code (afik). Does code generation really work for you (e.g. you remove the generated files, they get generated)? I have to say that I have not seen something you describe, so there must be something obvious we are missing?

      Like

      • Hi. Thanks for your answer. After posting here and asking tha same question in the freescale community forum, I found the problem. I had created the project enabling Processor Expert instead of Device Initialization, and creating a new project enabling Device Initialization solved the issue. I don’t fully understand the difference, or even if I have PE installed. It seems as if Device Initialization is a reduced version of PE.
        Anyway…
        Congratulations for your site! It is really helpful.

        Like

  36. So I have just started looking into building a Kinetis based drone as you have. I have a handful of assorted K-series boards already and an IMU as well. However I can not figure out how you are getting 4 PWM signals out of a K22. I was planning on using a K64F as it has a full 4 FTM modules, and I would use one FTM per PWM signal. However the K22 appears to only have 3 FTM modules capable of generating PWM signals. Are you just using something like GPIO and PIT based scheduler to create a PWM? Where’s that 4th channel coming from?

    (Also I really want to use Keil uVision for this as its my preferred tool and I find I learn more)

    Like

      • Alright, reading back though the reference manual it looks like I have misinterpreted a few things about the FTM. Between your code and reading over the documentation a few more times I feel I can get this working. Going to save some money and space replacing the K64 with a K22. Thanks for the clarification.

        Like

  37. Hi Erich,

    I am trying to use the Segger System Viewer with FreeRToS using your latest components, but i am getting the following error:

    “Description Resource Path Location Type
    undefined reference to `uxTaskGetState’ SEGGER_SYSVIEW_FreeRTOS.c /MK20DN512VLK10/Generated_Code line 85 C/C++ Problem


    if( pxTaskStatusArray != NULL ) {
    /* Generate the (binary) data. */
    uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL );

    from the “SEGGER_SYSVIEW_FreeRTOS.c” file?

    NOTE: if i remove the Segger Sysview component everything is working fine (i.e. FreeRTOS compiles and runs)

    any ideas?

    Thanks

    Like

    • Hi Andrew,
      uxTaskGetSystemState() is only available if configUSE_TRACE_FACILITY is turned on.
      Turn on ‘Use Trace Facility’ in the FreeRTOS component for this. I already have made a change in the component so this setting is automatically turned on if Segger System Viewer Trace is enabled.

      I hope this helps,
      Erich

      Like

  38. Hello,
    As the MMA8451 on the KL25Z is very bad and noisy, I am trying another accelerometer. It’s an ADXL345. I am fighting with SPI without any succes.
    The ADXL345 is connected like this:
    PTD0 SPI0_PCS0 to CS
    PTD2 SPI0_MOSI to SDA
    PTD3 SPI0_MISO to SDO
    PTD1 SPI0_SCK to SCL
    And the sources are here:
    http://www.etoiles-a-bleau.fr/transfert/ADXL345.rar
    I have ordered a ScanaQuad from IKALOGIC to scan the ports, but I am still waiting it.
    Any ideas?
    Thanks a lot

    Like

    • I think you really need to have a look at the signals, and check if they match with your sensor: MSB or LSB sent first? Clock idle polarity? shifting values on leading or trailing edge?

      Like

      • The datasheet of ADXL345 says that:

        For SPI, either 3- or 4-wire configuration is possible, as shown in the connection diagrams in Figure 3 and Figure 4. Clearing the SPI bit in the DATA_FORMAT register (Address 0x31) selects 4-wire mode, whereas setting the SPI bit selects 3-wire mode. The maximum SPI clock speed is 5 MHz with 100 pF maximum loading, and the timing scheme follows clock polarity (CPOL) = 1 and clock phase (CPHA) = 1.
        CS is the serial port enable line and is controlled by the SPI master. This line must go low at the start of a transmission and high at the end of a transmission, as shown in . SCLK is the serial port clock and is supplied by the SPI master. It is stopped high when Figure 5CS is high during a period of no transmission. SDI and SDO are the serial data input and output, respectively. Data should be sampled at the rising edge of SCLK.
        To read or write multiple bytes in a single transmission, the multiple-byte bit, located after the R/W bit in the first byte transfer (MB in to ), must be set. After the register addressing and the first byte of data, each subsequent set of clock pulses (eight clock pulses) causes the ADXL345 to point to the next register for a read or write. This shifting continues until the clock pulses cease and Figure 5Figure 7CS is deasserted. To perform reads or writes on different, nonsequential registers, CS must be deasserted between transmissions and the new register must be addressed separately.

        Like

      • Hello,
        First I’m going to write my own SPI read/write function, because I don’t know what the component SPIMaster_LLD does, unless this is allready done somewhere. After I should received my small logic analyzer on thursday and I will see.
        Michel

        Like

  39. Hello,

    After my failure to use SPIMaster, I have decided to write my own SPI-read function.
    The source is quite simple and it works!! but only one time 😦 I think there is a problem with SPMF but I don’t understand very well in the documentation:
    ——————
    SPMF is set after SPRF is 1 when the value in the receive data buffer matches the value in the M register.
    To clear the flag, read SPMF when it is set and then write a 1 to it.
    0 Value in the receive data buffer does not match the value in the M register
    1 Value in the receive data buffer matches the value in the M register
    ——————–

    In fact the first time I read the adress 0x00 of the ADXL345, I get 0xe5 wich is ok, but after if I try to read an other adresses, I allways get 0xe5!!In fact it’s impossible to write a new value in SPI0_D.
    my code is:

    ——————————
    uint8_t spi_read(uint8_t adresse)
    {
    uint8_t retour=0,dummy;
    while(!(SPI_S_SPTEF_MASK & SPI0_S))
    { //While buffer is not empty do nothing }
    SPI0_D =adresse+0x80; //write adress+0x80 (read mode)
    while(!(SPI_S_SPRF_MASK & SPI0_S))
    { //While received buffer is not full do nothing }
    retour=SPI0_D; //read the received value
    dummy=(SPI_S_SPMF_MASK & SPI0_S);
    SPI0_S |= SPI_S_SPMF_MASK; //Enable SPI0
    return retour;
    }

    Thanks

    Michel

    Like

  40. Hello folks,

    I’m trying to use the DS18B20 bean for PE but I can’t figure out how to set the OneWire Component.
    Any advice?

    Thanks!

    Like

  41. Hi All,

    i am looking into using the DMA to capture a 1usec pulse and measure its pulse width to 100ns accuracy. Currently i am looking into measuring the pulse width using a free running timer clocked at 48Mhz, which gives me a timer resolution of 20ns.

    Since i only need to measure the pulse once i have the CPU (which is clocked at 96MHz) polling the GPIO pin for a transition from high to low and then low two high taking the timer count at each transition and then doing the math at the end of the pulse (i cannot use interrupts as the isr latency is too high approx 12 clock cycles).

    I was looking at the following article:

    Updated Freedom Board Logic Analyzer with DMA

    but it seems the DMA input is limited to 2MHz, Did you find a reason for this?

    Reading the following article indicates a max DMA rate of 8.7Mhz with a CPU clock of 100MHz and bus clock of 50MHz, any ideas as to where the 8.7Mhz figure comes from? (as this is not explained in the article).

    Click to access an5083-using_dma_for_pulse_counting.pdf

    “The maximum transfer rate is limited for DMA hardware requests, especially for single byte transfers. The maximum
    achievable rate for 100MHz device is 8.7MHz, Thus, the maximum input frequency cannot exceed that speed.”

    Like

    • I believe it the reason is with the way how the DMA engine is clocked. I don’t remember that I have seen (or checked) that, but that would be the obvious reason for me that the DMA engine needs multiple clock cycles?

      Like

  42. Good day.

    I have a MK20 of freescale Kinetis and am trying to implement the receiver FIFO of CAN_LDD component (processor expert), however when I enable the flag of the FIFO it’s an error that the controller does not support FIFO.

    In the driver documentation says it supports up to 256 IDs can in FIFO.
    I found many people with the same problem on the internet, however I can not find the solution.

    Can anyone help me with this?

    thank you

    Like

  43. How do i disable / enable global interrupts ? (is there a macro for this)

    If i disable global interrupts for approx 200us will this cause problems with the USB stack (as i am using the Freescale CDC stack from your Library)?

    Like

    • Hi,

      I think i can answer part of my question:

      Enable global interrupts __asm(“cpsie i”);
      Disable global interrupts __asm(“cpsid i”);

      Any ideas what effect this will have on the USB stack? i am only doing this to time a 277us. I cannot use interrupts to do the timing as i require a 1us accuracy which i can achieve using polling ad a timer

      Like

      • disabling the interrupts for that time will suspend as well the USB interrupts. I have not tried that in your way, but I think you should be OK doing that. I just would not do this say for longer than a few milliseconds.

        Like

  44. Hello,
    I have two questions:
    1. Is there a way to use CAN bus with FRDM-K64F? If this is not a case, which extension board will allow me to use this bus?
    2. Recently I was reading an article about running ucLinux on STM32F429I-DISCOVERY. Have you ever considered to use it in any kind of application?

    Like

    • Hi Marek,
      1) I have not used CAN with the FRDM-K64F, so I’m affraid I’m not of any help here.
      2) Does this really make sense with that limited ressources? I have seen ucLinux on some Kinetis K60/K70 but here again: if you want to run a Linux (or Linux variant) you probably better use a i.MX or similar powerful device.

      Like

      • 1. I found FRDM-KE06Z, it looks this is only one FRDM with usable CAN. I just was hoping, that you have managed to use this resource in K64F ( I belive, mcu on this board, has CAN controller).
        2. I’m not sure if ucLinux has any clear advantage over popular OSes, that might be run on CortexM. Only idea, that comes to my mind is ethernet network or GUI.

        Like

  45. Hello

    I’ve been wondering if it is possible to generate a PE block that lets me define a USB device to be two different endpoints (specifically a CDC and a MSD; a serial port and a pass-thru of an SD card/USB disk?)

    do you have any pointers as to where to start? (tbh I’ve probably bitten off more than I can chew for a first project on this hardware).

    Like

  46. Hey Erich,
    I am an undergraduate student in my final year pursuing Bsc Microprocessor Technology and Instrumentation.I am carrying out research on the tiny K20 board.My goal is to develop the PCB footprints, produce the board and populate it locally.That doesn’t seem so hard.My only challenge is writing bootloader application for the board.Please shed some light on where to start.I will be using Kinetis Design Studio, doing everything in linux.

    Regards.
    jngigiw@gmail.com

    Like

    • Not excatly like this. But simply use a GPIO button, configure it for interrupts and check it from your code. If FreeRTOS or not does not matter as this should not depend on an RTOS.

      Like

      • I found some differences using GPIO with FREERTOS I need to habilitate the port clock
        Example
        CLOCK_EnableClock(kCLOCK_PortB);
        Using the examples, I am trying to make a simple task that just change the RGB color, and a IRQ SW that send a message, the IRQ SW works well without freertos.
        Same the RGB task, without IRQ SW.
        The problem is when I push the SW the program jump to NMI, It doesn´t jump to the PORTA_IRQHandler
        What I am missing?
        This is code to initialize the port
        gpio_pin_config_t sw_config = {
        kGPIO_DigitalInput, 0,
        };
        CLOCK_EnableClock(kCLOCK_PortA);

        PORT_SetPinInterruptConfig(BOARD_SW_PORT, BOARD_SW_GPIO_PIN, kPORT_InterruptFallingEdge);
        EnableIRQ(BOARD_SW_IRQ);
        GPIO_PinInit(BOARD_SW_GPIO, BOARD_SW_GPIO_PIN, &sw_config);

        Thanks
        Your friend from CD MEX
        RAUL

        Like

  47. Hi Erich,

    I just learned about this great components for KDS processor expert today. I would like to get more information on the licensing term. I downloaded the Components 2016-02-07.zip and KinetisTools_09.02.2016.zip but I can’t find any licensing information in it. Can I use all the components in these two ZIP files for commercial use without making my firmware open source?

    Thank you

    Johnny

    Like

    • Hi Johnny,
      The licensing terms are in the root folder where the components get extracted. You can find the terms as well on GitHub here:
      https://github.com/ErichStyger/McuOnEclipse_PEx
      Each of the components include the terms as well. In general, all the components I have contributed are open and you can use them for commercial products.
      As I have included portions of the USB stack, be sure you check out the terms for it (basically, you only can use it for Freescale devices).
      FreeRTOS has its own permissible license, so does Percepio and Segger.
      I hope this helps,
      Erich

      Like

  48. Hello,
    Your website here is very helpful. I am currently working on kl25z freedom board and this website helped me a lot understanding things better. Thanks for such detailed description that helps newbies like me a lot.
    So now, I need to create a MQTT connect packet and sent it over TCP/IP to a server. Can you please help me on how to do it. I found some in net but nothing on CodeWarrior. Would be really helpful if you could help me out in any way.

    Thanks in advance
    Sabbi.

    Like

    • Hi Sabbi,
      I have used MQTT for my projects, but I had no time to write up an article about this (only limited amount of time for my hobby :-(). But if you have an example for CodeWarrior, then you should be able to use it for any other IDE an toolchain, as it is just C programming language, right?

      Like

  49. hello there! im currently working on FRDM KL25Z on my project for head mouse. wanted to know a wireless alternative for this board which will help to make my project a wireless device as well! or else is there any other module which can be connected to this board itself, helping in wireless working of the product.

    Like

  50. Hi Erich,
    First of all, thank you for putting the effort into this blog, it helps a lot.
    This is my first time trying working on a project as a student, and it involves using the freescale MED-EKG board. I want to use that board as standalone with my KL25z, and I have seen that it needs an I2C communication to send a start command for its DSC to work. I’m new to I2C and and I’m having a hard time trying to interface that board with the KL25z. Do you think processor expert i2C ldd would work for that purpose? Do I need pull up resistors on both SDA and SCL lines? Thank you.

    Like

    • Hi schnaidler,
      thanks :-).
      We are using that MED-EKG board for some labs (see https://mcuoneclipse.com/2013/01/21/lie-to-me-or-building-a-polygraph/). I’m using that I2C interface with a ColdFire using Processor Expert, so that was very easy. You should be able to do the same with the FRDM board and Kinetis/ARM too. I don’t have the schematics with me, but I believe there are already pull-up resistors on the board (not 100% sure). In that case, you don’t need to add them. Otherwise you have: it is mandatory for I2C that you have pull-ups on both lines.
      I hope this helps,
      Erich

      Like

      • That’s amazing! I didn’t know you used the MED-EKG board before. It is giving me a hard time mainly because I’m still a beginner. I got it to work with the MCF51 tower board using the lab source code that came with it, but I don’t know how to port it to the KL25z. What I’m having a hard time with is the I2c driver. This is the mcf51 driver definition:

        #define IICIF IICS_IICIF
        #define IIC_ARBL IICS_ARBL
        #define IIC_RXAK IICS_RXAK
        #define IIC_BUSY IICS_BUSY
        #define IIC_IAAS IICS_IAAS
        #define IIC_SLAVE_ADD IICA
        #define IIC_CLOCK_RATE IICF_ICR
        #define IIC_CLOCK_DIV IICF_MULT
        #define IIC_TXAK IICC1_TXAK
        #define IIC_TX IICC1_TX
        #define IIC_MST IICC1_MST
        #define IIC_RSTA IICC1_RSTA
        #define IIC_DATA_REGISTER IICD

        Do you know the equivalent of this for the kl25z? If you have some free time, do you think you can show how to use the MED-EKG board with KL25z? That would be greatly appreciated : )

        Like

        • You won’t be able to map the I2C of the ColdFire to the Kinetis one easily. I’m affraid that you have to re-implement the I2C and other layers if you want to use the KL25Z. The easiest way would be to re-write that with Processor Expert I2C component code. But if you are new to that world, that takes some learning. Realistically, I won’t be able to work on that code for the MED-EKG in the next weeks as I have plenty of things on my plate 😦

          Like

      • I understand : ) I have an MCF51mm tower board, would you mind sharing the ECG project? I have the ECG lab 1 that came with the tower board but it has a project file for codewarrior 6.3 and I’m having a hard time upgrading it to codewarrior 10.6. Thank you very much.

        Like

      • Erich,
        In my attempt to use the MED-EKG board with the KL25z, I was able to use I2C_LDD from processor expert, similar to the example of the accelerometer. For the target slave address I used 2 and the I2c was successful, I can write commands to the med-ekg board and I can see its red led flicker every time there is a communication, so thats good! but I still have a minor problem, my read values are not correct, I think I’m not targeting the right register and therefore not getting any useful data. The way I’m writing commands and reading values is similar to the accelerometer example, in fact I’m using the same ReadRegAcc and WriteRegAcc functions, do you know if that will work? Thank you again : )

        Like

        • Yes, this is the way it should work. As for the values not correct: are you sure your EKG leads are ok too? They are very sensitive, and I had to use external electrodes.

          Like

      • Erick,
        The problem happens at the i2c communication, i always receive the same packet id from my read function, and I think that I’m reading the register wrong. Here is how I do my read and write:
        WriteAccRegs(I2C_DeviceData, &DataState, DSC_SLAVE_ADDRESS, 1, (UINT8 *)&CmdEcgDiagnosticModeStartMeasurement);

        and read example:

        ReadAccRegs(I2C_DeviceData, &DataState, DSC_SLAVE_ADDRESS, 1, (UINT8 *)&IsNewDataAvailable);

        The ReadAccRegs function always fill the buffer with a value of 2, no matter what the command is. I know im missing something stupid, and I have been pulling my hair for days now : )

        Like

        • I don’t see anything wrong with your two lines of code. But I’m not sure where that WriteAccRegs() function is? Maybe you should move this question to an article/post using that API as I’m lost in this Q&A section to which project you are referring too?

          Like

  51. Erick,
    I have an existing KSDK MQX ( with a K64 processor ) project where I have been using the DbgConsole for output to uart0. I now am trying to add in a read from console piece where it needs to be non-blocking.

    It seams that both getchar() and debug_getchar() are not compliant to the ANSI C getchar() as in the KSDK version they are blocking.

    I have found that debug_getchar() eventually hits UART_HAL_ReceiveDataPolling() which turns out to be a blocking call, and I have changed the while (!UART_BRD_S1_RDRF(base)) {}; to be and if statement returning EOF instead.

    This has not helped. While debug_getchar() now is not blocking it does not return characters at all.
    I am assuming this is because getchar() boils down to _nio_read() in nio.c and the NIO subsystem is reading the bytes and buffering them.
    This _nio_read() seams to be blocking as well. I have not found where in the NIO layers to make it a non blocking call.

    I have read a lot of other posts complaining / suggesting work around, with no real elegant solutions. This does not cover the nio.c implementation.

    If you had any suggestions or are already familiar with this and have a known workaround I would realy appreciate hearing your input.

    Thanks in advance,
    Greg

    Like

  52. Dear Erich
    Do you have an example using FREERTOS and SDK for the FRDMK64 BOARD, with “xSemaphoreGiveFromISR(xSemaphore_RGB,&xHigherPriorityTaskWoken);”
    I need to synchronize an interrupt from an adc, with a task, when a buffer is full, so the task can calculate an RMS value.
    When the code is running, and paused, the code is in this line:
    configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
    Do I need to change the priority level of the interrupt?
    Thanks for your value help
    I hope to see you in Austin
    Regards
    Raul Cortes

    Like

    • Hi Raul,
      have a read at http://www.freertos.org/RTOS-Cortex-M3-M4.html about interrupt priorities.
      The thing is: check your configMAX_SYSCALL_INTERRUPT_PRIORITY setting. You cannot call any RTOS API functions like xSemaphoreGiveFromISR() from an interrupt which is higher (numerically lower) than configMAX_SYSCALL_INTERRUPT_PRIORITY.
      For example if you have configMAX_SYSCALL_INTERRUPT_PRIORITY set to 4, then you are not allowed to call RTOS functions from interrupts 0, 1, 2 and 3. So yes, you have to change either configMAX_SYSCALL_INTERRUPT_PRIORITY or the level of your interrupt causing that assertion.
      I hope this helps, and looking forward to see you in Austin.
      Erich

      Like

    • Hi Raul,
      no, I don’t have that. I’m not using FreeMaster much anymore because I’m using the Segger J-Scope now instead: much easier and faster to use.
      Erich

      Like

  53. Hi Erich,

    Im trying to run the example FRDM-K64F_USB_MSD_HOST for KDS.
    When I attach or detach pen drive I don’t see the leds changing.
    I put some breakpoints to check and I don’t see any events.
    I saw your message about that this project wasn’t tested with hardware.

    Could you help me?
    Maybe clock wasn’t right configured?

    Like

    • Hi Dennis,
      I suggest you post your question in the releavant article if possible. As for that project: I have used that with hardware and with several memory sticks. But I know that things might be differnt with different memory devices/sticks, so I cannot guarantee that it works for every thumb/memory stick device out there. About the clock: make sure it is 48 MHz. And you should see that the device enumerates properly on the host.
      I hope this helps,
      Erich

      Like

  54. Sorry, I couldn’t find the article about K64F USB MSD to put my question, if possible send me a link.

    Where in the code/file I can find if device was properly enumerated?

    Thanks,

    Like

  55. Hi Erich,
    I have completed several small projects using my custom design with MK20DN512 and FRDM-KE06Z board using a non-licensed CW10.6 plus Processor Expert components within last two years. The debugging was done using P&E micro MULTILINK FX probe. I was using MQX-Lite RTOS then.
    Now I have produced a pilot series of a new design using NXP MK10FN1M0VLQ12 MCU and I am trying to make it running for me. After some lengthy discussion with FRS/NXP people (and PEx as well) i decided to buy a full ARM-M version of IAR WorkBench together with their I-jet Trace.
    Still, am not capable of programming the MCU without the use of PEx, I would like to start my new main project with configuration done by PEx. After this phase I am prepared to (and willing to) switch completely to IAR WorkBench, doing all programming and debugging solely under IAR. I have also decided to switch from MQX-Lite to FreeRTOS, if possible to start with 9.0.0.
    I have studied several of your topics covering PEx plus FreeRTOS on Kinetis processors and I found several points that are difficult for me.

    First of all MK10 Kinetis is already below horizon of (new) support from NXP. No new tools available seem to support such a mastodont. I still feel happy with MK10 for several reasons:
    – my custom board has been developed and produced in pilot series.
    – I need as many CAN ports as possible
    – no use for USB, Ethernet, displays on my side
    – 128kB RAM + 1MB of Flash seems to satisfy my current needs

    My project outline:
    1. Define the processor environment within PEx, possibly using FreeRTOS 9.0.0.
    2. Generate source code from PEx and transfer it into IAR.
    3. Start MCU run with RTOS mastering low power behavior.
    4. Implement remote upload via SDHC “internal buffer”
    4. Gradually add functions using the PEx methods to make my application running (2xCAN, 5xUART, 2xSPI, 2xI2C, ADC 4 single ended 12 bit channels, SDHC, all timers, many GPIOs, the MCU is virtually fully used)
    Many of the modules will be take from my previous projects, but it has to be adapted to the new RTOS, so hopefully I do not need to write from scratch.

    I have started with SDK at NXP website. MK10 is supported on 1.3 revision only. Later on I tried KDS 3.2.0 which enabled me to use quite a nice set of PEx components that looked very similar to those used previously under Eclipse and CW10.6. But installation of KDS removed any SDK from my computer. It looks like KDS does not run with Kinetis SDK. The PEx, provided with KDS 3.2.0. has FreRTOS, but only 8.2.0 version. I do not want to start using FreeRTOS with anything else but 9.0.0. So I have downloaded your Component Package from Github which includes FreeRTOS 9.0.0. But when I try to go through the RTOS settings in the PEx component, it requires links to SDK (1.3 or 2.x).

    My question is: Please, can you describe (from your point of view, of course) the correct setup of various systems and tools that may enable me to live with MK10FN1M0VLQ12 plus FreRTOS 9.0.0. plus PEx components from the KDS installation and then using IAR compiler and debugger (not the GCC one)?

    Great respect for what you do for this community!

    Ludek

    Like

    • Hi Ludek,
      While you *could* use IAR with Processor Expert, in my exprience this combination is not ideal. It is much easier and simpler with KDS. But that’s up to you. I don’t see why you cannot use the MK10FN1M0xxx12 with KDS. I don’t have that device/board, but I can create and use Processor Expert with it in KDS.
      Maybe I’m wrong, but I don’t see the MK10FN1M12 supported by the Kinetis SDK?
      KDS does run with the SDK (I use it in different projects), but from the NXP sites I do not see that this MK10 device is supported by the SDK at all (not in 1.3 and not in 2.0). If you go to http://www.nxp.com/kex (see https://mcuoneclipse.com/2016/01/29/first-nxp-kinetis-sdk-release-sdk-v2-0-with-on-demand-package-builder/) it is not listed/supported neither. There is only MK10DN512, DX128 and DX256 (all 100 MHz).
      I’m not sure when your device will be supported, but right now it does not seem to be supported.
      If it would be supported in SDK v1.x, then this article applies: https://mcuoneclipse.com/2014/11/08/tutorial-freertos-with-the-kinetis-sdk-and-processor-expert/

      But you can create in KDS a project for Processor Expert (File > New > Processor Expert Project). Then you can add the McuOnEclipse FreeRTOS component. That component has a reference to the SDK component, but in that SDK component you can set ‘none’ as SDK. That SDK component is used to make things work with the SDK v2.0 (see https://mcuoneclipse.com/2016/05/15/mother-of-components-processor-expert-with-nxp-kinetis-sdk-v2-0-projects/), so from your perspective simply set the SDK in it to ‘none’.
      You can use KDS to generate code for IAR (see https://mcuoneclipse.com/2015/02/05/using-kinetis-design-studio-with-iar-embedded-workbench-ide/), but I’m not actively using that approach. So I hope I have not broken anything for it.
      I don’t see a reason why you have to use IAR, you certainly could use KDS/GCC instead. It is just that I cannot provide much support for IAR as we cannot afford/need it at the university.
      So to me the ideal setup is:
      – Kinetis Design Studio V3.2.0 (unlimited, free of charge)
      – McuOnEclipse components from SourceForge which has FreeRTOS V9.0.0 (https://mcuoneclipse.com/2014/10/21/mcuoneclipse-releases-on-sourceforge/)
      – Either a P&E Multilink or Segger J-Link
      (The Segger J-Link and P&E Multilink has the advantage that you can use it with pretty much evey IDE out there)

      I hope this helps. I can make a quick check with the free version of IAR, but that’s pretty much all what I can do for you if you are using IAR.

      Like

      • Hi Erich and thanks for the comment.
        I am possibly facing two separate steps to solve:
        1. Use of Kinetis MK10FN1M0xxx12 plus FreeRTOS within KDS environment.
        2. Transition from working project under KDS into IAR Workbench environment (non-GCC compiler plus advantages of I-jet Trace probe).

        Starting with the first one seems to show some progress but still there are some issues there:
        – I do not know by now what limitations are there using FreeRTOS 9.0.0 component without a link to any SDK. As you say the FreeRTOS component refers to KSDK1 referenced component and the KSDK1 can have a SKD version setting set to none. What will I be loosing by this approach?
        – I was willing to use Shell Component via a dedicated UART, The CLS:Shell Component requires KSDK as well (which in my case is “none”). Is it ok to work with Shell but without any KSDK? The Shell utility also refers to Utility (UTIL1 by default) which also want to see some KSDK below. So several times KSDK is required. Is it usable without any KSDK?
        – KSDK configuration at nxp.com offers to generate KSDK 1.3 for MK10DN512 which is (to my knowledge) quite close to my MK10FN1M0. Should I try installing KSDK 1.3 configured for MK10DN512 and see the results?
        – In my previous projects I was using MQX Lite as a PEx component. That component enabled me to create all necessary tasks (and let the task_main() running automatically after initialization of the RTOS). Now it looks like FreeRTOS 9.0.0. component does not allow for configuration of tasks at the precompile stage, it looks like I have to create the tasks in my main.c program using FreeRTOS functions. This could be ok for me, the problem is that the PEx generated main.c explicitly does not allow any user code after RTOS startup. And of course I cannot use RTOS functions before I let RTOS run.
        /*** Don’t write any code pass this line, or it will be deleted during code generation. ***/
        /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON’T MODIFY THIS CODE!!! ***/
        #ifdef PEX_RTOS_START
        PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
        #endif
        /*** End of RTOS startup code. ***/
        /*** Processor Expert end of main routine. DON’T MODIFY THIS CODE!!! ***/
        for(;;){}
        /*** Processor Expert end of main routine. DON’T WRITE CODE BELOW!!! ***/
        } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

        —————————
        Last but not least:
        You wrote: “I don’t see a reason why you have to use IAR, you certainly could use KDS/GCC instead. It is just that I cannot provide much support for IAR as we cannot afford/need it at the university.”
        Visiting FRS/NPX people in Roznov pod Radhostem, CZ with some much better programmers than I am everyone was using IAR. There was a NXP Tech Day there some 2 months ago showing their usage of (“metering”) Kinetis MKM34, a remarkable project. Every piece of code shown there ran on IAR. They use FreeRTOS as well. So that was an important reference for me. But as I wrote earlier in this post, transition to IAR should be a second step after my design starts to breathe under KDS and FreeRTOS.

        Like

        • >>What will I be loosing by this approach?
          Nothing. You are simply not using the SDK (because it does not exist)
          >>Is it ok to work with Shell but without any KSDK?
          Yes.
          >>Should I try installing KSDK 1.3 configured for MK10DN512 and see the results?
          You could do this, sure. But indication from the forums is that it is not that simple/easy. But that depends on your knowledge of these devices.
          >>it looks like I have to create the tasks in my main.c program using FreeRTOS functions.
          MQX is using a table approach, while FreeRTOS uses normal functions. To me, the FreeRTOS way is much simpler and easier to understand.
          Have a look at this example: https://github.com/ErichStyger/mcuoneclipse/blob/master/Examples/KDS/FRDM-KL25Z/FRDM-KL25Z_FreeRTOS/Sources/main.c
          >>This could be ok for me, the problem is that the PEx generated main.c explicitly does not allow any user code after RTOS startup.
          The usual way with FreeRTOS is to create all the tasks (or at least one) before starting the RTOS. See above examples or the documentation on FreeRTOS.org.

          I hope this helps,
          Erich

          Like

        • Hi,

          please excuse me, I may be wrong, but I do not see any “Reply” button in my last post in Q&A section, also in Erich’s last reply to my last post the button “Reply” is missing.

          Am I doing something wrong? All my other posts do have Reply button.

          Kind Regards,

          Luděk Drobný

          ATLAS Europe s.r.o.

          Like

  56. Hi Erich,
    Sorry for my English it’s not my mother tongue.
    Your website here is very helpful. I am currently working on FRDM K64F and I have some problems. I follow topics about “kinetis Drone : Sensor Fusion Toolbox” and “Segger J-Link Firmware for OpenSDAv2”.
    My board is detected by the computer as a MBED disk drive. I can do program to light LED. But when I launch “Fusion Sensor Toolbox” the software says “Please connect a board”. What’s wrong with my board?
    Moreover, I would like to write a program and print result in a terminal (like tera term for instance). It seems not detecting my board but it is connected. I don’t know what I can do to solve that.
    One more question, I would like to collect acceleration with this board (that the reason why I want fusion sensor toolbox). Is that possible to export results in .txt with this software or should I create my own program? If that is the case do you know one that could do that?
    Thanks
    Guillaume

    Like

  57. HI Erich,

    I’m new to Eclipse and I am trying to figure out two questions about links.

    1. Suppose I have a project with links to files. Now suppose I want to replace one or two links to files with actual copies of the files. Is there a simple procedure for doing this?

    2. Suppose I have a project with links to files. Now suppose I want to make a clone of that entire project replacing all links to files everywhere with actual copies of the files. Is there a simple procedure for doing this?

    Thanks very much!

    Rick

    Like

    • Hi Rick,
      Point 1: delete the link and add the file (this time not as a link). It is as simple as delete the entry in the Project Explorer view in Eclipse, then drag&drop the new file into the project: I dialog will show up if you want to copy the file or to create a link.
      Point 2: if you copy/clone the project, it will copy the files in the project folder. The links will be copied and are still links. If you want to replace the links with the files instead, you have to do as in point 1).

      I hope this helps,
      Erich

      Like

      • Sounds tedious if there are many links, but I understand. It would be useful to have a “replace links with files” option when copying projects with a “replace” or “replace all” option.

        Thanks for your help.

        Rick

        Like

        • Hi Rick,
          yes, at the first sight that would be desirable and maybe not difficult to implement. But only at the first sight: it might be really not be possible to copy such a file because there is no real destination folder (e.g. only a virtual folder). And what about all the compiler settings e.g. compiler search paths pointing to the remote location? How a tool/script should handle that? I think there are far too many complicated details to make something ‘automatic’ work. From that perspective, better do it by ‘hand’. Not sure from where you are coming from, but if you want to ‘convert’ a Kinetis SDK project: they never should have used linked files for these projects, it is just making it really hard to get them copied.

          Like

  58. Hi Erich,

    More eclipse questions from an eclipse newbie:

    1. I’m using a toolset (CCS v6.1.3 for the TMS320F28069) that is based upon eclipse. Is there a place I can go to get the most complete documentation, perhaps an eclipse website (instead of going to TI’s website)? if so, what are those websites?

    2. I see that eclipse creates many files and directories automatically for my project. For the purpose of software source control, I want to save source files (this is obvious) and all files that contain project-specific configurations. I intentionally want to ignore files that are automatically generated and files that are not directly relevant to software source control. Is there documentation somewhere that describes the eclipse directory structure and files that are created by eclipse, and the purpose of those files and directories?

    3. Is there guidance somewhere for which files need to be tracked for software source control and which files can be safely ignored?

    4. I was poking around my project and found a directory called .plugins. This leads me to believe that eclipse can be extended or customized. Is this correct? If so, where can I find documentation on how to extend or customize eclipse?

    Thanks very much!

    Rick

    Like

  59. Hi,

    I’m having a problem building your Blinky for RTOS/PE/KSDK.
    Cant seem to find what PE component provides the following header: “HF1.h”

    Like

  60. Timing is everything. I have a hard fault issue with a KDS 2.0 project. I notice KDS has a hard fault handle and I would like to know if I should start with the KDS handler or use your processor expert code. The code we are working with will run under KDS 3.0 but all of out validation has been with KDS 2.0.

    Like

  61. I’m having a problem with your Wait PE component in that its seemingly not triggering. Am just getting a steady on LED.

    I am using a TWR-K60D100M board.

    Like

      • Well the problem seems to be it not triggering at all. I have gotten around this with my blinky by using an Interrupt instead but this does not work for the LCDHTA component which may explain why I cant seem to get my LCD to work ether.

        Like

  62. Hi Erich,
    I am having hard time with I2C component in PE of KDS,
    I am using KL03 as master and one external I2C device(Address: 24) and I want to read continously the sensor data from data register 0x04,
    I tried to search for I2C example for PE but no luck,
    Also I am confused in functions like I2C_DRV_MasterReceiveData and I2C_DRV_MasterReceiveDataBlocking,
    Can you please make a post for I2C component in PE?

    Thanks

    Like

  63. Hi Erich,
    me again. I am facing an incredible annyoing problem: I added a reference to a header file “Application.h” to “Events.c”. In Application.h the following things are coded:
    #include
    volatile uint8_t bLoggingAktiv, bExit = 0;
    void Application_Run(void);

    Application.c includes the following:
    #include “PE_Error.h”
    #include “AS2.h”
    #include “I2C.h”
    #include “drivers.h”
    #include “UTIL1.h”
    #include “Application.h”
    #include
    #include “PE_Types.h”

    Suddenly (after some successful builds before the change in Events.c) the compiler says, that in “I2C.c” (belonging to an I2C_LDD Component) the function “bool I2C_MasterGetBlockReceivedStatus(LDD_TDeviceData *DeviceDataPtr)” and “bool I2C_MasterGetBlockSentStatus(LDD_TDeviceData *DeviceDataPtr)” have conflicting types. And indeed, if I go to implementation of bool in I2C.c, i get to “stdbool.h”. If I go to implementation in I2C.h, I get to “PE_types.h”.
    I already tried this:
    https://community.nxp.com/thread/382891
    but that results in other errors. Maybe because there is no ARM Windows entry in my Kinetis Design Studio version 3.2.0
    I already tried to remove the include of Application.h in Events.c, but the error remains.

    How do I solve this?

    Like

    • sorry the text between the greater than- and smaller than-signs got erased. The two empty includes were followed by stdint.h between smaller than and greater than

      Like

      • Hi Johannes,
        somewhat unrelated, but you need to add ‘extern’ for variables in header files:
        extern volatile uint8_t bLoggingAktiv, bExit;
        Otherwise (except for rare use cases) this would be a programming error.
        Erich

        Like

    • Hi Johannes,
      you are running into a common C programming dialect problem: depending on your compiler language settings for C (C89, C99, etc), some standard types like bool are not defined in the language and need to be declared first.
      I bet your problem will go away if you add an include to ‘stdint.h’ (in less and greater signs to include it from the library path) *before* you are using any of the ‘bool’ or ‘uint8_t’ types.
      So add that include before your
      extern volatile uint8_t bLoggingAktiv, bExit;

      And BTW, your application.c shall have
      volatile uint8_t bLoggingAktiv, bExit = 0;
      (you cannot initialize a variable in a declaration).
      I hope this helps,
      Erich

      Like

      • Hi Erich,
        thanks for your quick answer. I have the feeling that either I didn’t understand right what you suggested or maybe I made a bad description.
        I already have #include stdint.h in both Application.c and in Application.h before I do any declarations of variables.
        I also tried to include stdbool.h, without success. Is the order of the includes important in this case? Because in PE_types there is a if-statement around the bool declaration testing if TRUE or FALSE may have already been defined and if __cplusplus is defined.
        In an additional test, I commented all PE_Types.h and stdbool.h out in my own source files. But still the error of conflicting types in I2C.c remains, and no other have been pointed out.
        Why does the IDE jumps to “stdbool.h” if it is nowhere included if I CTRL-Left click on bool as the return type of “bool I2C_MasterGetBlockReceivedStatus”???

        I also tried to delete the component and add a fresh one. No success.

        Johannes

        Like

        • Hi Johannes,
          yes, in such cases the order of includes is important. Because depending on the order, one module can see one declaration first, or the other.
          The CTRL-Left click to jump to the declaration is coming from the Eclipse IDE (the editor includes a parser which parses the source files). This is *not* the same and the same order as the compiler sees them.
          The only reliable way is to check what the preprocessor sees, have a look at https://mcuoneclipse.com/2015/11/23/preprocessor-listing-for-gnu-gcc-with-gnu-arm-eclipse-plugins/
          Open that .o file as outlined in the article and then you see what it is including/when. If you search for the error location and types, you should see from where it comes.

          If that does not help, you might send me your project to the email address listed on https://mcuoneclipse.com/about/ and I could have a look (maybe next week).
          Erich

          Like

      • Hi Erich,
        thanks for your offer to even check my project. I hope I don’t have to make use of that offer and am able to fight trough by myself 😉 I did check the *.o-Files and started with my Application.o. I searched for definitions of “bool” and found two, one as unsigned char (like in PE_types.h) and one as _BOOL (like in stdbool.h). I assume that the paths listed obove such statements are the source of where the definitions and code lines are taken from?
        After that, I remembered that the compiler errors began after, among other things like placing code in UART interrupt, I added an UTIL und a KSDK-Component. I wanted to use those helpful strcat-Functions from the UTIL-component. So I deactivated them and replaced the UTIL_strcat functions temporarily by calls of snprintf.

        Now the errors are gone. I will try to change the order of #including “UTIL1.h”, “I2C.h”, “stdint”, because in another project I use UTIL as a PE component and have no trouble with type conflicts according bool-types.

        Thank you, Erich, very much so far.

        Johannes

        Like

  64. Hi Erich,

    I was running this code and it got halted in between. The message I see in the Debug pane states, “Thread [ID: 0x0] (Suspended: Signal ‘Halt’ received. Description: User halted thread.)”. I saw some reply of your where you asked to “Enable Logging”. But the still interrupts even after the change. Please help! Thanks in advance

    Like

  65. Thanks for replying Erich.
    I am using KL25Z along with Sim900A GSM module to send a 96 byte packet to server. While debugging I get the above message. And, no I did not halt it myself, it happened on its own. //Cpu_Interrupt() Cpu.c:92 0x00000e00// is exactly where it stops. 😦

    Like

  66. I checked your article on Hard_Fault(), Erich. Helped a lot to understand the sudden halt i am facing. So my R1 address shows as 0x000028dd and when I checked in processor expert, its here:
    ////////////////////////////////////////////////
    int readGSMResp(char *str, uint16 WaitTime)
    {
    uint16 DlyCount;

    DlyCount = 0;
    do
    {
    if (DlyCount > (WaitTime * 10) )
    break;

    DlyCount++;
    WAIT1_Waitms(100);

    }while(strstr(GSM_Data, str ) == NULL);

    if (strstr(GSM_Data, str ) == NULL)
    return FALSE;
    else
    return TRUE;

    }
    The address shown is between 4th and 3rd line from below. (ie between if…and return FALSE). Advice Please.

    Like

    • Your stack trace shows more that it is in the MakePkt()?
      I’m not sure why you are thinking R1 is pointing to the problem location: check the PC and LR with the hardfault handler.
      Common causes for hard faults are:
      – calling a function in non-existing memory locations (e.g. wrong function pointer)
      – accessing a peripheral which is not clocked or not muxed at all.
      I hope this helps,
      Erich

      Like

      • Thanks Erich, I found the place of problem. Its in the shifting of bits.
        /////
        unsigned char Packetbuf[24];
        unsigned char *p, data;
        unsigned char tmp1;
        p = data
        // Push field event value in to Packetbuf array
        tmp1 = on;
        p[0] = Enx.PIR ;
        tmp1 = tmp1 >> 32;
        tmp1 = (tmp1 >>64) & 0xff ;
        p[3] = tmp1;
        Problem is at: temp1 = tmp1 >> 32; shifting issue.

        Like

        • I belive it is more p[0] = Enx.PIR ; as the PC is always *after* the place.
          looking at your code: this code really does not make any sense at all? shifting a 8bit varialble by 32 or 64 bits?

          Like

  67. Thanks Erich, I edited the code. Yes there was shifting issue while packing, did the necessary changes and it works now. Thanks for the help 🙂 . BTW, is there a thing like “max size of packet” the KL25z can support?

    Like

  68. Hi Erich,
    Was hoping somebody could help with the following problem:
    I have an old MC9S12NE64CPVE and i have purchased an P&E Cyclone Pro such that i can automate the firmware process.
    I have not use the P&E tools before and was wondering if there is a way i can get the device to read and save and S-Record from the device?
    SO far the P&E tools seem to be utter garbage in comparison to the Segger tools which are much simpler to use and from what i can tell offer tonnes more functionality. Unfortunately Segger don’t support the MC9S12NE64 so i am stuck with the P&E tools 😦

    Like

  69. Hi,
    Is there any tutorial which shows me the steps to start programming in KDS3.0.0 without PE.
    I want to do it for I2C interface with KL03, so how to define UART pins , baud rate , I2C pins, I2C configurations as it was very easy in PE by just using the component inspector, but how to do this without PE?

    Like

  70. Hi Erich,

    Do we always get ASCII as output. Like when I give DateDay = 23, it doesnot print any value; but when I give DateDay = 50, it gives 2 as output which is the ASCII value of Decimal 2.

    But this restricts us to print 2 digit number as 45,23,55 etc etc.

    Please help.

    Like

      • Thanks Erich, but I’m not printing string. This is part of a packet [57 byte] which i am sending. Its only taking octal values (0 to 7) and decimal values (mind values only above 32) and giving their respective ASCII character as output. I am unable to understand is why its only giving output as ASCII but not any other format like decimal,hex, etc

        Like

        • Hi Sabiha,
          I think you struggle normal C programming and data representation? Keep in mind that on the processor data is stored binary, and depending on the data respresentation it can be shown in different formats.

          Like

  71. Hi Erich,
    I am incorporating an FRDM-STBC-AGM01 board into a system with a FRDM KL25Z. Data retrieval works fine. To get correct values for yaw, pitch and roll out of the noisy sensor data I am using an open source filter algorithm (http://x-io.co.uk/open-source-imu-and-ahrs-algorithms/)
    The source code for the filter only consits of several multiplications und summations. For good and responsive filter dynamics the filter has to be called as often as possible. Kris Winer shows on his git hub wiki some comparisons between some microcontrollers running this filter algroithm (“Table 2”, almost at the end of the page. https://cloud.githubusercontent.com/assets/6698410/3424919/b143735c-ffec-11e3-851d-6b44bf98cb73.png). An Arduino Uno clocked with 16MHz reaches about 250Hz (depending on used IMU) with Madgwick filter and some display operations. I examined my loop time with an Realtime_LDD Component and measured about 3,9ms for executing the filter source code. My KL25Z was clocked at 20.9MHz (seems standard clock when creating a new project. MCG Output/Core clock are showing 20.97MHz). Together with I2C data request from the sensor I end up with about 5ms loop time. I assumed that the KL25Z with its 32bit Cortex M0+ has to be a bit faster than a slower clocked 8 bit Arduino Uno.
    This is what I am doing in my loop:
    for (;;) {
    res = FXOS8700_ReadAccData(IMU_Interface_DeviceData, &Sens_FXOS8700_ACC);
    res = FXOS8700_ReadMagData(IMU_Interface_DeviceData, &Sens_FXOS8700_MAG);
    res = FXAS2100X_ReadData(IMU_Interface_DeviceData, &Sens_FXAS2100_GYRO);
    //calculation sample frequency for sensor fusion algorithm
    //measure point 1. If RT1_Reset is not commented out at beginning of loop, time_after_meas equals period time of loop
    RT1_GetTimeUS(Rt1_DevData, &time_akt);
    RT1_Reset(Rt1_DevData);
    time_after_meas = time_akt;
    time_sum += time_akt/1000; //sum in ms
    sampleFreq = (1.0f/(time_akt)) *1000000.0f; //necessary for filter algorithm for integrating over time
    //magnetometer data come in uT, must be in mG –> multiply by 10
    //gyro data com in °/s, must be in rad/s –> *M_PI/180.0f
    MadgwickAHRSupdate(Sens_FXAS2100_GYRO.fYs[0]*M_PI/180.0f, Sens_FXAS2100_GYRO.fYs[1]*M_PI/180.0f, Sens_FXAS2100_GYRO.fYs[2]*M_PI/180.0f, Sens_FXOS8700_ACC.fGs_uc[0], Sens_FXOS8700_ACC.fGs_uc[1], Sens_FXOS8700_ACC.fGs_uc[2], Sens_FXOS8700_MAG.fuT_uc[0]*10, Sens_FXOS8700_MAG.fuT_uc[1]*10, Sens_FXOS8700_MAG.fuT_uc[2]*10);
    RT1_GetTimeUS(Rt1_DevData, &time_akt);
    time_after_filter = time_akt;
    //RT1_Reset(Rt1_DevData);

    //onlys send values to console every 100ms to speed up filterung by madgwick algorithm
    if (time_sum >= 100) { //write to debug console and save values to sd card }
    }
    There is only one interrupt routine filled with code in Events.c for analyzing characters sent by my PC through UART0. During measurement no data are sent from my PC.

    I am wondering why code execution is slower than expected. I didn’t suppose that this relatively compact filter algorithm takes so long to be processed.
    Am I reading the clock setting wrong? Does the KL25Z in the end run with a different clock setting?
    Does using Realtime_LDD add too much overhead (and interrupts) when measuring time? Is there someting more efficient for measuring elapsed time?
    Is there any debug compiler setting that may possibly slow down program execution?
    Do you have any idea what causes the comparatively long compute time? What are the places that I can check? I hope I do not have to crawl through assembler code…
    Thanks in advance,
    Johannes

    Like

    • Hi Johannes,
      I cannot access http://x-io.co.uk/open-source-imu-and-ahrs-algorithms/ because it is reported as a site infected by malware :-(.
      The KL25Z can run up to 48 MHz with PLL enabled, so you can get twice the speed. See https://mcuoneclipse.com/2012/10/07/tutorial-usb-cdc-with-the-kl25z-freedom-board/ how to configure it for 48MHz.
      The other thing is: you are doing lots of floating point multiplication, and the ARM Cortex-M0+ does not have a FPU, so this will slow down things. Additionally that core does not have hardware integer division, here again this will slow down things.
      The question is how fast you are getting the data from the sensor? Are you using maxium I2C clock speed?
      What will help you to some extend is to turn on compiler optimizations (-O3 in the compiler project settings).
      Your time measurement method should not impact much.

      I hope this helps,
      Erich

      Erich

      Like

      • Hi Erich,
        oh dear, I didn’t want yout to go to an infected site. Strangely, my browser doesn’t say anything about malware warning…anyway, the source code is also readable on Kris Winers Git Hub: https://github.com/kriswiner/MPU-9250/blob/master/quaternionFilters.ino
        I use the code inside “void MadgwickQuaternionUpdate”.

        There are indeed several floating point operations. Of course rising the core clock speeds up program execution. But for me it doesn’t explain the speed difference. As far as I know, no ATmega based Arduino has an FPU either, and is with its 8bit architecture and slower core clock (16MHz Arduino, 20.0MHz KL25Z) about as fast a 32bit ARM. Does the Arduino IDE somehow optimize floating point operation, that the Kinetis IDE in standard mode doesn’t? Or is a Cortex M0 not imperatively faster than an ATmega Core (assuming similar core clock)?

        Data reading takes about 1.4ms for 9 values of 16bit each, with I2C clocked at 1042kHz (I2C reading functions were taken from a sensor fusion example from NXP sensor fusion source code kit). Calling the filter algorithm takes about 3.5ms. Eliminating the multiplication of the magnetometer values with 10 reduced the call time by 500µs down to about 3ms. Why do three mulitplications reduce the call time by 14%, if there are far more floating point multiplications inside the algorithm? For my purpose 200Hz update rate is fast enough, but I also want to learn something from this and until now I don’t fully understand why there are such speed differences between the Arduino and the supposedly faster KL25Z 😉

        Like

        • Hi Johannes,
          thanks for that link, this one is fine :-). I have not run that algorithm, and I think most of the time will be spent in library floating point routines. I think assembly stepping through the code will show where it roughly spends the time, otherwise deeper analysis is needed. Have you turned on optimizations in gcc? Because with -O0 (the default) the code is really verbose and bloated, so this should give you some speed up.

          Like

  72. Hello Erich

    I am relatively new to this board KL43z
    I have been trying to follow your Wifi Blog using ESP8266
    But have stuck a problem

    When I select the shell component it also loads the AS1 component.
    When I go to the component inspector the first line shows:- The component is not supported for selected processor.

    If I try and generate processor expert code I as you would expect get error messages
    on the problems page it reports :- Error This component is not supported in Kinetis SDK project mode.

    I am probably making a simpletons mistake but help would be appreciated.
    PS I get the same error messages when a new project is started using the 25z

    Andrew

    Like

    • Hi Andrew,
      you have created a project using the Kinetis SDK: the Kinetis SDK is not compatible with most components (SDK 1.x) and does not support Processor Expert in SDK v2.0: you should not see any problems if you create a Processor Expert project with ‘none’ as SDK selection.
      I hope this helps,
      Erich

      Like

  73. hello Erich
    I am using this KL25Z in code warrior, So i just need to toggle the LED in it, i had written the program for that, and its running without any errors, but the thing is it’s not blinking. So can you just help me for toggling the LED thing.
    i have got the output like this in console window as below
    INF: Flash Programming Successful.
    GDI: DiRegisterWrite(PC (id:0xF), value = 0x1CE4)
    GDI: => DI_OK

    Like

  74. Hello Erich
    Actually I am using sim900 module to get TCPpackets but I am getting some network limitations. Is there any alternate method so that I can get the packets from server

    Like

  75. Hi Erich,

    I am using GSM module with UART interface to KL25 and have been successfully sending packet data (62 byte) from module(client) to server(btw the output is still in ASCII format, if you remember i have asked about this earlier 😀 ). Also now i need to get back data from server as well. ie from client prospective:
    1. get ping from server //string (Eg: Device1 you have 4 messages)
    2. response to ping //string (Eg: Forward)
    3. get message data from server // four strings (Eg: x1,x2,x3,x4)
    Please advice how to proceed.
    Earlier while sending packet, after CIPSEND AT command, i used GSM_Uart_Sendchar from component library to send my packet byte wise. What should be my approach this time? Please help!

    Thanks,
    Sabiha.

    Like

    • Hi Sabiha,
      based on your question, I was thinking you use a TCP based GSM modem. I don’t know how you have architected your software, but my usual approach for these kind of things is to implement a state machine with queues which processes incoming and outgoing packets. That way you could have a task which just does the low level message passing, and handles the protocol in the higher layers. Basically what the ISO/OSI does with the a layered network stack approach. You might have a look at the concept in books or even look at how I have implemented in the RNet stack (see https://mcuoneclipse.com/2013/11/17/rnet-a-simple-open-source-radio-network-stack/). But I’m affraid that your question and problem is very, very broad, so I hope you have all the necessary software and architecture knowledge to solve such a problem. Good luck!

      Like

  76. Hi Erich,
    I am using the K22 with either the K22F freedom board one of my own designs.
    My latest design has an SDcard slot because it will need to do data logging. So I have looked at your FATFS projects (on the K25 or K64 freedom boards), and am trying to get mine up and running but I am having a problem with your latest component release (9-21-16) (or maybe all of them)

    I am using KDS 3.2, and following some of your comments I created a new PEX project (with NO KSDK). I add the FATFS component to the project, and it gives me an error in PEX that I cannot understand how to fix or bypass.
    The error is this:
    Method is required by the interface, but is disabled by component settings or by template (SetBaudRateMode) Scout_PEX SM1/SetBaudRateMode Processor Expert Problem

    It’s a problem in the synchromaster component, and it doesn’t want to generate code for the method ‘SetBaudRateMode’. I also see the error message “method is required by the interface, but is disabled by the component settings or by the template.”

    The ‘generate/don’t generate code’ box is grayed out and I cannot make it generate code. And then I cannot make the project because this is missing.

    The pop-up message box says all sorts of stuff that I’m not going to retype here, but it is unclear where I am supposed to specify a list of possible period settings, and if that will make it happ

    Also, if I cannot use KSDK components, how do I easily get my UARTs working?

    Brynn

    Like

  77. hii Erich,
    I need to create a MQTT connect packet and sent it over TCP/IP to a server. Can you please help me on how to code it… I found some in net but nothing on CodeWarrior. Would be really helpful if you could help me out in any way. At-least send me some basic idea about coding it on CW.

    Like

  78. Hi Erich,
    My question is regarding semihosting, I am using KDS3.1.0 with PE,
    in project’s properties>>C/C++build>>Settings>>Cross ARM C++ Linker>>Miscellaneous
    I got these linker files
    -specs=nosys.specs -specs=nano.specs -Xlinker -z -Xlinker muldefs

    so as mentioned in one of your article I removed all these and added only one as
    -specs=rdimon.specs
    when I compile the project it is showing me errors.

    is there any different way for using semihosting in KDS3.1.0 ?

    Like

  79. Hi Erich,
    Thanks for the help, saved me a lot of work.
    Now, I have a different problem on a different project, also a K22FN512, although this is in LQFP-100 🙂
    I was having trouble with the I2C working consistently using KSDK1.3, so I switched to your latest component release and created a PEX only project that uses your generic I2C and the I2C_LDD from the kinetis repository. But lots of other stuff I have for that project uses the SDK 1.3 stuff, and I get errors when I co-mingle them at all. I am going to read up on your two KSDK 2.0 postings to see if that has a solution, but the question is – is there a better way?

    Also I see there was/is a bug in the silicon with the I2C repeated start if you have a prescaler value other than 0 (or 1?), and I can’t tell if that still exists in the current K22FN512 parts I am getting. Is that ancient and has been fixed? It seems the Kinetis I2C_LDD lets you set that prescaler value, but the SDK I2C driver does not.

    Brynn

    Like

    • Hy Brynn,
      Using Processor Expert with the Kinetis SDK is a challenge, I know. I would say unless you are an expert both on the SDK and Processor Expert code, you won’t be able to merge them.
      I do have managed to get them together for the non-low-level hardware components, but the ones like I2C_LDD (which are low level hardware) it is very hard to get them working with the SDK.
      In short: not recommended. You would be better off just learn the SDK V2 and maybe use some of my components with it (as explained in https://mcuoneclipse.com/2016/05/15/mother-of-components-processor-expert-with-nxp-kinetis-sdk-v2-0-projects/). So I’m affraid there is no better way 😦

      As for the I2C hardware bug: to my understanding this one is present in all Kinetis devices, and has not been fixed.

      Like

  80. Hi Erich,
    Still having projects integrating the RTOS into two different projects.
    On one of them, once I added the RTOS the ADC comnponent quit working – the AD conversion I started with AD1_Measure never finishes.

    I went and started a new project using the Freedom Board (K22), and had both the RTOS and ADC components to show that problem, but of course that new project works fine. Is there a possibility that I added PEX components in the ‘wrong’ order? It seems like the projects on my hardware that don’t work have pretty much all the same components as your example projects and new projects that I start, but they work differently.

    I have searched your projects on github and could not find any that used the ADC component and the RTOS at the same time – is there one I missed.

    The other project is the one where I am having trouble using the SPI for both the FATFS (SDcard) and a port expander. I still haven’t solved that yet.

    Brynn

    Like

    • I’m using ADC with FreeRTOS in several projects, but they are not on GitHub. The order should not matter. I belive it is more an interrupt priority problem. Have you tried to use the ADC in non-interrupt mode?

      Like

      • Yes, and it doesn’t work in non-interrupt mode either.
        it hangs in the AD1_MainMeasure fuction on the
        while (AdcLdd1_GetMeasurementCompleteStatus(AdcLdd1_DeviceDataPtr) == FALSE) {} /* Wait for AD conversion complete */

        Line of code for the non-interrupt mode of the ADC component.

        Like

  81. Okay just took a different project with different hardware (but the same K22FN512), and running the ADC in the PEX only project the AD1 component works perfectly.

    I then added the FreeRTOS component and compiled and ran – and it locks up on the WaitForResult while (Modeflg == MEASURE) {}
    (same place). I did not change any code when I added the FreeRTOS component.

    Like

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

  83. Hi sir, excellent page really. My question is simple I using the Tower for many projects and I have the TWR-DEV-PERIPH and I like to connect with a Raspberry Pi. Is possible do that ?

    Short history: I need to control a Robocar with the board but if I can controlled by the raspberry connected to the board and using a wifi shield to connect the car with one Arduino via wifi. My idea

    Like

  84. Hello,

    Using Microsoft Visual Studio Source Control. Using Code Warrior 10.4 for MKL36Z256VLL4 chip.

    I am new to Code warrior and Process Expert. I need to take some code from the Source Control and open the project in Code Warrior. I get the code from the source control onto my system but I cannot find out how to open or import the project into Code Warrior. Hope some one can tell me how to do this and make sure the PE is working.

    Also, I have noticed that the project that was on the system I inherited seems to have fixed path names and was wondering how to make them virtual path names?

    Thanks in advance,
    John Vogel

    Like

    • Hi John,
      I have not used Visual Studio source control as version control system with CodeWarrior, so I cannot really comment on that. I have used CVS and Git with CodeWarrior and this worked fine, and there were no issues with project settings or things like absolute paths, given that only the correct (not derived) files are stored in the system. For example the ProjectInfo.xml has absolute paths, but this file is *derived* and shall not be part of any version control system.
      There are a few things to know and consider dealing with Processor Expert, discussed in https://mcuoneclipse.com/2013/03/29/version-control-with-processor-expert-projects/.

      I hope this helps,
      Erich

      Like

  85. Hi Erich

    Firstly, I love this site. Thanks for your help.

    I am using CW 10.7 with Processor Expert and the KL25Z and I am trying to get Uart1 to run at 115200 baud so that it can communicate with a PAN1322 bluetooth module.

    I set up the CPU clock parameters just like you did in “using-the-frdm-kl25z-as-a-usb-mouse-device” . This allowed me to select a baud rate of 115200.

    When I try to send the AT command for RESET, I get a syntax error response (-1) from the PAN1322.

    Could it be that the CPU is not set up properly.

    Like

  86. Hi again
    I solved the problem. The PAN1322 needs some time for initialization, so I send AT reset commands until I get an “ROK”. The Uart1 is behaving properly at 115200.
    Thanks

    Like

    • Hi Eli,
      ah, I was looking into this right now :-). Good that you have it resolved. As a tip (and probably you already know about this): a logic analyzer is very useful in those situations to verify the signals on the wire.
      Thanks for reporting back!

      Like

  87. Hi again
    I implemented your Freedom_UsbCdc example and it works just fine. I noticed that you created the host.c routine to interface between the stack and the application.
    I am trying to connect a barcode reader to the KL25Z. I have the hardware all done and am providing external power to the barcode reader.
    I changed the FSL_USB_Stack component from a CDC_device to a CDC_host. It all compiled fine.
    What do I need to do in the host.c to interface to the stack?

    Thanks for your help
    Eli

    Like

  88. Hi Erich,
    Do you have any recommendations about where a person can find out how to either cross-compile, or native compile, Qt5 for the Raspberry Pi (or Beaglebone Black) with an Ubuntu host? I have spent the last several months searching the internet to find out how to do it and nothing has worked so far.

    I know this is outside the normal range of your website, but I thought I would ask anyway.

    Thank you.

    Like

Leave a reply to Johannes Rost Cancel reply

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