Timer; Event Counter - Conrad C-Control Pro Mega Series Manual

Table of Contents

Advertisement

{
Msg_WriteText(str2); Thread_Delay(200);
}
}
char str1[12],str2[12];
//------------------------------------------------------------------------------
// main program
//
void main(void)
{
str1="Thread1";
str2="Thread2";
Thread_Start(1,thread1);
while(true)
{
Thread_Delay(100); Msg_WriteText(str1);
}
}
6.19

Timer

In C-Control Pro Mega 32 there are two, in Mega128 are three independent timers available. These
are Timer_0 with 8 bit and Timer_1 with 16 bit (Timer_3 with 16 bit for Mega128 only). Timer_2 is
used by the firmware as an internal time base and is set firm to a 10ms interrupt. These internal
timers can be utilized for a multitude of tasks:

Event Counter

·
·
Frequency Generation
·
Pulse Width Modulation
Timer Functions
·
·
Pulse & Period Measurement
Frequency Measurement
·
6.19.1 Event Counter
Here are two examples for how a Timer can be used for an Event Counter:
Timer0 (8 Bit)
// Example: Pulse Counting with CNT0
Timer_T0CNT();
pulse(n);
count=Timer_T0GetCNT();
© 2008 Conrad Electronic
// generate n Pulses
Libraries
// "Thread2" is displayed
// after that the thread
// sleeps for 200ms
// global variable declaration
// variable declaration
// variable declaration
// start new thread
// endless loop
// the thread sleeps for 100ms
// after that "Thread1" is displayed
196

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