Counters - Timers C++ - NEED HELP

Discussion in 'Programmer's Corner' started by blank, May 18, 2008.

  1. blank

    Thread Starter Member

    Apr 26, 2008
    13
    0
    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 (;[​IMG]
    {
    // 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.
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Code cleanup for readability using the CODE tags.

    The labels CS10 and CS11 are defined in the .h header file for the AVR device you are using. The header file must not be located in the folder in which the compiler is looking.

    What AVR device are you using in your project?

    hgmjr
     
  3. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    As a point of reference, I cut and pasted your code into my AVRSTUDIO/WINAVR application and it compiled without any errors.

    That confirms my suspicion that your problem is a directory or path specification problem.

    hgmjr
     
Loading...