Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/30/07 19:44
Read: times


 
#143769 - Assembler Directive DB
THIS IS MY FIRST EVER POST ON THIS FORUM. So if i am not adhering to certain norms, kindly pardon. I will know them soon.

I am using the code to Display on the 16x2 LCD.
When using code to send data byte individually to the LCD the Display works. Since there were several Titles to be displayed i used "DB" to define the title string. Running the code with this does not display anything but just '0' which i gave in the code without using DB. So i assumed that DB is not working.As direct data commands to the LCD is working so it means LCD is initialised properly.
I am using KEIL to complie this .asm file. it is showing no errors. 1. Does KEIL understand DB assembler directive.
2. Can you please suggest other assembler.

The code is appended below:
-----------------------------------------------------------------
RS EQU P2.5; RS pin of LCD
EN EQU P1.2 ;Enable pin of LCD
LCD EQU P0 ; Port 0 as data port
TITLE: DB "PROJECT-GPSH",0
MODE: DB "MODE",0
ACQUIRING: DB "ACQUIRING GPS",0
NVRAMFULL:DB "NVRAM IS FULL",0 
;---------------------------
ORG 0
LJMP MAIN
MAIN:
	ACALL CHK_MODE ; check the mode using Pin 1.0 and 1.1
	ACALL INIT_LCD; Initialise
	ACALL DISP_TITLE; Dispaly Title
	ACALL DISP_MODE; Display "MODE"
	SJMP GOTO_MODE; jump to mode 
;----------------------------------------
CHK_MODE:SETB P1.0; Make them as input pins  // USING R1
	SETB P1.1;
	MOV A,P1; Reading Mode info
	ANL A,#03H; Storing P1.1 and P1.0 only
	MOV R1,A; Mode info in R1
RET
;---------------------------------------------
INIT_LCD:	; Initialising LCD
	MOV A, #38H
	ACALL LCDCMD
	MOV A,#02H
	ACALL LCDCMD
	MOV A,#0FH
	ACALL LCDCMD
	MOV A,#80H
	ACALL LCDCMD
	MOV A,#01H
	ACALL LCDCMD
RET
;-------------------------------------------
LCDCMD:	   ; Command Word to LCD
	MOV LCD,A
	CLR RS
	SETB EN
	ACALL DELAY_INIT
	CLR EN
RET
;----------------------------------------------
DELAY_INIT:		 ; Delay in initialising
	MOV R7,#0FFH
	LOOP_DELAY_INIT:MOV R0,09H
	JUMPHERE_DELAY_INIT:DJNZ R0,JUMPHERE_DELAY_INIT
	DJNZ R7,LOOP_DELAY_INIT
RET
;---------------------------------------
DISP_CHAR:               ; Display Character on LCD
	SETB RS
	MOV LCD,A
	SETB EN
	ACALL DELAY_CHAR
	CLR EN
	ACALL DELAY_CHAR
RET
;------------------------------------------
DELAY_CHAR:		;Delay  Using R7,R0
	MOV R7,#0FFH
	LOOP_DELAY_CHAR:MOV R0,01H
	JUMPHERE_DELAY_CHAR:DJNZ R0,JUMPHERE_DELAY_CHAR
	DJNZ R7,LOOP_DELAY_CHAR
RET
;-----------------------------------
DISP_TITLE:ACALL CLR_LCD
	MOV DPTR,#TITLE	          ; Display   "Project-GPSH"
	NEXT_CHAR_DISP_TITLE:CLR A
		MOVC A,@A+DPTR	  
		JZ EXIT_DISP_TITLE  ; IF Null then exit
		ACALL DISP_CHAR
		INC DPTR
		SJMP NEXT_CHAR_DISP_TITLE
EXIT_DISP_TITLE: 
RET
;-----------------------------------------		
DISP_MODE: ACALL CLR_LCD
	MOV DPTR,#MODE	; Display "MODE"
	NEXT_CHAR_DISP_MODE:CLR A
		MOVC A,@A+DPTR	  
		JZ EXIT_DISP_MODE	  ; If Null the exit
		ACALL DISP_CHAR
		INC DPTR
		SJMP NEXT_CHAR_DISP_MODE
	EXIT_DISP_MODE:MOV A,#30H  ; Display Mode Noumber 0/1/2/3
		ORL A,R1
		ACALL DISP_CHAR
RET
;---------------------------------
GOTO_MODE:MOV A,R1      ; Checking Mode and jumping to subprogram
	JB ACC.1,MODE2OR3 ; 00= mode 0
	JB ACC.0,MODE0    ; 01= mode1 
 	LJMP MODE_1        ; 10= mode 2
	MODE2OR3: JB ACC.0,MODE2 ; 11= mode 3
		LJMP MODE_3
	MODE0:LJMP MODE_0
	MODE2:LJMP MODE_2
