Friday, 20 July 2012

PIC16F887 Hitech C Basic

I thought i'd share this here, as might help someone starting to dive into the PIC architecture.
I always been afraid of PICs compared with AVR, as the learning curve is much higher.
But, thanks to a few friends in a forum ( ). i lost the fear and even dug deep into Assembler... hmmm, you say !! YES !!
When trying to compile a basic example, i realized that wouldnt allow me to compile unless _XTAL_FREQ 4000000 is #defined.
Chip is PIC16F887 (
44-Pin Demo Board from Microchip, DM164120-2 ), compiler Hitech C Basic in MPLab IDE with a PickIt2 programmer ( i said it one breath ! You know what i mean with PICs being scary, right ?!

#define _XTAL_FREQ 4000000 


void main(void)

  PORTD=0x01;   //turn on LED at RD0. 
             PORTD=0x00;   //turn off LED at RD.
  PORTD=0x02;   //turn on LED at RD1.  
  PORTD=0x00;   //turn off LED at RD.
  PORTD=0x04;   //turn on LED at RD2. 

No comments:

Post a Comment

Feel free to contact me with any suggestions, doubts or requests.