I discovered an interest in MCUing a couple weeks ago, and with the help of others on this site and hours of google searches, I think I know some basic stuff now. I wanted to see if I could make a square wave keyboard. Here's the code, if people could help me with my code to make it, well good, that would be much appreciated, please note, anything in asterisks are troubled areas and I realize time hasn't been set to values as I do not know the method by which I will delay:
;Author Jake Wood
;Project Square Wave Keyboard
;Date 9 11 08
device PIC16F882
*What other info do I need up here, and what is the syntax to set the Hz of the built in 31kHz-8Mhz oscillator?*
origin 0
clrf PORTA *I would be surprised if this syntax were right
clrf PORTB
clrf PORTC
bsf STATUS, RP0; to bank 1
movlw b'11111111' ;sets 255 to W
movfw TRISA ;all RA set to input
movfw TRISB ;all RB set to input
movlw b'11111110' ;sets 255 to W
movfw TRISC ;RC0-6 set to input RC7 to out
bcf STATUS, RP0 ;back to bank 0
int time
buttons:
movlw 0
movfw RC7 ;turn RC7 off
While(1){
If(RA0==1){ ;waits for button to be pressed, goto appropriate tone
time=
goto tone}
If(RA1==1){
time=
goto tone}
If(RA2==1){
time=
goto tone}
If(RA3==1){
time=
goto tone}
If(RA4==1){
time=
goto tone}
If(RA5==1){
time=
goto tone}
If(RA6==1){
time=
goto tone}
If(RA7==1){
time=
goto tone}
If(RB0==1){
time=
goto tone}
If(RB1==1){
time=
goto tone}
If(RB2==1){
time=
goto tone}
If(RB3==1){
time=
goto tone}
If(RB4==1){
time=
goto tone}
If(RB5==1){
time=
goto tone}
If(RB6==1){
time=
goto tone}
If(RB7==1){
time=
goto tone}
If(RC0==1){
time=
goto tone}
If(RC1==1){
time=
goto tone}
If(RC2==1){
time=
goto tone}
If(RC3==1){
time=
goto tone}
If(RC4==1){
time=
goto tone}
If(RC5==1){
time=
goto tone}
If(RC6==1){
time=
goto tone}
}
tone:
while(*The Bit that got us here*== 1)
movlw 1
movfw RC7
*delay for time*
movlw 0
movfw RC7
*delay for time*
}
end
http://www.mastincrosbie.com/mark/electronics/pic/delay.html Would this work for the delays? also, where would I put that lib file so I can use those commands?
;THANKS A LOT GUYS!!!!!!!!!!!!
;Author Jake Wood
;Project Square Wave Keyboard
;Date 9 11 08
device PIC16F882
*What other info do I need up here, and what is the syntax to set the Hz of the built in 31kHz-8Mhz oscillator?*
origin 0
clrf PORTA *I would be surprised if this syntax were right
clrf PORTB
clrf PORTC
bsf STATUS, RP0; to bank 1
movlw b'11111111' ;sets 255 to W
movfw TRISA ;all RA set to input
movfw TRISB ;all RB set to input
movlw b'11111110' ;sets 255 to W
movfw TRISC ;RC0-6 set to input RC7 to out
bcf STATUS, RP0 ;back to bank 0
int time
buttons:
movlw 0
movfw RC7 ;turn RC7 off
While(1){
If(RA0==1){ ;waits for button to be pressed, goto appropriate tone
time=
goto tone}
If(RA1==1){
time=
goto tone}
If(RA2==1){
time=
goto tone}
If(RA3==1){
time=
goto tone}
If(RA4==1){
time=
goto tone}
If(RA5==1){
time=
goto tone}
If(RA6==1){
time=
goto tone}
If(RA7==1){
time=
goto tone}
If(RB0==1){
time=
goto tone}
If(RB1==1){
time=
goto tone}
If(RB2==1){
time=
goto tone}
If(RB3==1){
time=
goto tone}
If(RB4==1){
time=
goto tone}
If(RB5==1){
time=
goto tone}
If(RB6==1){
time=
goto tone}
If(RB7==1){
time=
goto tone}
If(RC0==1){
time=
goto tone}
If(RC1==1){
time=
goto tone}
If(RC2==1){
time=
goto tone}
If(RC3==1){
time=
goto tone}
If(RC4==1){
time=
goto tone}
If(RC5==1){
time=
goto tone}
If(RC6==1){
time=
goto tone}
}
tone:
while(*The Bit that got us here*== 1)
movlw 1
movfw RC7
*delay for time*
movlw 0
movfw RC7
*delay for time*
}
end
http://www.mastincrosbie.com/mark/electronics/pic/delay.html Would this work for the delays? also, where would I put that lib file so I can use those commands?
;THANKS A LOT GUYS!!!!!!!!!!!!
Last edited: