alvieboy

Request for Comments: new PWM module for ZPUino/Papilio/Designlab

Recommended Posts

Although current ZPUino timers implement a very complex and capable PWM system, we are struggling a bit to integrate PWM and Timer support at same time in ZPUino code. It's rather hard to mix both in a sensible way, because timers can have been claimed for other modules, and PWM may not always be able to map the correct pin, or map the correct timer, and fixing this in software will end up with a bit mess of code and bugs.

 

So, after a quick chat with Jack a few days ago, we concluded that it would be better to have a separate PWM module from now on.

 

But we are not entirely sure of what you users may need/want from such a module. I have spent last couple of days thinking about this, and I have come to a preliminary design which I'd like you to comment on.

 

This design is based on my previous experience with a very PWM-capable generator - the Texas Instruments TMS320F series. I have borrowed some ideas from them, and my plan is roughly to have something like this (I have already implemented most of it, actually):

 

-- Overall Module view

  - 16-bit counter, 8-bit prescaler. Up to 4 PWM compare/output blocks.

  - Each output block has 2 outputs.

  - Sync-in/Sync-out support for cascading more modules (if for example different timebases are needed) and to keep them perfectly synchronized.

  - Interrupt support.

 

 

- Clocking block

  - 8-bit prescaler. Can divide the main clock by anything from 1 to 255.

  - Only meant to be programmed once. Subsequent programming may lead to glitches.

  - Per-module clock enable/disable.

 

- Counter block

  - Three modes: count-up, count-down, and count-up-down

  - 16-bit period, with shadow register configurable. Phase counter for sync-in.

 

- Compare block (up to 4 blocks per module)

  - 2 comparators (A and B) with 16-bit comparator.

  - Shadowing support

 

- Output module (up to 4 blocks per module)

  - 2 outputs.

  - Each output configurable to both A/B comparators, zero or overflow. Can either set, clear, toggle or no-op on output pin.

 

Comments ?

 

Alvie

Share this post


Link to post
Share on other sites

I really like the idea of patterning it after an existing chip, the main benefit being that there is already built in documentation...

 

Jack.

Share this post


Link to post
Share on other sites

Although TI documentation is far from the best out there :) Search for 'sprug04a'.

 

Anyway, the implementation will be similar, but not exactly the same. I don't want to do a clone, for obvious reasons.

 

Alvie

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now