The Anonian
PIC24F Family, Specifically the PIC24FJ128GA106

The PIC24F family can output up to 9 Pulse-Width Modulated waveforms on any of the remappable pins (RPx). This is all fine and dandy… until you want more control.

The PIC’s provided Pulse-Width Modulation modules allow developers to set and maintain a desired frequency and duty cycle, without adding any extra burden to the processor’s main CPU. With the ability to use either the system clock or any of the built-in timers (which can actually be brought in externally) as a clock source, there are a large number of possible frequency ranges. For example, all of these and more are easily achievable:

While the PWM’s parameters can be changed to give varying frequencies and duty cycles, it is not a good solution when these variations become too frequent. The CPU would be given too heavy a burden, constantly having to adjust the waveform. Essentially, the PWM module is useless in this case.

Technically, this can be accomplished still using the provided PWM module. You would just be forced to constantly update the parameters. However, this would take a huge chunk out of your processing power and is likely to cause an undesirable delay. You could also use software to create your own Pulse-Width Modulation module to output a waveform, using interrupts and an output pin. This would work better and probably help with delays, but would also eat into your processing power.

So, what should you do?

SPI to the rescue!

The PIC24F family is freaking amazing. On top of everything else, these PICs provide 3 Serial Peripheral Interface modules, all of which can be assigned to any remappable pin (RPx). I will append this post tomorrow and add more of a tutorial and explanation of the benefits and limitations of using this method. I may even provide pictures of possible waveforms. Just know that it is possible and that you are not completely screwed if the PWM module turned out to not be the right solution.

 

Featured image from DigiKey.

Discover more from Hunter Schoonover

Subscribe now to keep reading and get access to the full archive.

Continue reading