kent01981 0 Newbie Poster

Hi, I am doing a doorbell using P16F84A chip.
I have programmed in asm in MPLAB 8.10,but the code is not working at all.
no any errors show up, but just not working.
please help me out.

#include P16F84A.inc

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
errorlevel -302
org 0x0000
porta equ 05h
portb equ 06h
NoteC equ 0Ch
NoteD equ 0Dh
NoteE equ 0Eh
NoteF equ 0Fh
NoteG equ 11h
NoteA equ 12h
NoteB equ 13h
postC equ 14h
postD equ 15h
postE equ 16h
postF equ 17h
postG equ 18h
postB equ 19h
postA equ 1Ah
post30 equ 1Bh
post2 equ 1Ch

Start
;==============
Init clrf porta
clrf portb
movlw b'1111'
tris porta
movlw b'00000000'
tris portb

movlw d'30'
movwf post30

movlw d'127'
movwf NoteC

movlw d'113'
movwf NoteD

movlw d'101'
movwf NoteE

movlw d'95'
movwf NoteF

movlw d'85'
movwf NoteG

movlw d'75'
movwf NoteA

movlw d'67'
movwf NoteB

movlw d'2'
movlw post2

movlw d'131'
movlw postC

movlw d'147'
movlw postD

movlw d'165'
movlw postE

movlw d'175'
movlw postF

movlw d'196'
movlw postG

movlw d'220'
movlw postA

movlw d'297'
movlw postB

main bcf portb,0
btfsc porta,0
goto melody1
;btfsc porta,1
goto melody2
btfsc porta,2
goto melody3
btfsc porta,3
goto melody4
goto main

melody1 call CNote
call DNote
call ENote
call FNote
call GNote
call ANote
call BNote
goto main

melody2 call ENote
call ENote
call FNote
call GNote
call GNote
call FNote
call ENote
call DNote
call CNote
call CNote
call DNote
call ENote
call DNote
call CNote
call CNote
goto main

melody3 call BNote
call ANote
call GNote
call FNote
call ENote
call DNote
call CNote
goto main

melody4 call BNote
call FNote
call GNote
call DNote
call ENote
call CNote
call CNote
call ANote
call BNote
goto main

CNote decfsz NoteC,f
goto CNote
decfsz post30,f
goto CNote
movlw b'00000001'
xorwf portb,0
movlw d'127'
movwf NoteC
movlw d'30'
movwf post30
decfsz postC,f
goto CNote
decfsz post2,f
goto CNote
movlw d'2'
movwf post2
movlw d'131'
movlw postC
goto main
;return


DNote decfsz NoteD,f
goto DNote
decfsz post30,f
goto DNote
movlw b'00000001'
xorwf portb,0
movlw d'113'
movwf NoteD
movlw d'30'
movwf post30
decfsz postD,f
goto DNote
decfsz post2,f
goto DNote
movlw d'2'
movwf post2
movlw d'147'
movwf postD
return

ENote decfsz NoteE,f
goto ENote
movlw d'101'
movwf NoteE
decfsz post30,f
goto ENote
movlw d'30'
movwf post30
movlw b'00000001'
xorwf portb,0
movlw d'101'
movwf NoteE
movlw d'30'
movwf post30
decfsz postE,f
goto ENote
movlw d'165'
movwf postE
decfsz post2,f
goto ENote
movlw d'2'
movwf post2
movlw d'165'
movwf postE
return

FNote decfsz NoteF,f
goto FNote
decfsz post30,f
goto FNote
movlw b'00000001'
xorwf portb,0
movlw d'95'
movwf NoteF
movlw d'30'
movwf post30
decfsz postF,f
goto FNote
decfsz post2,f
goto FNote
movlw d'2'
movwf post2
movlw d'175'
movwf postF
return

GNote decfsz NoteG,f
goto GNote
decfsz post30,f
goto GNote
movlw b'00000001'
xorwf portb,0
movlw d'95'
movwf NoteG
movlw d'30'
movwf post30
decfsz postG,f
goto GNote
decfsz post2,f
goto GNote
movlw d'2'
movwf post2
movlw d'196'
movwf postG
return

ANote decfsz NoteA,f
goto ANote
decfsz post30,f
goto ANote
movlw b'00000001'
xorwf portb,0
movlw d'75'
movwf NoteA
movlw d'30'
movwf post30
decfsz postA,f
goto ANote
decfsz post2,f
goto ANote
movlw d'2'
movwf post2
movlw d'220'
movwf postA
return

BNote decfsz NoteB,f
goto BNote
decfsz post30,f
goto BNote
movlw b'00000001'
xorwf portb,0
movlw d'67'
movwf NoteB
movlw d'30'
movwf post30
decfsz postB,f
goto BNote
decfsz post2,f
goto BNote
movlw d'2'
movwf post2
movlw d'297'
movwf postB
return

;==============

END

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.