Closed techildllc closed 4 years ago
@Irev-Dev any insight would be greatly appreciated. Thanks!
It seems reasonably likely, it might be as simple as changing 1 to 2 for all of the registers in the code, but the way to check properly is to look at the docs between the registers for 1 and 2 and see if they match up and if there's anything that needs to be tweaked. I've done a reasonable job of commenting on what the bit pattern is doing for each register.
Datasheet here: http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf
let me know how you go.
Unfortunately Timer2 does not have a corresponding ICR2. Any idea how to achieve the same results?
@techildllc Sorry mate I'm not sure. That register is used to set the switching frequency of the pwm, if you are able to still get the interrupt service routine to fire when timer 2 overflows, you might still be able to get something working. Though you won't be able to adjust the switching frequency. Mind you I believe there is scaling values available for some of the timers, so you might be able to do some crude adjusting of the frequency. But this is just me thinking out loud.
Is it possible to implement the sPWM with generated lookup table using Timer2 instead of Timer1? I know that only Timer1 has an ICR to define the period. Not sure how you would go about doing it with Timer2.