sukumar
Junior Member level 3
Hi All,
I have come across a doubt, Assume I have written a code eg. a simple LED blinking code for PIC Micro-controller. In that program I used three variables called 'x' and declared it as int x=AA,y=0xaa and delay_cnst(Local). Now I built the project. The build will give hex file. I burned the hex file into microcontroller. Now the microcontroller has only the hex file and all the variable i used will be in hex file only(Program memory) ie No data memory involved. Finally my question is how the data's (Global and Local Variables)are arranged in program memory and how they copied to data memory? How they are initialized? where the value 220 stored in my program etc.
Suggest me some books or tutorial to read more about these things.
I have come across a doubt, Assume I have written a code eg. a simple LED blinking code for PIC Micro-controller. In that program I used three variables called 'x' and declared it as int x=AA,y=0xaa and delay_cnst(Local). Now I built the project. The build will give hex file. I burned the hex file into microcontroller. Now the microcontroller has only the hex file and all the variable i used will be in hex file only(Program memory) ie No data memory involved. Finally my question is how the data's (Global and Local Variables)are arranged in program memory and how they copied to data memory? How they are initialized? where the value 220 stored in my program etc.
Suggest me some books or tutorial to read more about these things.
Code:
#include <pic.h>
__CONFIG(0x3f72);
unsigned char x=0xAA, y=0x55;
void DelayMs(unsigned int Ms);
void main()
{
DelayMs(10);
TRISD = 0x00; //PORTD Configured as O/P
while(1)
{
PORTD = x;
DelayMs(500);
PORTD = y;
DelayMs(500);
}
}
void DelayMs(unsigned int Ms)
{
int delay_cnst;
while(Ms>0)
{
Ms--;
for(delay_cnst = 0;delay_cnst <220;delay_cnst++);
}
}
Last edited: