rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
Can't make pulse with timer0 pic12f508 [Solved] |
Posted: Wed May 23, 2018 9:33 am |
|
|
Hi, I am trying to toggle led using the only timer that this micro has: timer0.
Here is the code:
Code: |
#include <12F508.H>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
void main() {
setup_timer_0(T0_INTERNAL|T0_DIV_128);
set_timer0(0);
while(1) {
if(get_timer0() > 254) {
output_toggle(PIN_B5);
set_timer0(0);
}
}
}
|
On the output pinB5 I have attached LED. I see that the led is blinking asynchronously. I have a scope to but no need to scope it. It is obvious that there is no pulse with duty 50% as I expect. _________________ A person who never made a mistake never tried anything new. |
|