Tips to start programming pics

Thread Starter

Ironic

Joined Dec 23, 2008
18
it´s been a few years since i programmed in assembly, and i am now in a position where i need to do a few projects envolving pics.
my doubt now is between programming in assembly or C.

My idea is that assembly is better by one side, because it allows more control over what we are doing, while C (that i know well) would allow to write bigger programs a lot faster.
My question about C, is if it is possible to access some of the special features of chips, like watchdog timer,pwm and generating interrupts from signal changes on ports.
I could only find simple c guides that did not cover this points.

was hoping for some advice on this. Tks
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,027
C is a good choice for programming the PIC. You may find it a wee bit expensive.

If you like FREE then you may want to consider the ATMEL AVR since the Assembly Language and the C-Language programming tools are free and very powerful.

By the way C compilers support the low level hardware features of the PIC or the AVR microcontrollers.

hgmjr
 

Thread Starter

Ironic

Joined Dec 23, 2008
18
can you point me to some site or literature were the low level hardware features os pics are explained trough C? tks
 

futz

Joined Dec 14, 2008
23
My idea is that assembly is better by one side, because it allows more control over what we are doing, while C (that i know well) would allow to write bigger programs a lot faster.
My question about C, is if it is possible to access some of the special features of chips, like watchdog timer,pwm and generating interrupts from signal changes on ports.
Assembly gives you cycle-accurate fine control, which is pretty much impossible in C. But you can use inline assembly code inside C to do the same thing for the time-critical part. This isn't something you'll do very often, but sometimes it's necessary.

For everything else C is great! You have full access to all MCU features, same as in asm. Timers, PWM, interrupts, ports, etc. are all just as accessible as in asm. No problem there.

I love assembly language programming, but C makes things so much quicker and easier. Also, C programs, especially bigger ones, are SO much easier to read/understand, especially when you've not looked at the source for a long while.

If you're going to be programming PICs in C, I highly recommend SourceBoost BoostC. The demo is only code size/RAM limited - works for all supported PICs. And when you hit the limits of the demo, a full license for the compiler is only about $75! Compare with C18's price of ~$500 and PICC's price of ~$1000. It's a no brainer! Better yet, BoostC comes with both 16F (supports some 12F also) and 18F compilers.
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,027
Here is a link to a website that shows some code samples for the free AVR C-compiler called WINAVR.

This C compiler works with pretty much the entire AVR family of microcontrollers.

Did I mention it was free?

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
You can download the assembler AVRSTUDIO4 at www.atmel.com and check it out right now.

You will be surprised at its power. It is full-featured without any limitations.

hgmjr
 

Thread Starter

Ironic

Joined Dec 23, 2008
18
tks, but i prefer using pics. already a bit familiarized with them, and have a programmer.

all i need is some guides on using C with those features. tks
 

n9352527

Joined Oct 14, 2005
1,198
Which PIC are you thinking of? For 18F the C18 from Microchip is free, except for one disabled code optimisation option (not really a big deal for most project). The help file included is informative enough to get you going.

The idea is the same with assembler, the peripherals are controlled through Special Function Registers by writing or reading the values. For example, to load the timer, in assembly it would be:

movlw 0x40
movwf TMR0

In C it would be:

TMR0 = 0x40;

As you can see, the procedure is exactly the same only the syntax is different. The datasheet would have complete information on how to control and access all available peripherals.
 
i made many codes for picaxe how to convert for pic .. any software conversion available for it and can anyone explain the picone micromouse pcb board to me how the pcb connections and what is each made for speciallt the registers capacitors and the sensors :D
 
Top