Monday 23 February 2015

embedded - Variable declaration with @ in C


I am reading some C code and came across this declaration in the program:


unsigned char serv_ctr @0x0002;

Can someone point me to documentation, or explain what the "@0x0002" is for in the Mplab XC8 v1.35 C compiler?



Answer



This is to specify an absolute address to place the variable at.
From the XC8 compiler manual page 27, section 2.5.2 Absolute Addressing:



Variables and functions can be placed at an absolute address by using the __at() construct

......
2.5.2.2 DIFFERENCES
The 8-bit compilers have used an @ symbol to specify an absolute address



No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...