Download filezillafor windows
'----[MAIN PROGRAM CODE]----------------------------------------------------------- MAIN_PROGRAM_LOOP:
InputTRIGGER ' Remove any loading to the capacitors NOTE_1_COUNTER = 0 ' \ NOTE_2_COUNTER = 0 ' Clear note counters for all channels NOTE_3_COUNTER = 0 ' / INTCON= %11000000 ' Enable global interrupts, TMR1 will trigger interrupts
T1CON= %00000001 ' Turn on Timer1, prescaler = 1:1 PIR1.0= 0 ' Clear TMR1 interrupt flag PIE1.0= 1 ' Enable TMR1 as peripheral interrupt source NOTE_1 = 179 ' Frequency value for channel 1 note NOTE_2 = 142 ' Frequency value for channel 2 note NOTE_3 = 119 ' Frequency value for channel 3 note HighTRIGGER ' Start charging the capacitors Delayms40 ' Allow time for the capacitors to charge InputTRIGGER ' Release the capacitors and let them discharge naturally Stop ' Stop when notes are played Most of the listing above remains the same as the previous program for produc-
ing a single chime, however, the notes are now produced from PORTA and trig-
gered by PORTB. Within the interrupt handler, there are three routines that
perform the same function but on different pins of PORTA. Each pin is toggled
when its respective counter (NOTE_n_COUNTER) reaches a predetermined
value (NOTE_n). The value dictates the pitch or frequency of the note played. The circuit for the above program is shown below and will be used for the rest
of the program listings. VDD RB2
RB1
RB0 MCLR OSC1 OSC2 VSS 32 PIC18F452 +5 Volts RA0 RA1 RA2 VSS 20MHz
Crystal 0V 2 1 35 34 33 31 12 14 13 1 VDD 11 R1
220W R3
220W R2
220W R4
120kW R6
120kW R5
120kW C5
2.2uF 10V C6
2.2uF 10V C7
2.2uF 10V C2
100nF C1
10uF 10V C3
15pF C4
15pF R7
100kW R8
120kW R9
150kW + - 6 4 5 3 2 LM386 VR1
100kW C8
100nF C9
100uF 10V Volume 3