Only a single simultaneous PWM value possible?

fernando_g

Senior Member
I've noticed that if I setup a PWM value on a port, for instance C1:

pwmout pwmdiv4, C.1, 199, 600

and immediately afterwards I follow with another command in a different port, same frequency but different % like so:

pwmout pwmdiv4, C.2, 199, 550

Then, both ports assume the last PWM value.

This tells me that there is a single timer available, and its output is only assigned to different ports.
Am I correct?

I tested this assumption on a 28X2 (5 volt version)
 

hippy

Technical Support
Staff member
There is a single timer shared for C.1 and C.2 on the 28X2 but it should be possible to have two distinct duty cycles on each.

There is a hardware issue that PWMOUT resets all active PWMOUT to PWMDIV1 on the 28X2 and 40X2 which may be what you are seeing. This is referenced in the online PWMOUT command reference -

http://www.picaxe.com/BASIC-Commands/Digital-InputOutput/pwmout/

and detailed in the following post along with a solution for that -

http://www.picaxeforum.co.uk/showthread.php?21867-Using-PWMDIV-options-with-the-PICAXE-28X2-and-40X2

There is a query at the end of that thread relating to C.1 and C.2 use. I am not sure what the follow-up to that would be off-hand.

What firmware version is your 28X2 ? That will help us identify if it is a bug or otherwise, what solution should be most appropriate.
 

fernando_g

Senior Member
Thanks hippy, for your reply.

Indeed, I was using C.1 and C.2 as the PWM outputs, which as your thread mentions, share a common timer.

I was only curious about it, as I had observed it a while back and puzzled me, but had forgotten to ask about it.
 
Top