PWM characteristics (by Ziggy)
I am using the PWM output with a duty cycle of 50 to drive an electromechanical buzzer.
In order to get the sound going i simply enable the PWM finction with an internal relay contact.
Sound comes on.
However when the relay contact is open the PWM module does not turn off.
In simulation mode the enable path is clearly deenergised, however the module still outputs a tone.
I then altered the approach to controlling the output by changing the dutycycle value for the PWM module.
Duty cycle value changes from 0 to 50 and indeed the tone comes on loudly and turns off.
But it does not turn off fully. There is still an artefact a very narrow pulse at the PWM frequency coming through.
Is a setting of 0 supposed to extinguish any output from the PWM module.
(no subject) (by Ihor Nehrutsa)
Fragment of LDmicro manual.txt
...
If the input condition to this instruction is true, then the duty cycle of the PWM peripheral is set to the value of the variable duty_cycle.
...
LDmicro use Fast PWM Mode. In this mode zero PWM duty not feasible.
"the output will be a narrow spike" in datasheet.
Fragment of ATmega8A [DATASHEET] at page 87
...
The extreme values for the OCR1x Register represents special cases when generating a PWM waveform output in
the fast PWM mode. If the OCR1x is set equal to BOTTOM (0x0000) the output will be a narrow spike for each
TOP+1 timer clock cycle. Setting the OCR1x equal to TOP will result in a constant high or low output (depending
on the polarity of the output set by the COM1x1:0 bits.)
...
The solution is to apply a new additional PWM_OFF element in LDmicto or use a Phase Correct PWM Mode.
(no subject) (by Ihor Nehrutsa)
to MGP
You are right, PIC has no this problem.