what is #pragma pic

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi guys,

I am new to PIC and I am coming from AVR, setting the registers in PIC is about the same as AVR for me, but there is one thing that I am totally lost.

there are a few example code, they use something like:
Rich (BB code):
#pragma config
#pragma rom
#pragma data
#pragma .....
I am guessing they are same as setting those individual bits in registers, but I don't know for sure and can't find much info about these on Google. Can someone point me to the right direction please?

A tutorial or something is perfect.

Thanks
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
for who have the same question, details info can be found \Microchip\xc8\v1.10\docs\manual.pdf, and
\Microchip\xc8\v1.10\docs\pic_chipinfo.html
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
so #pragam config ... ... is same as setting the CONFIG register, what's the advantage of over setting CONFIG register in the C code anyway? any good reason except using #gragam config is a little easier?
 

t06afre

Joined May 11, 2009
5,934
You should not bother with other #pragma settings than the #config settings in 99.9% of your programming. I like to use the header file for my current PIC as base. I cut out all the configuration setings from the header file. Then I paste it in to my code code. And just comment out the settings not needed or used
 

ErnieM

Joined Apr 24, 2011
8,220
#pragma is a well defined way to send some message to a C compiler saying "hey, I need you to do something specific to my hardware, something outside the bounds of normal C code, so let's just be pragmatic about this."

There are many things you may need to tell your compiler, such as configuration settings, the address to start placing code, that the following routine in an interrupt handler, and so on. Things beyond normal C bounds.
 
Top