;----------------------------------- 
DELAY:MOV R7,A  ; USING R7,R0
	LOOP_DELAY:MOV R0,#0FFH
	JUMPHERE_DELAY:DJNZ R0,JUMPHERE_DELAY
		DJNZ R7,LOOP_DELAY
RET
;-----------------------------------------------
DISP_NVRAM_FULL: ACALL CLR_LCD	
	MOV DPTR,#NVRAMFULL	  ; Daisplay "NVRAM FULL"
	NEXT_CHAR_DISP_NVRAM_FULL:CLR A
		MOVC A,@A+DPTR	  
		JZ EXIT_DISP_NVRAM_FULL	  ; If Null then Exit
		ACALL DISP_CHAR
		INC DPTR
		SJMP NEXT_CHAR_DISP_NVRAM_FULL
EXIT_DISP_NVRAM_FULL:
RET	
;---------------------------------------	
DISP_ACQUIRING:ACALL CLR_LCD
	MOV DPTR,#ACQUIRING	; Display "ACQUIRING GPS"
	NEXT_CHAR_DISP_ACQUIRING:CLR A
		MOVC A,@A+DPTR	  
		JZ EXIT_DISP_ACQUIRING	  ; If Null then Exit
		ACALL DISP_CHAR
		INC DPTR
		SJMP NEXT_CHAR_DISP_ACQUIRING
EXIT_DISP_ACQUIRING: 
RET
;-------------------------------------------
CLR_LCD:MOV A,#01H	; Clearing LCD
	ACALL LCDCMD
	MOV A,#80H    ; Cursor at start of line 1
	ACALL LCDCMD
RET
;--------------------------
SET_SRL_MODE_0:MOV TMOD,#20H  ; TIMER 1 , AUTO RELOAD MODE
	MOV SCON,#50H  ; 8N1
	MOV TH1,#0FDH; 9600 BAUDS
	MOV A,PCON	 ; Double the Baud
	SETB ACC.7
	MOV PCON,A	; BAUD Set at19200
	SETB TR1	; Start Timer T1
RET
;---------------------------------------------
MODE_0:
        MOV IE,#0H ; Disable Interrupts
	ACALL DISP_ACQUIRING
	ACALL SET_SRL_MODE_0
	MOV A, #0FH
	ACALL DELAY
	MOV DPTR,#0000H	
	CHK_NVRAM:; Check if 8Kx8 NVRAM full. Address 0000H TO 1FFFH
		MOV A,82H; DPTR Lower byte (DPL) To ACC
		CLR C; Clear Carry
		SUBB A,#0FFH ; compare Lower byte with FF
		JC WAIT_HERE
		CLR C
		MOV A,83H ; DPTR higher Byte (DPH) To ACC
		SUBB A,#1FH ; Compare higher byte with 1F
		JNC FULL ; If = or > the jump to full
	WAIT_HERE:JNB RI,WAIT_HERE; Wait for character to come in		        MOV A,SBUF ; Get Received Byte in ACC
	        MOVX @DPTR,A; Store in external RAM
	        INC DPTR; Incrdement pointer
	        SJMP CHK_NVRAM; check RAM status
	FULL:ACALL DISP_NVRAM_FULL ; Display RAM is Full
	LJMP LAST

MODE_1:NOP  ; To be programmed 
MODE_2:NOP   ; To be programmed 
MODE_3:NOP   ; To be programmed 
LAST:NOP
END





List of 24 messages in thread
TopicAuthorDate
Assembler Directive DB            01/01/70 00:00      
   Hmmm... Looks suspiciously like...            01/01/70 00:00      
   see the list file            01/01/70 00:00      
      movbe the db's to the end            01/01/70 00:00      
   Formatted again            01/01/70 00:00      
      highlight            01/01/70 00:00      
         What do you mean?            01/01/70 00:00      
   Keil DB syntax            01/01/70 00:00      
      I think i found the problem            01/01/70 00:00      
         you don't need to do that...            01/01/70 00:00      
            You are Right            01/01/70 00:00      
   Another Bug found            01/01/70 00:00      
      What is the crystal frequency?            01/01/70 00:00      
      I doubt it            01/01/70 00:00      
   Another Mode Added ,19200 problem solved            01/01/70 00:00      
      how do you mean this?            01/01/70 00:00      
         Couldnt get your query            01/01/70 00:00      
            END is not an instruction            01/01/70 00:00      
      END is not an instruction!!!            01/01/70 00:00      
         Got the point ; query about program loop            01/01/70 00:00      
            How microcontroller programs end (or don't)            01/01/70 00:00      
               Alternative to infinite loop            01/01/70 00:00      
            what is an infinite loop?            01/01/70 00:00      
               That must be the reason...            01/01/70 00:00      

Back to Subject List