Low PWM frequency.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Low PWM frequency.

2,758 Views
prog_ram
Contributor III
Hi,
I want to generate a low PWM frequency signal,
I read the AN2612.pdf document, but it's good just for certain low frequency, but not as low as 0.1Hz!!
 
does anybody have an idea how to do that?
 
thanks..
 
 
Labels (1)
0 Kudos
Reply
6 Replies

901 Views
bigmac
Specialist III
Hello,
 
With a PWM frequency as low as 0.1 Hz, you hardly need to use the PWM module hardware - you could simply "bit-bang" the PWM waveform.
 
You don't mention the resolution you need to achieve - but a possibility is to generate a timer interrupt for each incremental period of the PWM signal.  Within the ISR, a counter would be incremented, and then tested to determine whether a change of output state was needed.  For example, if you require 8-bit resolution, the timer interrupt period required would be 39 milliseconds.
 
Regards,
Mac
 
0 Kudos
Reply

901 Views
prog_ram
Contributor III
Hello,
thanks to the reply,
actually I don't know what "bit-bang" the PWM  means!!
so, can you please give me an idea how to do that..
 
thank you again..
 
 
0 Kudos
Reply

901 Views
bigmac
Specialist III
Hello,
 
What I meant was to use a GP output for your PWM signal.  Then, within the periodic timer ISR you could increment a counter variable, and test the new value -
 
If the new value is equal to the required pulse width, clear the output.
If the new value is equal to the "terminal count" value, set the output and clear the counter value.
 
The total PWM period would be (timer interrupt period * terminal count).
 
Regards,
Mac
 
0 Kudos
Reply

901 Views
prog_ram
Contributor III
I got you thanks BigMac,
what I am doing now is using the output compare to generate the PWM, this is described in one of the Freescale App. Notes.
it's working so far, but I wonder whether the method you described is better than Output compare one?
 
thanks again
0 Kudos
Reply

901 Views
bigmac
Specialist III
Hello,
 
I might have considered that the direct use of timer output compare would not have been suitable for a 10 second PWM period, since the timer overflow period would need to be 10 seconds minimum.  Can you actually achieve this?
 
With the method that I suggested, the timer output compare could be used to generate a periodic interrupt in the region of milliseconds to tens of milliseconds.  A multiple of this period represents the PWM period.  The suitability of the method will depend, to a large extent, on the resolution you need to achieve - probably an upper limit of 12 bits.  This would require a timer interrupt period of 10000/4096 ~= 2.5 ms.
 
Regards,
Mac
 
0 Kudos
Reply

900 Views
prog_ram
Contributor III
Acutally yes we can do so by dealing with the overflow of the timer counter.
I implemented the idea you suggested and it worked very good, however, there will be restriction on the resolutions (as you said), and increasing it will generate more interrupts which is not good as I am using almost all the communications availble in HCS12 (IIC, SPI, SCI and CAN in future) don't you think so?
 
thank you..
 
 
0 Kudos
Reply