Please help me. I am totally confusing with this timer and calculations. I was read a lot of examples. many examples said different calculation for generating pulses.
What is the purpose of timer?
Where it should be used?
How to calculate ?
please explain rtcc,internal rtcc, extra.
What is the synatx for enable and use the timer ?
I am using proteus for simulation. Also 877 is in real time. _________________ Thanks and Regards
Sureshkumar.
The purpose of timer is as it can be understood from it's name "timing".
Simply with an example, let's say you wanna generate a PWM signal with 1.5ms HIGH cycle and 18.5 LOW cycle in total 20ms which is 50hz.
To do that you need a timer so you can turn state off if 1.5ms passed and turn state on if 18.5ms pass.
It is easy to do that with delay function without using timers:
Code:
output_high(pin_a0);
delay_us(1500); // which is equivalent of 1.5ms MCU waits till 1.5ms passes and do nothing, does not respond to any interrupt
output_low(pin_a0);
delay_us(18500); // which is equivalent of 18.5ms MCU waits till 1.5ms passes and do nothing does not respond to any interrupt
When you do like above by using delays you actually freeze the MCU, if MCU freezes it does not do anything till the stated time value passes. This is not good because an interrupt can occur that freeze time and mcu can't respond it which we can also call this interval dead time.
Instead of freezing the MCU we use timers. You can imagine timer as a chronometer ticking at background and do your timing stuff and let you know about your time stuff according to your way of modifying it.
So the code at above turns into something like this below:
Code:
output_high(pin_a0);
*let me know if 1500us passes and do what ever you do now you are doing and accept any interrupt and proceed through it *
if(*ok 1500us passed*){
output_low(pin_a0);
}
*let me know if 18500us passes and do what ever you do now you are doing accept any interrupt and proceed through it*
if(*ok 18500us passed*){
output_low(pin_a0);
}
_________________ Hardware-Software Developer
Physics Engineer
Ceo airVision Aerial Video and Photography
Ceo Massive Robotics
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum