You may have noticed something peculiar with the fuse setting in the program.
The compiler is set up to produce code for a 40MHz crystal, but a 20MHz crys-
tal is actually used. And the fuse settings are for a x4 PLL, which will multiply
the  crystal’s  frequency  by  4.  Now  the  maximum  (official)  frequency  that  a
PICmicro can operate is 40MHz, and this arrangement is usually implemented
using a 10MHz crystal (10MHz * 4). See the PICmicro’ data sheet for more in-
formation concerning the x4 PLL fuse setting, or peruse the midrange reference
manual  for  the  16-bit  core  devices.  Both  of  these  are  downloadable,  free  of
charge, from Microchip’s web site at www.microchip.com.
You might think that using a 20MHz crystal with a x4 multiplier would allow
the  PICmicro  to  operate  at  80MHz.  However,  this  is  unachievable  on  the  cur-
rent breed of PICmicros and it actually settles at a frequency of approx 55MHz.
40MHz is the closest  crystal that is implemented by the compiler therefore all
delays will be somewhat wrong, which they are anyway because the interrupt
routine  is  taking  most  of  the  PICmicro’s  time.  This  high  speed  allows  higher
pitched  octaves  to  be  achieved,  thus  producing  a  more  pleasant  sound  to  the
tune. Not bad for 20MHz crystal ?
In tests, no PICmicro chosen failed to oscillate, and because the program is not
dependant on  its frequency, it really doesn’t matter if   he oscillator is out by a
few KHz or even a few MHz. We just need speed! Converting a Midi file to LDATA tables. Being able to play a tune is all well and good, but actually creating the tune to
play  is  most  of  the  fun  with  this  project.  As  mentioned  earlier,  tunes  can  be
downloaded in the form of .MID files (midi files) for playing on a PC soundcard.
However,  some  of  these  are  very  complex  compositions,  consisting  of  many
tracks  containing  many  instruments,  so  you  will  need  to  choose  the  midi  file
carefully. Piano or guitar tunes tend to be more suitable, and classical music is
very  good  for  conversion  because  they  usually  do  not  contain  a  drum  track
(which we cannot recreate). And of course, traditional Christmas tunes are also
more suitable.
Once you’ve chosen a midi file that you think may be suitable for conversion,
you will need a piece of software capable of viewing and editing the file. When
creating  the  project  I  used  a  shareware  program  named  MIDINOTATE.  A  30-
day fully working demo of this can be downloaded from  www.notation.com. SO
this is the program I will use to illustrate conversion.
If you’ve built the previous circuit, you will have guessed that the tune was “We
Wish You a Merry Christmas”, so we’ll take a look at how this tune was con-
verted.
The MERRY CHRISTMAS.MID file containing the tune can b e found along with the BASIC programs listed in the article at the PROTON Users Page.
Home | Previous Page | Next Page