resources/libtiny/Servo.cpp
//=============================================================================
// FUNCTION:    void setupTimerPrescaler()
//
// DESCRIPTION: Helper function that sets up the timer prescaller based on what
//              timer is selected and the F_CPU frequence.
//
// INPUT:       Nothing
//
// RETURNS:     Nothing
//
//=============================================================================
void setupTimerPrescaler()
DESCRIPTION: Helper function that sets up the timer prescaller based on what
timer is selected and the F_CPU frequence.

Nothing

Nothing
void setupTimerPrescaler () DESCRIPTION : Helper function that sets up the timer prescaller based on what timer is selected and the F_CPU frequence . Nothing Nothing
void ServoSequencer::setupTimerPrescaler()
{
    #ifdef PLLTIMER1
        #error "PLL Timer source not compatible with Servo, turn it off."
    #endif
    #ifdef LOWPLLTIMER1
        #error "PLL Timer source not compatible with Servo, turn it off."
    #endif
  #if defined(__AVR_ATtinyX5__)
    TCCR1 = 0;
    #if F_CPU == 8000000L
        TCCR1=7;
    #elif F_CPU == 16000000L 
        TCCR1=8;
    #elif F_CPU == 1000000L
        TCCR1=4;
    #else
        #error "Servo only supported at 1MHz, 8MHz and 16MHz on tiny25/45/85. "
    #endif
  #elif defined(__AVR_ATtinyX61__)
    TCCR1B = 0;
    #if F_CPU == 8000000L
        TCCR1B=7;
    #elif F_CPU == 16000000L 
        TCCR1B=8;
    #elif F_CPU == 1000000L
        TCCR1B=4;
    #else
        #error "Servo only supported at 1MHz, 8MHz and 16MHz on tiny261/461/861. "
    #endif
  #endif
}
void ServoSequencer :: setupTimerPrescaler ( ) { #ifdef PLLTIMER1 #error  "PLL Timer source not compatible with Servo, turn it off." #endif #ifdef LOWPLLTIMER1 #error  "PLL Timer source not compatible with Servo, turn it off." #endif #if defined ( __AVR_ATtinyX5__ ) TCCR1 = 0 ; #if F_CPU == 8000000L TCCR1 = 7 ; #elif F_CPU == 16000000L TCCR1 = 8 ; #elif F_CPU == 1000000L TCCR1 = 4 ; #else #error  "Servo only supported at 1MHz, 8MHz and 16MHz on tiny25/45/85. " #endif #elif defined ( __AVR_ATtinyX61__ ) TCCR1B = 0 ; #if F_CPU == 8000000L TCCR1B = 7 ; #elif F_CPU == 16000000L TCCR1B = 8 ; #elif F_CPU == 1000000L TCCR1B = 4 ; #else #error  "Servo only supported at 1MHz, 8MHz and 16MHz on tiny261/461/861. " #endif #endif }
FUNCTION:    void setupTimerPrescaler()
DESCRIPTION: Helper function that sets up the timer prescaller based on what
timer is selected and the F_CPU frequence.
FUNCTION : void setupTimerPrescaler () DESCRIPTION : Helper function that sets up the timer prescaller based on what timer is selected and the F_CPU frequence .
//reset the Timer Counter Control Register to its reset value //set counter1 prescaler to 64 //our F_CPU is 8mhz so this makes each timer tick be 8 microseconds long //TCCR1 &= ~(1<< CS13); //clear //TCCR1 |=  (1<< CS12); //set //TCCR1 |=  (1<< CS11); //set //TCCR1 |=  (1<< CS10); //set //16MHz //TCCR1|=(1<<CS13) //set counter1 prescaler to 8 //our F_CPU is 1mhz so this makes each timer tick be 8 microseconds long //TCCR1 &= ~(1<< CS13); //clear //TCCR1 |=  (1<< CS12); //set //TCCR1 &= ~(1<< CS11); //clear //TCCR1 &= ~(1<< CS10); //clear //set counter1 prescaler to 64 //our F_CPU is 8mhz so this makes each timer tick be 8 microseconds long //TCCR1 &= ~(1<< CS13); //clear //TCCR1 |=  (1<< CS12); //set //TCCR1 |=  (1<< CS11); //set //TCCR1 |=  (1<< CS10); //set //16MHz //TCCR1|=(1<<CS13) //set counter1 prescaler to 8 //our F_CPU is 1mhz so this makes each timer tick be 8 microseconds long //TCCR1 &= ~(1<< CS13); //clear //TCCR1 |=  (1<< CS12); //set //TCCR1 &= ~(1<< CS11); //clear //TCCR1 &= ~(1<< CS10); //clear