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:
//************************************************
#include"pic.h"
main()
{
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
PORTB = 0xFF;
// 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
example.
10 . Press F12 to Run the program.
Here you can find the Proteus ISIS model and the source code
If you like this blog you can support us by many ways:
1. Leave comments stating your point of view about this article.
2. Buy our book on Amazon Learn By Making.
3. Click on links of our sponsors without adding any extra cost on you if you make purchase from them. Actually, many of these offers are totally free.
Amazon.com - Read eBooks using the FREE Kindle Reading App on Most Devices
Join Amazon Kindle Unlimited 30-Day Free Trial
Try Amazon Prime 30-Day Free Trial
Shop Amazon - Give the Gift of Amazon Prime
Try Audible and Get Two Free Audiobooks
Thank you for visiting our blog.
No comments:
Post a Comment