; --- Piano0.asm ---- ; This program toggles RC0 at 261 Hz (note C4) #include ; Variables CNT0 EQU 1 CNT1 EQU 2 ; Program org 0x800 call Init Loop: incf PORTC,F call Wait ; Play note C4 on RC0 goto Loop ; --- Subroutines --- Init: clrf TRISA ;PORTA is output clrf TRISB ;PORTB is output clrf TRISC ;PORTC is output clrf TRISD ;PORTD is output clrf TRISE ;PORTE is output movlw 15 movwf ADCON1 ;everyone is binary return ; Wait 1.916ms = 19,157 clocks Wait: movlw 19 movwf CNT1 W1: movlw 100 movwf CNT0 W0: nop nop nop nop nop nop nop decfsz CNT0, F goto W0 decfsz CNT1, F goto W1 return end