Download filezillafor windows
Playing a Tune. We now have the ability to play multiple notes using only a handful of compo-
nents, and with the PROTON+ compilers ability to store and handle data in the
form of CDATA or LDATA tables, we also have the possibility of holding the
data required for tunes. If your not musically gifted (which unfortunately, Im not) then there is the
small problem of writing the tunes to play. However, thanks to the internet
there are quite literally thousands of ready made tunes in the form of MIDI files
(.MID). However it must be noted that not all midi files can be converted to o-
tation data which is suitable for our project, but there should be enough to
keep you going for quite some time, you just have to find them. Ill take you briefly through converting a midi file later in the article, but for
now, take a look at the listing below. Its a program capable of playing a single
tune consisting of three channels, and it uses the circuit previously shown. See
if you can guess the tune? Because the program contains lots of data, only the main body of the code is shown here. The actual working program, along with the others, can be
downloaded from the PROTON+ Users Page. This program is named SIM- PLE_TUNE.BAS. ' Play a tune consisting of three channels
'
' Program with H4 set and use a 20MHz xtal to overclock the PICmicro to approx 55MHz
' Device= 18F452 ' Setup the fuses for X4 xtal frequency @CONFIG_REQ
@__CONFIG CONFIG1H, OSCS_OFF_1 & HSPLL_OSC_1
@__CONFIG CONFIG2L, BOR_ON_2 & BORV_20_2 & PWRT_ON_2
@__CONFIG CONFIG2H, WDT_OFF_2 & WDTPS_128_2
@__CONFIG CONFIG3H, CCP2MX_ON_3
@__CONFIG CONFIG4L, STVR_ON_4 & LVP_OFF_4 & DEBUG_OFF_4 XTAL= 40 ' Produce code for a 40MHz crystal ' Interrupt driven channel variables
DimNOTE_1_COUNTER asWordSYSTEM ' Determines when pin for channel 1 is toggled
DimNOTE_1 asWordSYSTEM ' Determines the pitch of the note DimNOTE_2_COUNTER asWordSYSTEM ' Determines when pin for channel 2 is toggled
DimNOTE_2 asWordSYSTEM ' Determines the pitch of the note DimNOTE_3_COUNTER asWordSYSTEM ' Determines when pin for channel 3 is toggled
DimNOTE_3 asWordSYSTEM ' Determines the pitch of the note ' Misc variables DimNOTE_STATUS asByte ' Used as Flags DimNOTE_1_TO_PLAY asNOTE_STATUS.0' 0 = Enable Chime, 1 = No Chime for channel 1
DimNOTE_2_TO_PLAY asNOTE_STATUS.1' 0 = Enable Chime, 1 = No Chime for channel 2
DimNOTE_3_TO_PLAY asNOTE_STATUS.2' 0 = Enable Chime, 1 = No Chime for channel 3
DimTICKS asWord ' Midi event counter DimNOTE_POINTER asWord ' Pointer for midi to frequency table DimCHANNEL_INFO asByte ' Used as Flags