I want to run some C code targeted to run on a unique PIC micro based hardware setup in a PC windows environment as well. The objective is to emulate multiple instances of the hardware without the actual hardware. I expect to have to write the code upfront to account for this and to create low level functions in C or C# that emulate each of the PIC functions. Does anyone know an environment that can support this?
-
You are light on details, but one way would be to compile the PIC code for your developing environment, then run these functions in different threads. But there are many ways. – Prof. Falken Apr 29 '13 at 07:10
-
What you want to do is simulate the PIC controller and run your code in the simulator? if yes you can try this [LINK](http://sourceforge.net/projects/gpsim/). – Koushik Shetty Apr 29 '13 at 07:12
-
It really depends on what you need to test. If you are primarily concerned with algorithms, it's often enough to write replacement I/O routines and build targeting the development machine. At the opposite extreme of complexity, there are full cycle-accurate simulators for embedded processors. – Chris Stratton Apr 29 '13 at 16:40
-
Actually I need to test a c# app running on a PC that talks to a multitude of PIC micros (down a TCPIP link). I need to test before I have the PIC micros in place so hence the interest in emulating the PIC code. I don't need to do a low level cycle simulation of the PIC code I am ok developing that on the target system (although others below have pointed out the PC environment may be quicker). My focus here is on how to test the PC code using the actual PIC code rather than coding a second PC version. – cpluspluseverywhere May 01 '13 at 09:41
2 Answers
What you're looking for is a microcontroller simulator. The simulator will run on the PC and execute the PIC code. In order to e.g. generate interrupts / simulate serial data / whatever you'll need to either configure the simulator settings or write a few custom function.
Your target code (for the PIC itself) shouldn't need to be aware of what environment it's running on.
Here's a few links, but you're best off searching for some variant of "PIC microcontroller simulator" or "microchip PIC simulator".

- 1,313
- 4
- 16
- 24
I'm not sure that this question is about an instruction simulator. It seems to me that it is simply about the technique called "dual targeting". I've asked a similar question on StackOverflow before, please see: Prototyping and simulating embedded software on Windows . Recently, I've also made a blog post about dual targeting and rapid prototyping on Windows here: http://embeddedgurus.com/state-space/2013/04/dual-targeting-and-agile-prototyping-of-embedded-software-on-windows/ .
So, while the links should provide the answer to the original question, I'd like to add that the 8-bit PIC is probably no programmable in C++. In fact, it is so baroque that even C compilers for this "architecture" must cut many corners.

- 1
- 1

- 1,909
- 14
- 19
-
Thanks you are much closer to what I want to do. I dont need low level. Although in your blog post your motivation is to speedup dev (and involves HMI) wheras mine is to provide a method to test the PC interacting with multiple embedded devices without physically making them. My PIC embedded device is doing measurement & runs a mini home grown RTOS. I had not heard of the term dual targeting before so thanks that is exactly what I want to do. The C compiler i am using is MPlab version so now I just need to find a PC complier that works the same as the PIC compiler. – cpluspluseverywhere May 01 '13 at 10:02