Rich (BB code):
#include <htc.h>
#define _XTAL_FREQ 4000000
__CONFIG(0x3F39);
void main()
{
unsigned char sGPIO=0; //shadow copy of GPIO
unsigned char dcnt; //delay counter
//initialisation
TRISIO=~(1<<1); //configure GP1 (only) as an output
//Main loop
for(;;)
{
//toggle GP1
sGPIO ^= 1<<1;//flip shadow bit corresponding to GP1
GPIO = sGPIO;//write to GPIO
//delay 500ms
for(dcnt=0;dcnt<5;dcnt++)
{
__delay_ms(100);
}
}//repeat
}
I got this code from this website
http://www.gooligum.com.au/tutorials/midrange/PIC_Mid_C_1.pdf
it's a pdf file and the code is taken from page[16]
can you explain to me in a more simple way or modify the code to a more understanfable code.
especially those highlighted(what shadow and what symbol represent for that ^=1<<1).
assume if change to using pic16f877a instead of using the same pic as this example.this example is using pic12f629.
i need to understand this before going to the following page especially page[21] that about switch debounce.
Last edited: