Let ‘s speed up the rate !!


Now that we learned to flash an LED using the PIC 16F84, we ‘ll increase the rate of information flow.

We ‘ll write the same program using C language. This will be very easy as it is a popular language and it also a high-level language. Most of us used it for computer programming.

That ‘s the flasher program:





unsigned char i;

TRISB = 0 ; // Make PORTB output

PORTB = 0 ; // Initialize PORTB

for(;;) // This is the infinite loop that keeps the PIC running


PORTB = 0x00;

// turn all LEDS off

for(i = 100 ; –i ;);

// Delay


// turn all LEDS on

for(i = 100 ; –i ;);

// Delay




I guess the program is self explaining.

Now again, we ‘ll try it in Proteus to see it working.

Here are the steps to add the C source code file and compile it.

1. Copy and paste the previous code into a file named flasher.c .

2. Install the program HiTec PIC C .

3. In ISIS 7 , open the flasher.DSN model you used before.

4. On the Source menu , choose Define Code Generation Tools.

5. Press New.

6. Brows to the folder of HiTec PIC C and to Bin folder , choose picl.exe.

7. To add the source , choose Source –> Add/Remove Source files , press New to add

flasher.c choose PICC from the drop-down menu under Code Generation Tool , and on the

Flags text box , type –chip=16f84a to choose the microcontroller type.

8. Now press Source –> Build All.

9. Now choose the oscillator speed and the flasher.HEX file as you did in the Assembly


10 . Press F12 to Run the program.

Here you can find the Proteus ISIS model and the source code

Be the first to comment

Leave a Reply

Your email address will not be published.