[an error occurred while processing this directive]
|
//....
#define TC_CLEARBYCOMPARE 0x08
#define TC1_PRESCALER_0 0x00
#define TC1_PRESCALER_1 0x01
#define TC1_PRESCALER_8 0x02
#define TC1_PRESCALER_64 0x03
#define TC1_PRESCALER_256 0x04
#define TC1_PRESCALER_1024 0x05
#define TC1_Stop(); TCCR1B =TC1_PRESCALER_0+TC_CLEARBYCOMPARE;
#define TC1_Start(); TCCR1B =TC1_PRESCALER_1024+TC_CLEARBYCOMPARE;
// defdefOCR1A = F_ck/TC_PRESCALER/Ft1 + delta
// Fsck= 1000000 Hz
// Ft1 = 2 Hz
// defdefOCR1A = 1000000./1024./2.-1 =0x017e
#define defOCR1AH 0x01
#define defOCR1AL 0x7e
interrupt [TIMER1_COMPA_vect] void INT_TIMER1()
{
TOGLEBIT(PORTE,2);
}
//....
void C_task main()
{
//....
_CLI(); // Disable interrupts
TC1_Stop();
// TIMSK:Timer/Counter Interrupt MaSK register
// bit 4:OCE1A = 1;
TIMSK = 0x10;
// TC1 Load Compare Register
OCR1AH = defOCR1AH;
OCR1AL = defOCR1AL;
// Configuration direction PORTE
PORTE = 0xff;
DDRE = 0xff;
//...
_SEI(); // Enable interrupts
TC1_Start();
while(1){;}
}