Chapter 8: C Pointers and Arrays
tion = 0;
Duration = (DURATION_SEED/pgm_read_word(pSong+Tone));
Duration <<= 1;// compensate for using 2 MHz clock
Tone++; // point to the next tone in the Song-table
e
if((pgm_read_word(pSong+Tone) == p)|
e) == P))
8 bits to the right
/ reset TCNT1H/L
ICR1H = temp_hi; // load ICR1H/L
ICR1L = pgm_read_word(pSong + Tone);
ICR1L <<= 1; // compensate for using 2 MHz clock
Tone++; // point to the next tone in the Song-table
if(!Tone)
{
Dura
Tempo = (uint8_t)pgm_read_word(pSong + 0);
Tempo <<= 1; // compensate for using 2 MHz clock
Tone = 1; //Start the song from the beginning
}
if(!Tempo)
{
if(Duration) // Check if the length of the tone has "expired"
{
Duration--;
}
else if(pgm_read_word(pSong + Tone))// If not the song end
{
// store the duration
// if paus
(pgm_read_word(pSong+Ton
cbi(TCCR1B, CS10); // stop Timer1, prescaler(1)
else
sbi(TCCR1B, CS10); // start Timer1, prescaler(1)
cli();
// read out the PWM-value
temp_hi = pgm_read_word(pSong + Tone);
temp_hi >>= 7; // move integer
TCNT1H = 0; /
TCNT1L = 0;
sei();