199
C-Control Pro Mega Series
© 2008 Conrad Electronic
be entered into the measuring result. With a programmable prescaler the resolution of Timer_1 can
be set. Prescaler see
Example: Activate Pulse Width Measurement (Project PMeasurement) 434 µs (100 x 4,34 µs, see
)
word PM_Value;
void Timer1_ISR(void)
{
int irqcnt;
irqcnt=Irq_GetCount(INT_TIM1CAPT);
}
void main(void)
{
byte n;
// Define Interrupt Service Routine
Irq_SetVect(INT_TIM1CAPT,Timer1_ISR);
100
,PS0_64);
// Start Pulse Generator Timer 0
// Measurement starts here
// Output Timer0 OC0(PortB.3) connect to ICP(input capture pin, PortD.6)
PM_Value=0;
// Set mode to Pulse Width Measurement and determine prescaler
while(PM_Value==0);
// Measure Pulse Width or Period
Msg_WriteHex(PM_Value); //
Output Measuring Value
}
For reason of better survey only a simplified version is shown here. Because of a collision on Pin
B.4 Timer_0 is used for pulse generation with Mega128. The entire program can be found in directory
PW_Measurement.
6.19.6 Timer Functions
In C-Control Pro Mega 32 there are two, in Mega128 three independent Timer available. These are
Timer_0 with 8 bit and Timer_1 with 16 bit (Timer_3 with 16 bit for
Mega128 only
). The timer have a
programmable prescaler (see
. After the defined period the timer will trigger an interrupt. An
interrupt routine can then be used to execute specific actions.
Timer_T0Time (8 Bit)
Example: Timer0: Switch output on with a delay of 6,94 ms (100x 69,44 µs, see
)
Содержание C-Control Pro Mega Series
Страница 1: ... 2008 Conrad Electronic C Control Pro Mega Series ...
Страница 9: ...VIII Inhalt 2008 Conrad Electronic ...
Страница 10: ...Part 1 ...
Страница 17: ...Part 2 ...
Страница 23: ...Part 3 ...
Страница 41: ...32 Hardware 2008 Conrad Electronic 3 3 5 3 Component Parts Plan ...
Страница 57: ...48 Hardware 2008 Conrad Electronic 3 4 5 3 Component Parts Plan ...
Страница 58: ...Part 4 ...
Страница 91: ...82 IDE 2008 Conrad Electronic ...
Страница 92: ...Part 5 ...
Страница 135: ...126 Compiler 2008 Conrad Electronic 31 1F US 63 3F 95 5F _ 127 7F DEL ...
Страница 136: ...Part 6 ...
Страница 231: ...Part 7 ...
Страница 240: ......