PIC C COMPILER

Thread Starter

bilal sheikh

Joined Jan 21, 2015
22
any one here who have used PIC C (ccs pic c compiler pcwdh) for pic programming ?
i want to access SFR registers like PR2 and TMR2 but dont know how to access these. kindly help :)
 

Papabravo

Joined Feb 24, 2006
22,075
Normally you would have an "include" file with an extension of ".h" containing the definitions of all of the file registers. These definitions would look like"

#define TMR2 0x87

for example. There should be an include file for each PIC variant supported by the compiler. If you can locate such a file and include it with your source code you can write statements like

TMR2 = 0x9C ;
 

ErnieM

Joined Apr 24, 2011
8,415
If you can locate such a file and include it with your source code you can write statements like

TMR2 = 0x9C ;
I believe you meant to make that a define statement. As written it is a simple assignment where the lvalue may not be determined.
 

Papabravo

Joined Feb 24, 2006
22,075
No I meant it the way it was written. What I did not specify was the content of the include file which would have a definition which allowed the string TMR2 to resolve into an lvalue. I just don't have a handy example at the moment.
 

ErnieM

Joined Apr 24, 2011
8,415
The #define example you wrote is pretty close, though typically all working registers are defined as "volatile".

Just let it lie there least we start another useless thread concerning the necessity of that keyword. ;)
 

takao21203

Joined Apr 28, 2012
3,702
Only true Alchemists download MPLABX and use project templates.
You actually dont need to do a thing, and get all the files created.
 

Thread Starter

bilal sheikh

Joined Jan 21, 2015
22
thank u all for ur valuable suggestions, the problem was resolved. we can generate a file for all PIC varients that contains defination of all SFR's and can access all SFR's.Screenshot (40).png
 
Top