PDA

View Full Version : RTTTL problem??



akshay66
05-01-2009, 06:26 PM
Hi all,
I have problem with a assembly program.I don't know assembly language but i just wanted to test this program.So can anyone figure out the problem.
The errors shown by the compiler is

assembling akshay11.asm...
akshay11.asm(21): error A45: UNDEFINED SYMBOL (PASS-2)
Target not created

Program plays a happy birthday note on a buzzer.The part which is to played has been Programed by RTTTL language.




$mod51
FLAG EQU 07FH
SPEAKER EQU P0.3
BEGIN:
ORG 0000H
AJMP MAIN
ISR:
ORG 000BH
LCALL ACTION
RETI
ORG 0050H
MAIN:
MOV TMOD,#00010001B ;
MOV IE,#82H ;
MOV TH0,#0DCH
MOV TL0,#00H
SETB TR0
MOV DPTR,#SONG
MOV R0,#02
LOOP1:
ACALL PLAY_NOTE
CJNE R0,#02,CARRY_ON
SJMP MAIN ;end of music has been detected so strat again
CARRY_ON:
ACALL PLAY
SJMP LOOP1
PLAY:
CLR EA
SETB FLAG
SETB EA
RUN: JNB FLAG,STOP
DO: CJNE R0,#0,START
SJMP RUN
START: MOV TH1,R2
MOV TL1,R3
SETB TR1
HERE: JNB TF1,HERE
CLR TF1
CLR TR1
CPL SPEAKER
SJMP RUN
STOP: CLR SPEAKER
RET
PLAT_NOTE:
CONTINUE:
CLR A
MOVC A,@A+DPTR
MOV R0,A
INC DPTR
CLR A
MOVC A,@A+DPTR
MOV R1,A
INC DPTR
CLR A
MOVC A,@A+DPTR
MOV R2,A
INC DPTR
CLR A
MOVC A,@A+DPTR
MOV R3,A
INC DPTR
CLR A

RET
ACTION:
CLR TR0
CJNE R1,#0,D02
CLR FLAG
SJMP D03
D02: DEC R1
D03:
MOV TH0,#0DCH
MOV TL0,#00H
SETB TR0
RET
SONG: ;HAppy birthday
;R0 R1 R2 R3
DB 1, 12, 0FCH, 08FH ;R0=1indicates there is a note to be played
DB 0,6,0,0 ;R0=0indicates there is no note to be played
DB 1,6,0FCH,08FH
DB 0,6,0,0
DB 1,24,0FCH,0EFH
DB 0,6,0,0
DB 1,24,0FCH,08FH
DB 0,6,0,0
DB 1,24,0FDH,06CH
DB 0,6,0,0
DB 1,48,0FDH,045H
DB 0,12,0,0
DB 1,12,0FCH,08FH
DB 0,6,0,0
DB 1,6,0FCH,0EFH
DB 1,24,0FCH,0EFH
DB 0,6,0,0
DB 1,24,0FCH,08FH
DB 0,6,0,0
DB 1,24,0FDH,0B4H
DB 0,6,0,0
DB 1,48,0FDH,06CH
DB 0,24,0,0
DB 1,12,0FCH,08FH
DB 0,6,0,0
DB 1,6,0FCH,08FH
DB 0,6,0,0
DB 1,24,0FEH,048H
DB 0,6,0,0
DB 1,24,0FBH,0E9H
DB 0,6,0,0
DB 1,24,0FDH,06CH
DB 0,6,0,0
DB 1,24,0FDH,045H
DB 0,6,0,0
DB 1,24,0FCH,0EFH
DB 0,6,0,0
DB 1,12,0FCH,023H
DB 0,6,0,0
DB 1,6,0FCH,023H
DB 0,6,0,0
DB 1,24,0FBH,0E9H
DB 0,6,0,0
DB 1,24,0FDH,06CH
DB 0,6,0,0
DB 1,24,0FDH,0B4H
DB 0,6,0,0
DB 1,48,0FDH,06CH
DB 2,0,0,0 ;R0=2 indicates end of music
END




This program came in electronics for you of the march 2009 edition.

debu
05-01-2009, 07:29 PM
@akshay66:


Line 21: ACALL PLAY_NOTE


Line 44: PLAT_NOTE:

Notice something?

Hope this helps,

Regards,

Debu :)

suhasm
05-01-2009, 07:34 PM
There is a reference to PLAY_NOTE in 21st line...
There is nothing called PLAY_NOTE in the rest of the program...

That is causing the error...

There is a label called PLAT_NOTE after a few lines. Probably that has been mis-spelled by the author.
Change that to PLAY_NOTE
Then it will work.

EDIT : ah..Debu beat me to it by a few mins.

akshay66
05-01-2009, 09:18 PM
Hi all,
Finally it has started working but the sound is not clear.I was using a buzzer uptil now.Now i will change it to a speaker maybe thats the reason.Pleas give your opinions on this.

:D THANKS TO DEBU & SUHASM :D

Regards Akshay,