[ create a new paste ] login | about

Link: http://codepad.org/Pi8Vq5WD    [ raw code | output | fork ]

C, pasted on Oct 31:
uint16_t minute_time;
#define TICKS_IN_MINUTE ... // compute it...
uint16_t beat_count;
uint16_t beat_ticks;
uint16_t beat_position;
uint16_t beat_time;

main ()
{
	// init timer here, set constant prescaler ...
	// leave it running in normal mode (no CTC)
	
	beat_count = 100; // 100 beats per minute
        beat_ticks = TICKS_IN_MINUTE / beat_count;
        beat_position = 0;
	
        minute_time = TCNT1 + 100; // add a small amount so we catch it
        beat_time = minute_time;
	OCR1A = beat_time;
}

ISR(TIMER1_COMPA_vect) { // something like that
        beat_position++;
        if (beat_position == beat_count) {
            beat_position = 0;
            minute_time += TICKS_IN_MINUTE;
            beat_time = minute_time;
        } else {
            beat_time += beat_ticks;
        }
	OCR1A = beat_time;
}


Output:
Line 1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'minute_time'
Line 3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'beat_count'
Line 4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'beat_ticks'
Line 5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'beat_position'
Line 6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'beat_time'
In function 'main':
Line 13: error: 'beat_count' undeclared (first use in this function)
Line 13: error: (Each undeclared identifier is reported only once
Line 13: error: for each function it appears in.)
Line 14: error: 'beat_ticks' undeclared (first use in this function)
Line 14: error: expected expression before '...' token
Line 15: error: 'beat_position' undeclared (first use in this function)
Line 17: error: 'minute_time' undeclared (first use in this function)
Line 17: error: 'TCNT1' undeclared (first use in this function)
Line 18: error: 'beat_time' undeclared (first use in this function)
Line 19: error: 'OCR1A' undeclared (first use in this function)
In function 'ISR':
Line 23: error: 'beat_position' undeclared (first use in this function)
Line 24: error: 'beat_count' undeclared (first use in this function)
Line 26: error: 'minute_time' undeclared (first use in this function)
Line 26: error: expected expression before '...' token
Line 27: error: 'beat_time' undeclared (first use in this function)
Line 29: error: 'beat_ticks' undeclared (first use in this function)
Line 31: error: 'OCR1A' undeclared (first use in this function)


Create a new paste based on this one


Comments: