+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Full Member level 6
    Points: 2,866, Level: 12

    Join Date
    Aug 2012
    Location
    .
    Posts
    375
    Helped
    7 / 7
    Points
    2,866
    Level
    12

    Moving from Arduino to actual C

    I'm working on a project and for proof of concept I used a Cortex M0 based Arduino board (MkrZero) for the micro controller portion. I have some limited experience with C and wrote the firmware using the Arduino IDE. Now that its all working I would like to move away from the speed limitations inherent to the Arduino operating system. The nice thing about the Arduino approach is the readily available open source libraries, but you pay a stiff price in performance. Most of the code I wrote is pretty basic stuff, loops and switch statements etc, so those aspects should compile under a regular C compiler.

    The one aspect I'm not looking forward to is the display code, I'm using a generic SPI based 320 x 240 TFT display with touch screen, I'm actually okay with the Arduino library for the display, it works well and is not overly slow.

    Assuming I get a conventional C based loop and interrupt firmware to run on this uC, is it possible to use the Arduino display library or do I need to write this from scratch?


    The display : https://www.aliexpress.com/item/2-8-...617643223.html

    I think this is the library I used: https://www.arduinolibraries.info/li...afruit-ili9341

    Any suggestions from anyone that has migrated code from Arduino to regular C or suggestions for a non Arduino IDE are welcome.

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 5
    Points: 8,870, Level: 22
    Achievements:
    7 years registered
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,567
    Helped
    358 / 358
    Points
    8,870
    Level
    22

    Re: Moving from Arduino to actual C

    Depends of compilier that you are using. For example, Keil uVision support c++, so you can keep using your arduino sources.
    Really depends what are you trying to do. If it is just a simple gui - probably, direct driving using this library is enough.
    If you need to make a kind of framebuffer with high update rate, you need to write a driver by yourself: memory -> dma -> pereferial (SPI/FSMC) -> display controller.
    Love me or hate me. All infractions will be ignored.


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  3. #3
    Super Moderator
    Points: 28,503, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,470
    Helped
    1078 / 1078
    Points
    28,503
    Level
    41
    Blog Entries
    6

    Re: Moving from Arduino to actual C

    Assuming I get a conventional C based loop and interrupt firmware to run on this uC, is it possible to use the Arduino display library or do I need to write this from scratch?
    Significant part of the libraries for Arduino have their source codes available in the folder designated for the libraries, and I wouldn't doubt that this could be the case at hand, so if I were you I would make a deep search on your computer to see if it is there somewhere.

    Any suggestions from anyone that has migrated code from Arduino to regular C or suggestions for a non Arduino IDE are welcome
    Although Arduino loses some performance and flexibility in excess abstraction, on the other hand it is a language that gains from C by having C++ as its native SDK running in the background compilation; You can even rename the .ino file to .cpp and find that it is an accepted extension and thus take all the benefits of an object-oriented language, but this would be suited only for those who have a little more familiarity with this language.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  4. #4
    Full Member level 6
    Points: 2,866, Level: 12

    Join Date
    Aug 2012
    Location
    .
    Posts
    375
    Helped
    7 / 7
    Points
    2,866
    Level
    12

    Re: Moving from Arduino to actual C

    Quote Originally Posted by Easyrider83 View Post
    Depends of compilier that you are using. For example, Keil uVision support c++, so you can keep using your arduino sources.
    Really depends what are you trying to do. If it is just a simple gui - probably, direct driving using this library is enough.
    If you need to make a kind of framebuffer with high update rate, you need to write a driver by yourself: memory -> dma -> pereferial (SPI/FSMC) -> display controller.
    Software is not my strong point so I'm looking for advice.

    Option 1) On the Microchip website, it appears they offer a free IDE and compiler for the SAM MCU https://www.microchip.com/development-tools
    Option 2) On the Microchip website, it appears they offer a SAM-ICE debugger for $150, I'm assuming that integrates with their free IDE and compiler for the SAM MCU? https://www.microchip.com/Developmen...ls/AT91SAM-ICE
    Option 3) Keil offers a free evaluation version with some limitations, I'm not sure if I can work within the limitations, looks like 32k code space limit? However beyond that Keil is way beyond what I'm willing to pay

    I already have the following Segger programmer, perhaps I can work with it and the free Microchip IDE https://www.digikey.com/product-deta...061-ND/7387472

    Would appreciate your thoughts.



  5. #5
    Advanced Member level 5
    Points: 8,870, Level: 22
    Achievements:
    7 years registered
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,567
    Helped
    358 / 358
    Points
    8,870
    Level
    22

    Re: Moving from Arduino to actual C

    You can use even Visual Studio or make crosscompilation under linux. Many options to not pay anything.
    Love me or hate me. All infractions will be ignored.


    1 members found this post helpful.

--[[ ]]--