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,039 thoughts on “Q&A

  1. Hi Erich,

    There are various CAN interface devices like the Vector CAN Case, the Komodo CAN Interface, etc. I am not very familiar with how these interfaces communicate with the PC over USB. Do you know the data is transmitted over USB? I will start experimenting with NXP USB examples for FRDM boards. My goal is to use a FRDM board with a CAN interface to capture CAN traffic and then send to a PC Application over USB for displaying the CAN ID and the payload. I imagine there is some data packet protocol involved in the data transmission. Do you have any projects along these lines, perhaps reading Sensor Data or Telemetry Data?

    Thanks,
    David

    Like

    • Hi David,
      I have not worked with CAN recently, and I don’t have a project to share with you.
      There is to my knowledge no special Can2USB protocol. Most do a simple CAN-to-Serial (UART, USB CDC) conversion. Simply capture things on the CAN side and transmit as USB CDC data to the host, and vice versa.

      Erich

      Like

  2. Hi Erich

    I want to develop Arm Coretex M4 code on an Arm MPS2 development board. I don’t currently have a debug probe but the MPS2 has a USB port that supports CMSIS-DAP debug. I have used this successfully with the Arm Development System suite, but I want to use Visual Studio Code instead. My question is, what software components do I need to build a debug system using Visual Studio Code, targeting the USB CMSIS-DAP debug device, and using the armclang toolkit?

    I have a good understanding of VS Code.

    I have a CMake script that builds an elf file from our source using the armclang tools. I am familiar with how to integrate CMake with VS Code.

    Arm has an Arm Embedded Debugger VS Code extension which I think supports CMSIS-DAP. Would that be a good way forward? (https://marketplace.visualstudio.com/items?itemName=Arm.embedded-debug).

    And then, do I need OpenOCD and the arm debugger (not sure what that is) ?

    Any hints would be appreciated.

    Best regards
    David

    Like

    • Hi David,
      you need a debug server (e.g. OpenOCD) which talks over CMSIS-DAP with your debug probe. And you need to configure OpenOCD with the correct script/settings for your target board.

      Like

  3. Hi Erich,

    First of all, I thank you for developing such a great plugin PEx, I am learning to use it now. I am using a key module on kl05z and I am not sure how to configure it to use it properly. The programming environment I am using is – CodeWarrior for MCU Version: 11.1 Build Id:181224. thank you!

    Best regards.
    Lance

    Like

      • Hi Erich,

        The idea I got from your project is to add a timer module on top of the component and then trigger AddTick() in the timer interrupt function.
        Now there are 2 problems:
        1, After configuring the timer when not using freertos, the keys are not responsive enough and need to be pressed 2 times to achieve the function. I am not quite sure what is causing this.
        2, I want to use the key component in freertos short press and long press and hold state, is it open the RTOS in TRG?Do I still need a timer trigger?

        Best regards.
        Lance

        Like

        • Hi Lance,
          1. Are you using interrupts or polling? For polling, you need to poll it frequently enough (say every 10 ms or so). For the timer, this needs to be fast enough (faster than the debouncing wait time, so for example configure it to 10 ms).
          2. If using FreeRTOS, you have to feed the trigger (TRG_AddTick()) every 10 ms or so too. You can do this from the FreeRTOS tick hock.

          Like

      • Hi Erich,

        The advice you gave me was great, and it all hit the nail on the head. I basically understand all the features now. However, I have one last question. It’s a question about the interrupts and the FreeRTOS tasks running between them. I have 1 light bead blinking any configured in FreeRTOS, and I want to implement a 2 second delay in the OnKeyHold interrupt to turn off the light bead blinking. But then after I press the switch for a long time, the program stays in OnKeyHold directly interrupting the task of holding down the button while the light bead is blinking. I want to use OnKeyHold to avoid key state malfunction, but at the same time I want the FreeRTOS task to run continuously until the key is not placed for 2 seconds. I am not sure what is a better way to achieve my needs, thank you!

        Best regards.
        Lance

        Like

        • Hi Lance,
          good to hear that things are making progress. As for your question: do you have interrupts configured for level or edge? It should be on Edge, and then you should only get one interrupt (ideally).
          Otherwise you might need to turn off the button interrupt and turn it on again at the end.
          As a general solution to your use case (if I understand it correctly): you always can send events from the interrupt to your task in question.

          Like

  4. Do you have any experience with Linux Mint based Eclipse and the Pico W?
    I am trying to set up a system now and would like any good examples of using the Eclipse Linux Based IDE and the Segger JLink devices, as that is what I have for hardware debug.

    Like

  5. I’ve just attempted to add a Wi-Fi AP mode to a project I’m working on which currently uses McuLib and LwIP in Wi-Fi STA mode, and have run into an issue where I’m now getting “error: expected identifier before numeric constant”, which seems to boil down to McuLib defining ERR_OK and LwIP also defining ERR_OK.

    Am I missing some obvious way of avoiding the issue? I’m currently attempting to reimplement each change incrementally in order to work out what exactly causes the error to appear but haven’t found anything useful yet.

    Like

    • Hi Stephen,
      yes, this is a common issue with C not having multiple name spaces :-(. I had the same issue too, and the solution is to first include the lwIP header files, and later the McuLib one. The McuLib checks if things like ERR_OK is already defined, and does not redefine it. I had to do it in such a way for example with many ESP32 projects too.

      Like

  6. Hi Erich,
    Just switching to a new board rev for my mk22FX512 project, and The buyers could only find the mk22FX512A parts. I told them this was okay, as I should be able to compile for the other version.
    Well, the other version crashes early in PE_low_level_init.
    Do you know changes I need to make to get my FX512 code running on the FX512A ?

    Byrnn

    Like

    • It seems like I have PE bean for the MK22FX512VLL12, but I should switch it to one that knows about the MK22FX512AVLL12. (-A version). I hope my old KDS supports this processor.

      Like

        • so when I run non-A code on the -A, it gets a hard fault on this code:
          /* Initialization of the FTFL_FlashConfig module */
          /* SIM_SCGC7: MPU=1 */
          SIM_SCGC7 |= SIM_SCGC7_MPU_MASK;
          /* Initialization of the MPU module */
          /* MPU_CESR: SPERR=0,VLD=0 */
          MPU_CESR &= (uint32_t)~(uint32_t)((MPU_CESR_SPERR(0x1F) | MPU_CESR_VLD_MASK));
          /* Initialization of the PMC module */

          when it tries to AND into the MPU_CESR register.
          I have both RM’s open and don’t see any differences in that part. It has a different SIM_SDID(REVID) 2 for non-A , 6 for -A,
          and also a different JTAG PRN (2 for non-A, 6 for -A again)

          Like

        • Well, that’s at least a place to look at. I still would recommend that you download the SDK of the A version and check in one of the examples their clock settings (Kinetis initial clock settings are a nightmare to me, and not well documented) and try pasting/adopting that code into your clock setting routine.
          Once you have found the fix, you could keep your modified code with https://mcuoneclipse.com/2012/03/23/disable-my-code-generation/

          Like

    • Hi Brynn,
      our sumo robots are based on the K22FX512 (non-A) version, I’m not sure what the difference between A and non-A would be.
      I think it could have a difference with the internal clocking.
      BTW, I’m using that K22FX512 now with VS Code.

      Like

    • Hi Brynn,
      NXP (and Freescale) never made the toolkit or instructions available how to build a CPU bean. Only what they provided was the BeanWizard I’m using which can create ‘normal’ beans. I would guess that building a CPU bean would not be harder than building a normal component bean, but it is hard to tell without the proper information.

      Like

  7. Unhelpful comment from the peanut gallery, call up NXP’s technical rep and ask them what’s going on with the difference between the two parts. They either know or should want to know.

    Like

  8. We Solved the MK22FX512A / not A problem.
    We bought what are marked MK22FX512AVLL from china.
    except they are mask set 0N50M, which is a MK22FN512VLL.

    Someone on Alibaba is selling remarked chips that wont work. (unless I treat it as an FN, which has different memory architecture and no CAN)

    Like

  9. Hi Erich,
    I needed some more IO so I added an HC165 to my board. (K22FX512A)
    I put it on spi0, and used spi0_cs0
    I also already was using spi0_cs0 as an output, with a 6C595 and an HC595 daisy chained together. (a 6C595 is like a HC595, but it has open drain outputs that handle 30v).
    Now I am trying to figure out how to use processor expert to both SM1_send_block and SM1_recieve_block to read and write at the same time.
    Is it not possible? I’m also sending out 16 bits, and only intend to read back 8 bits.
    Obviously I am using PEX.

    Brynn

    Like

    • Hi Brynn,
      with PEx, the ‘Send’ is doing the ‘receive’ into a buffer, as SPI is a shift-in-out-register.
      So you have to do a SendBlock first, and with ReceiveBlock after that you get the data.
      SM1_SendBlock(writeP, writeSize, &snt);
      SM1_RecvBlock(&buffer[0], writeSize, &snt);
      You have to use the same size of buffer/data for the SendBlock and the ReceiveBlock. In your case, just ignore the not needed data.
      So with SPI, you cannot send out 16 bits and only receive 8 bits: you will get 16 bits in any case by the hardware.

      Like

What do you think?

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