PIC simulators for Mac OSX

Thread Starter

portreathbeach

Joined Mar 7, 2010
143
I program my PICs in asm, maybe going to use C in the future, in MPLabX on a Mac. I usually create my schematics and build my own circuit boards using Cadsoft Eagle.

Up till now, I run the simulator in MPLab X to test my PIC programs, but have noticed that there is software like Proteus for the PC that allows the MPLab program to be placed in the PIC and the circuit can be simulated in the schematic. Please can someone recommend a simulation program that I can use on Mac which will allow the import of Eagle schematics.

Thanks
 

Thread Starter

portreathbeach

Joined Mar 7, 2010
143
OK. I think I've found it. LT Spice seem to do what I want. Is it any good?

The problem I have just found is that LtSpice.ulp is only available for Windows, so exporting from Eagle to LtSpice isn't possible. Maybe I'll have a go at editing the ulp
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
It's great at analog simulation. It's terrible for what you wish to do.

I've never had much use for simulators like that. By the time I have accumulated all the pieces for an involved design I just build the dang thing and hit it with measurement tools (meters, scopes), all under MPLAB running an in-circuit debugger such as PICkit 2, 3 or an ICD3, I have em all.
 

Thread Starter

portreathbeach

Joined Mar 7, 2010
143
Yeah, that's what I've done up till now and it works. Just didn't know if it's worth trying a simulator program.

Anyway, been looking into migrating over to C from programming PICs. Can you explain how the simulator works in MPLab if running C code. Obviously when running assembly, each instruction takes a set time and the 'stopwatch' feature shows the exact time taken to carry out a specific part of the code. In a piece of C code, you may have a For loop, which is only a couple of lines, but if the loop was counting to say 1000000, that would translate to tens of lines of code in asm.
 

ErnieM

Joined Apr 24, 2011
8,377
I use the Microchip C compilers inside MPLAB and they work the same way with C as they do in asm: line by line. Sure, a line is more then 1 asm statement but the stopwatch tracks it anyway. Occasionally you may have a line that "runs funny (last part of a compound statement first) or got abstracted away but you can rewrite for those cases into several distinct steps.

For the best granularity you can also drop into the disassembly listing where each C statement is a comment followed by the actual asm code generated.

They work that way either simulating code or in circuit debugging.
 

Thread Starter

portreathbeach

Joined Mar 7, 2010
143
Thanks again ErnieM for your input.

I know this is a bit off thread, but as I am designing a Nixie tube clock where a 40 pin PIC will be located under another board, I was thinking about in circuit programming it.

I've been writing PICs for 4 or 5 years and never done ICSP. Have you done this before?

I see from various threads that the MCRL line needs a little work done to it to enable the programmer to connect to it and also the 2 serial data lines need resistors in them too. I'm a little confused about the supply voltage though. I normally use my PicKit2 and recent addition PicKit3 to supply the voltage for programming. Could I simply connect the PicKit3 supply voltage pin to my common 5 volt rail on my circuit.

Luckily, I have not used the MCLR pin of the PIC in my project so I guess I can attach it directly to the programmer. The programming pins on the other hand connect to a 74141 BCD chip, so I assume I could put a resistor in series with the chip, maybe a 220R to 'isolate' the chip from the programmer.

Any advice would be great
 

ErnieM

Joined Apr 24, 2011
8,377
Unless there is some rare constraint I *always* use ICSP, and will even use a larger pin count device (again if possible) to keep the MCLR, PGD and PGC lines free so I can also do in circuit debugging.

The rare exceptions are the times I used a PIC12HV615: just 8 pins, and the board was just so tiny I had no room for anything else. Board was literally about 0.1" by 0.3" and the leadless chip carrier PIC was pre-programmed before solder attach. Plus that chip doesn't have the debug circuitry.

Generally if the PGD and PGC are used as outputs you need do nothing extra to use as programming pins.

MCLR will be driven to a high voltage (up to 13V I believe) so it needs some isolation. Also put about a 10K pull up on it if doing in circuit debugging (which is no doable if PGD & PGC are used to drive other chips) so the circuit doesn't get flaky once you complete debugging.

PICkit 2 or 3 can supply power to the PIC, or use the power that is there. So yep, you connect the PICkit Vdd pin directly to the 5V rail. Same with the other 4 pins.
 

Thread Starter

portreathbeach

Joined Mar 7, 2010
143
Hi again ErnieM, yes, in my circuit the PCG and the PGD pins of my PIC are both output pins, so are you saying I can simply connect these straight to the programmer without the need for resistors before the 74141 chip?

Also, if I'm not going to do in circuit debugging, does that mean the MCLR pin can be left completely free from the circuit and just connect to the programmer too, or is it still wise to add a 10k pull up resistor?

If I leave the MCLR pin with no connection to my circuit, will the 13V damage anything else connected to any of the other pins?

If this is the case, it should be pretty easy to add a 5 pin header to my already tightly populated board.


Edit:

I just found this image on the net:


What's the need for the capacitor?

Thanks again.
 
Last edited:
Top