PDA

View Full Version : MAXTERM for NMIX 0016


clement sudhakar
03-19-02, 04:02 AM
I have a few questions to be clarified...could anyone help me

1. I write a assembly code to set a bit in the Internal bit addressable memory. How to test the memory after execution of the program?

2. Is it possible to check the register contents after a small program execution. like

MOV R1, #33H
MOV R2, #44H
LJMP 0030H

From what I understand, when a program is executed, the nmix monitor resets all the registers...is it true?

3. Is it possible to access the port 4 as normal. When I write a data to Port 4, and check the SFR content, the data doesnt seem to be there. Why?


4. I find that the unit has a keypad and lcd display interface. Is there a standard code available to use them or should we write one of our own?

Thank you for your reply

Clement

nmitech
03-19-02, 12:08 PM
1. I write a assembly code to set a bit in the Internal bit addressable memory. How to test the memory after execution of the program?
2. Is it possible to check the register contents after a small program execution. like

You can use the monitor commands to check the registers content after execution, but to do this you must add a jump to the monitor prompt or where the monitor main program starts, LJMP 05Ah right before the program is exit.

From what I understand, when a program is executed, the nmix monitor resets all the registers...is it true?

No, Let put it this way, Once you use the monitor execute command X "address" your program will take over the execution of your program instructions. If you exit your program without jump to the monitor main routine LJMP 05Ah the instruction pointer will get lost and the code will hang and if you do a hardware reset then the monitor will re-initialize all the registers. That is why!

3. Is it possible to access the port 4 as normal. When I write a data to Port 4, and check the SFR content, the data doesnt seem to be there. Why?

Keep in mind, Port 4 bit 3 to bit 7 are also share with the keypad data lines. If you use the keypad for your application then you can only use Port 4 bit 0,1,2. IF keypad is not used, you can remove the keypad decoder chip, 74C923 and be able to use all 8-bit of Port4.

4. I find that the unit has a keypad and lcd display interface. Is there a standard code available to use them or should we write one of our own?

I am looking for the examples. Stay tune!

nmitech
03-19-02, 12:51 PM
.ORG H'8000 ; START PROGRAM ON RAM LOCATION U3

.EQU LCDCMD,H'FFE0 ; DEFINE LCD COMMAND REGISTER
.EQU LCDDAT,H'FFE1 ; LCD DATA REGISTER

;-------------------------------------------------
; CHECK LCD STATUS BIT
;-------------------------------------------------
NOBUSY: MOV DPTR,#LCDCMD
ISBUSY: MOVX A,@DPTR
JB ACC.7,ISBUSY ;WAIT UNTIL NOT BUSY
RET

;-------------------------------------------------
; INITIALIZE LCD
;-------------------------------------------------
INILCD: ACALL NOBUSY
MOV A,#038H
MOVX @DPTR,A
ACALL NOBUSY
MOV A,#038H
MOVX @DPTR,A
ACALL NOBUSY
MOV A,#06H
MOVX @DPTR,A
ACALL NOBUSY
MOV A,#0EH
MOVX @DPTR,A
RET

;-------------------------------------------------
;SEND A CARRIAGE RETURN LINE FEED TO LCD
;-------------------------------------------------
LCDLF: MOV DPTR,#LCDCMD
ACALL NOBUSY
MOV A,#0C0H ;SET NEW LINE COMMAND
MOVX @DPTR,A
RET

;-------------------------------------------------
;SEND A CHARACTER TO LCD
;-------------------------------------------------
LPUTC:
MOV B,A ;SAVE ACC
ACALL NOBUSY ;WAIT FOR LCD READY
MOV A,B ;RESTORE ACC
MOV DPTR,#LCDDAT ;AND
MOVX @DPTR,A ;SEND CHARACTER TO LCD
RET

;-------------------------------------------------
; SEND A STRING TO LCD
;-------------------------------------------------
LPUTS: CLR A ;CLEAR A
MOVC A,@A+DPTR ;GET CHARACTER OF STRING
NEXTC: PUSH DPL ;SAVE STRING DPTR
PUSH DPH
ACALL LPUTC ;SEND TO LCD
POP DPH ;RESTORE STRING DPTR
POP DPL
INC DPTR ;POINT TO NEXT CHARACTER
CLR A ;CLEAR A
MOVC A,@A+DPTR ;GET NEXT CHARACTER OF STRING
CJNE A,#0,NEXTC ;SEND IT TO LCD TILL DONE
RET
;-------------------------------------------------
; SEND MESSAGES: GREET1 & GREET2 TO LCD
;-------------------------------------------------
LCDMSG: MOV DPTR,#GREET1 ;GET GREET1 MESSAGE
ACALL LPUTS ;PUT ON LCD
ACALL LCDLF ;NEW LINE
MOV DPTR,#GREET2 ;GET GREET2 MESSAGE
ACALL LPUTS ;PUT ON LCD
RET ;DONE


GREET1: .DB "HELLO WORLD! \0",

GREET2: .DB "This is a test \0"

;------- PROGRAM EXECUTES AT ADDRESS 8400h, <X 8400> ------

.ORG H'8400
ACALL INILCD
ACALL LCDMSG
LJMP H'5A
.END