Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Software PWM Vs Hardware PWM?

Status
Not open for further replies.

PICMICRO

New Member
What is it that I can't achieve through software PWM that Hardware PWM can provide?
Except for the processor time, which I have enough.
 
The most importent thing is the number of PWM channels.
With software PWM theoretical every output Pin can be used as PWM Channel.
Hardware PWM's are restricted by the included PWM Generators.

At AVR Controllers Hardware PWM Channels appends from Timers.
Every ( sometimes 2 ) PWM Channel afford's one Timer.
With software PWM one Timer is enough for all PWM Outputs with the same PWM Frequency.

Many Controller only have 1 or 2, 16Bit PWM sources.
With Software PWM all Outputs are possible with 16 Bit Resolution by using a 16 Bit Timer.

The mischief of software PWM ist the controller load.
The Controller must set and clear every Output at different, sometimes at same Time, while a PWM cycle.

So there are only quite low PWM Frequencies possible - But I think you know that.
 
What is it that I can't achieve through software PWM that Hardware PWM can provide?
Except for the processor time, which I have enough.

- You won't achieve as high frequencies with software PWM compared to hardware PWM.
- Software PWM can also be very difficult to implement if your application needs accurate timing of PWM updates (like dead-time insertion in half-bridge control).
- And of course you will "waste" a lot of processor time with software PWM compared to hardware PWM.
 
Last edited:
With software PWM you can select which i/o pins do the PWM which is useful if you are laying out a dense PCB or need to allocate entire 8 bit ports for other duties.

I recently used s'ware PWM up to 100Hz via a 1 millisec interrupt. About 30 ASM instructions @ a 2MHz inst. clock costs 15 usec per 1000 usec or 1.5% of processor time.
S'ware PWM also allowed me to easily invert the PWM outputs depending on the application of the actuators or whether I used Sinking or sourcing load drivers.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top