Instructions

363 C-Control Pro IDE
© 2013 Conrad Electronic
// Example: Pulse Counting with CNT1
Timer_T1CNT();
pulse(n); // generate n Pulses
count=Timer_T1GetCNT();
5.26.1.2 Frequency Generation
To generate frequencies
Tim er_0, Tim er_1
and
Tim er_3
can be utilized as follows:
Timer0 (8 Bit)
1. Example:
// Square Wave Signal with 10*1,085 µs = 10,85 µs Period Duration
Timer_T0FRQ(10, PS0_8)
2. Example: Pulsed Frequency Blocks (Project FRQ0)
void main(void)
{
int delval; // Variable for the On/Off Time
delval=200; // Value Assignment for Variable delval
// Frequency: Period=138,9 µs*100=13,9 ms,Frequency=72Hz
Timer_T0FRQ(100,PS0_1024); // Timer is set to Frequency
while (1)
{
AbsDelay(delval); // Time Delay by 200ms
Timer_T0Stop(); // Timer is stopped
AbsDelay(delval); // Time Delay by 200ms
Timer_T0Start(PS0_1024); // Timer will be switched on with
// Timer Prescaler PS0_1024.
}
}
The program will on Mega128 not work in USB mode since output PB4 is in conjunction with the USB
interface used on the Application Board.
Timer1 (16 Bit)
Example: Frequency Generation with 125 * 4,34 µs = 1085µs Period
Timer_T1FRQ(125,PS_64);
Timer3 (16 Bit) (only Mega128)
Example: Frequency Generation with 10*1,085 µs =10,85 µs Period and 2*1,08s =2,17 µs Phase Shift