Connect with us

Simulate the software before flashing

Discussion in 'Microcontrollers, Programming and IoT' started by electronicsLearner77, Feb 15, 2017.

Scroll to continue with content
  1. electronicsLearner77

    electronicsLearner77

    162
    1
    Jul 2, 2015
    I want to simulate my software before actually flashing into the hardware. I am looking into microchip controllers. External tools also ok for me. I want to test my logic since I am finding lots of issues like flags not properly reset and etc. I want to test all the loops. Please suggest.
     
  2. brevor

    brevor

    87
    16
    Apr 9, 2013
    Microchip's MPLAB software has a simulator called MPSIM built in.
     
  3. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    And it's free!

    Bob
     
  4. hevans1944

    hevans1944 Hop - AC8NS

    4,626
    2,159
    Jun 21, 2012
    I don't trust software simulators much, because software that checks "good" in the simulator may fail in the final hardware install, usually because of real-time timing issues. These can be a real bitch-kitty to troubleshoot and correct.

    It is okay to use simulation to verify the correctness of your program, but if using MPLAB you will quickly find out whether your program syntax is correct and whether or not the program is ready to download to the target. If it is okay, then you might as well download it so you can test its functionality on the real hardware. After all, the final "test" is whether or not a program performs correctly when downloaded to the target microcontroller or microprocessor.

    Most micros use non-volatile FLASH memory technology for program storage. This type of memory can be overwritten hundreds (or even thousands) of times without fear of damage, so it is a good idea, IMO, to routinely download the program to the target during program development, skipping the simulation.

    In early phases of program development, especially where timing is important, I normally install breakpoints in the program that use whatever I/O ports are available to let me know how and where the software is executing, removing and replacing these breakpoints as program development proceeds. Of course this is most easy to do in a simulator, but be aware the timing might not be accurate. For me at least, program development is always an iterative process. If simulation makes this process go faster, use it. Unfortunately (perhaps) the Microchip product line is complex. You need to thoroughly review the datasheet and understand ALL the flag and control bits, and learn how to use them to obtain the functionality you desire.

    If you get in trouble, you can upload snippets of code to this forum for someone to inspect and perhaps guide you. Ask, if you need help with that.
     
    Arouse1973 likes this.
  5. electronicsLearner77

    electronicsLearner77

    162
    1
    Jul 2, 2015
    Thank you very much for the replies.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-