output a pwm signal

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

output a pwm signal

503 Views
100asong
Contributor I

I want to output a pwm signal on IOC4, But not using Mask 7 Compare function.

The result I test:

The frequency of IOC4 signal is the same as of IOC7(according to TC7), since that I set OC7M = 0x00;

How to implement the frequency of IOC4 according to TC4 not TC7?

Can I get it?

Labels (1)
0 Kudos
1 Reply

346 Views
kef
Specialist I

OCn+OC7 is hardware PWM solution. Once you set up PWM duty cycle and period, timer generates PWM waveform without any help from CPU side and software. From CPU you only change duty cycle setting when required. You can have up to 7 PWM channels from 8channels timer. Of course, period of all these PWM channels will be the same.

 

Yes, you can generate PWM using just OC4, but at the cost of 2x interrupt events per PWM period. Provided TCRE bit is clear, you set up timer to set TC4 pin high on channel4 output compare at TC4=TC4+pwmlo and wait for TC4 interrupt. When interrupt happens, you change set up to set TC4 pin low on output compare at TC4=TC4+pwnhi; and so on, updating TC4 every time you receive TC4 interrupt. As you may guess, this narrows your duty cycle settings, so that they can't be too close to 0 or too close to PWM period. So from all available PWM settings between 0 and period, 0-N and period-N settins won't work, where N is interrupt latency time expressed in PWM pulse width/period units.

0 Kudos