Chapter 8: C Pointers and Arrays
Music
to pillage the Butterfly code again and play some tunes to further
trate the use of pointers and arrays.
ngs are
,
t songs in flash
song variable. All nice
uite as C-like in the way it
port of
chnical
e. But I won’t mention free. Especially not
is is a miraculous little free compiler (send them
eforge.net/donate.)
e port of the Butterfly code from not-free IAR compiler to the free WinAVR
[email protected]
d an outstanding job. When you finally learn enough to really evaluate the
utterfly code, you will come to appreciate the intelligence and hard work that
es, you. And for free. So when you
ple appearing song selection statement,
out
Music to my ears. “Play it again Sam.”...................................................
We are going
illus
More on pointers to arrays
In the original Butterfly code written with the IAR compiler, in sound.c, so
selected using these definitions:
flash int flash Songs[] = { FurElise, Mozart, /Minuet
AuldLangSyne,*/ Sirene1, Sirene2, Whistle, 0};
int __flash *pSong; // pointer to the differen
The __flash is not C, it is a special IAR modifier that allows access to Flash ROM
as if it was regular C style RAM. In use:
pSong = Songs[song]; // point to this song
Loads pSong with the pointer to the tune indicated by the
and C like. Unfortunately, the WinAVR compiler isn’t q
allows access to Flash ROM. Not that I’m criticizing, I think the WinAVR
the gcc tools to the AVR platform is a miracle of dedication and te
prowess, not to mention: fre
repeatedly: free, free, free. So th
some money at: http://www.sourc
Th
was done by:
Martin Thomas, Kaiserslautern, Germany
http://www.siwawi.arubi.uni-kl.de/avr_projects/
who di
B
this gentleman (my assumption) did for you. Y
see the way he translated the relatively sim
you can agree with his comment below: ‘// looks too complicated’, with
getting fussy about it.