I try to program STK500 microcontroller and have a timer in my program.
I have the following program:
#include <avr/io.h>
int main (void)
{
unsigned char ElapsedSeconds = 0; // Make a new counter variable and initialize to zero
DDRB |= (1 << 0); // Set LED as output
TCCR1B |= ((1 << CS10) | (1 << CS11)); // Set up timer at Fcpu/64
for (;
{
// Check timer value in if statement, true when count matches 1 second
if (TCNT1 >= 15625)
{
TCNT1 = 0; // Reset timer value
ElapsedSeconds++;
if (ElapsedSeconds == 60) // Check if one minute has elapsed
{
ElapsedSeconds = 0; // Reset counter variable
PORTB ^= (1 << 0); // Toggle the LED
}
}
}
}
Is there an other way to write the command
TCCR1B |= ((1 << CS10) | (1 << CS11));
because when I compile it it shows an error that CS10 and CS11 are undefined.
I have the following program:
#include <avr/io.h>
int main (void)
{
unsigned char ElapsedSeconds = 0; // Make a new counter variable and initialize to zero
DDRB |= (1 << 0); // Set LED as output
TCCR1B |= ((1 << CS10) | (1 << CS11)); // Set up timer at Fcpu/64
for (;
{
// Check timer value in if statement, true when count matches 1 second
if (TCNT1 >= 15625)
{
TCNT1 = 0; // Reset timer value
ElapsedSeconds++;
if (ElapsedSeconds == 60) // Check if one minute has elapsed
{
ElapsedSeconds = 0; // Reset counter variable
PORTB ^= (1 << 0); // Toggle the LED
}
}
}
}
Is there an other way to write the command
TCCR1B |= ((1 << CS10) | (1 << CS11));
because when I compile it it shows an error that CS10 and CS11 are undefined.