I am trying to emulate a remote control using a S08PT60, connected to a switching transistor and an IR LED. However, my algorithm is not working. I have sliced the code into 500us slices, because all "on" and "off" times are multiples of 500us. Then I have a boolean vector which indicates whether the LED should be oscillating or not during that 500us period. The microcontroller enters a periodic interrupt every 500us to enable or disable the PWM oscillator, which controls the transistor.
Using an IR receiver, I have confirmed that the oscillator is being switched on and off. However, all timing seems to be wrong. Times are bigger than they should be.
Does anybody have a hint on how I can switch the PWM oscillator with correct timing?
Thanks in advance.