Frequency Generation - Conrad C-Control Pro Mega Series Manual

Table of Contents

Advertisement

197
C-Control Pro Mega Series
With Mega128 for reasons of the hardware the use of Timer_0 as counter is not possible!
Timer1 (16 Bit)
// Example: Pulse Counting with CNT1
Timer_T1CNT();
pulse(n);
count=Timer_T1GetCNT();

6.19.2 Frequency Generation

To generate frequencies Timer_0, Timer_1 and Timer_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;
delval=200;
// Frequency: Period=138,9 µs*100=13,9 ms,Frequency=72Hz
Timer_T0FRQ(100,PS0_1024);
while (1)
{
AbsDelay(delval);
Timer_T0Stop();
AbsDelay(delval);
Timer_T0Start(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);
// generate n Pulses
// Variable for the On/Off Time
// Value Assignment for Variable delval
// Timer is set to Frequency
// Time Delay by 200ms
// Timer is stopped
// Time Delay by 200ms
// Timer will be switched on with
// Timer Prescaler PS0_1024.
© 2008 Conrad Electronic

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

C-control pro mega32C-control pro mega128

Table of Contents