-
Notifications
You must be signed in to change notification settings - Fork 345
Open
Description
If I understood correctly, playNote()
is supposed to create a square wave with a period of period
by toggling the SPEAKER_PORT
, and continues to output the wave for duration
.
If this is the case, shouldn't SPEAKER_PORT
be toggled twice after half the amount of time for period
has elapsed, as the period is the duration of a single cycle?
Thus instead of:
for (i = 0; i < period; i++) {
_delay_us(1);
}
SPEAKER_PORT ^= (1 << SPEAKER);
I would assume it should be something like:
for (i = 0; i < 2; i++) {
for (j = 0; j < period / 2; j++) {
_delay_us()
}
SPEAKER_PORT ^= (1 << SPEAKER);
}
Please let me know If I have misunderstood how this is supposed to work.
Otherwise, thank you for your outstanding book.
Metadata
Metadata
Assignees
Labels
No labels