differences in coding for blinking of LED in mikro c and mplabx

Thread Starter

peter65

Joined Dec 4, 2016
18
I must say a big thanks to u all (GURUS--spinnaker, Erniem, nsaspook and be80be) for ur help and orientation. now I can confidently program a pic16f877a to blink a LED using mplabx/xc8. Please can anyone recommend any textbook/PDF that I can use to learn supported embedded c syntax for mplabx/xc8/pic16f877a for beginners. I would really appreciate any help...thanks
 

Thread Starter

peter65

Joined Dec 4, 2016
18
Your TRIS registers are to select if the pin is going to be an input or output. If the pin can also be an analog input then you may need to take the additional step of making it digital.

You really should try to read the datasheet for your Pic.
trust me, i have read the datasheet of pic16f877A over and over again, I made sense out of somethings while somethings were elusive(and like junks) to me.
 

spinnaker

Joined Oct 29, 2009
7,830
, I made sense out of somethings while somethings were elusive(and like junks) to me.
Join the club. It takes a long time to understand everything. If it ever happens. Those chips have a lot of different features. You will learn how to use them as you need them. The important thing is that you know basically what is available.
 

Picbuster

Joined Dec 2, 2013
1,059
use timer interrupt @ interval.
Any timer will do I used the timer 1 for this example.
in the .H file

int cnt;
#define Led RB0 // or RA1 or what ever pin you want to use. make this pin output in TRIS
//------------- end of .H ---------------------
//in main set int's, clock, source and enable them


// in interrupt
if (TMR1IF)
{
TMR1IF=0; // Always running
Led = ! Led;
}

or insert a extra counter when needed (replace the Led = ! Led; )with;

cnt++;
if (cnt>xx)
{
cnt=0;
Led = ! Led;
}

Picbuster
 
Top