Hi,
I've been tryin to understand from a coding standpoint how to write a software pwm. I understand what Pwm is and how it works, I think.. So, what I am trying to do understand the the external clock vs internal clock and the Timers etc.. So, if I have a 4mhz clock, my internal frequency would be 1Mhz ? If I set the prescaler, would that apply to just the timer?
If I set the prescaler to say 1:16 @ 1mhz clock, then my frequency would be 244hz?
Im just trying to figure out the frequency so I can base the duty cyle on the amount of time in each per step.. 1% 5% 10% and so on.. and essentially create a lookup table..
In other words, a main loop that uses the TMR0 with interupt overflow to slow the speed of each transition so it doesn't get bright super fast. I was going to use a lookup table to supply values based on the clock cycle to reach a certain level in the duty cycle. The ultimate goal being to flip a switch and it slowly fade in or slowly fade out.
I know Hardware pwm is much easier, but like I said, I want to try it in software first.
I've been tryin to understand from a coding standpoint how to write a software pwm. I understand what Pwm is and how it works, I think.. So, what I am trying to do understand the the external clock vs internal clock and the Timers etc.. So, if I have a 4mhz clock, my internal frequency would be 1Mhz ? If I set the prescaler, would that apply to just the timer?
If I set the prescaler to say 1:16 @ 1mhz clock, then my frequency would be 244hz?
Im just trying to figure out the frequency so I can base the duty cyle on the amount of time in each per step.. 1% 5% 10% and so on.. and essentially create a lookup table..
In other words, a main loop that uses the TMR0 with interupt overflow to slow the speed of each transition so it doesn't get bright super fast. I was going to use a lookup table to supply values based on the clock cycle to reach a certain level in the duty cycle. The ultimate goal being to flip a switch and it slowly fade in or slowly fade out.
I know Hardware pwm is much easier, but like I said, I want to try it in software first.