Instructions
391 C-Control Pro IDE
© 2013 Conrad Electronic
During operation the period (frequency), duty (latitude) and deadtime of the PWM signal can be
specified.
For the frequency, the following formula applies: Frq = 66,000,000 / prescaler / period. Permitted
values for duty are 0 to period. A duty of 0 means that the signal is permanently off, wherein a duty
of value period means the signal is permanently on. Therefore a duty of 50% is period / 2. Thus the
width (duty) of the PWM signal can be set as finely as possible, a prescaler must be selected so
that the period parameter for the desired frequency is as large as possible (maximum 20 bits).
Parameter
chan number of PWM channel (0 - 3)
period frequency of the PWM signal (20 Bit)
duty duty of the PWM signal (20 Bit)
dtl deadtime of PWML_x signal
dth deadtime of PWMH_x signal
5.26.2.7 Timer_ConfigCounter
Timer Functions
Syntax
void Timer_ConfigCounter(byte timer, byte portbit, byte edge, word irq_-
threshold);
Sub Timer_ConfigCounter(timer As Byte, portbit As Byte, edge As Byte,
irq_threshold As Word)
Description
The function initializes a timer as a counter. The inputs COUNTA-0, COUNTA-1, COUNTA-2 and
COUNTB-2 are available (see Pin Assignment). For the x-COUNTA inputs only the timer 0,2,4 can
be used, for COUNTB-2 the timer 1,3,5 are available. If the parameter irq_threshold is non-zero, then
an interrupt is generated when the counter is equal to the value of irq_threshold. After an interrupt,
the counter is reset to zero.
After initialization, the counter retains its old value. The first edge then sets the counter to zero.
When reading the counter, it therefore looks as if one edge less has been counted. This behavior is
due to the structure of the internal counter of the AVR32 controller.
Parameter
timer number of timer (0 - 5)
portbit (GPIO in Pin Assignment )
edge edge type: CNT_FALLING (falling) or CNT_RISING (rising)
irq_threshold counter when an IRQ will be triggered