We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I have two files in my project, that are as follows; /////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// File 1 ////////////////////////////// /////////////////////////////////////////////////////////////////////////// $NOMOD51 $INCLUDE (REG952.H)
PUBLIC HI_DATA PUBLIC LO_DATA PUBLIC LED_PORT PUBLIC RAM_LOCATION EXTRN CODE (init_CAM) ;============================================================== ; EQUATES COMMON ;============================================================== LED_PORT EQU P5
USING 0 ;using register bank0 USING 1 ;using register bank1
C_DATA SEGMENT DATA
RSEG C_DATA
HI_DATA: DS 1; LO_DATA: DS 1; RAM_LOCATION: DS 1; STACKPTR: DS 1; ; START OF STACK
;============================================================== ; INTERRUPT VECTORS ;============================================================== C_TEXT SEGMENT CODE RSEG C_TEXT
ORG 000H ; RESET VECTOR JMP INIT_MAIN
;============================================================== ; INITIALIZATION ROUTINE COMMON ;============================================================== INIT_MAIN:
;---------- added for NXP -----------------
MOV DIVM,#2
MOV DPTR,#0FFB8H ; P4M1 MOV A,#00H MOVX @DPTR,A MOV DPTR,#0FFB9H ; P4M2 MOV A,#00H MOVX @DPTR,A MOV DPTR,#0FFBAH ; P5M1 MOV A,#00H MOVX @DPTR,A MOV DPTR,#0FFBBH ; P5M2 MOV A,#00H MOVX @DPTR,A
MOV P2M1,#00H ; for NXP MOV P2M2,#00H ; for NXP MOV P1M1,#00H ; for NXP MOV P1M2,#00H ; for NXP MOV P0M1,#00H ; for NXP MOV P0M2,#00H ; for NXP MOV P3M1,#00H ; for NXP MOV P3M2,#00H ; for NXP
MOV SP,#STACKPTR MOV LED_PORT,#05H
MOV HI_DATA,#0 MOV LO_DATA,#0 MOV RAM_LOCATION,#0
;============================================================== ; BACKGROUND PROCESS ;============================================================== BKGR:
call init_CAM
JMP BKGR ;============================================================== ; BACKGROUND PROCESS ends ;============================================================== END
whereas file 2 is
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// File 2 ////////////////////////////// /////////////////////////////////////////////////////////////////////////// $NOMOD51
EXTRN DATA (HI_DATA) EXTRN DATA (LO_DATA) EXTRN NUMBER (LED_PORT) EXTRN DATA (RAM_LOCATION) PUBLIC init_CAM
LIB_TEXT SEGMENT CODE
RSEG LIB_TEXT
init_CAM: MOV LED_PORT,#0AH
RET END
Note: When I declare the function init_CAM directly in file 1, the LED_PORT works. However if I call the same init_CAM function created in file 2, the LED_PORT does not work. The code compiles without error. Kindly provide the solution to this problem. I am using uVision 3 VER3.30 and the target controller is NXP P89LPC952.
Regards, Nick
However if I call the same init_CAM function created in file 2, the LED_PORT does not work.
You'll have to be more specific than that. How does is "not work"? What did you expect to happen, and what happened instead?
Hi, The LED_PORT defines the address of Port 5(0xB4) of P89LPC952, onto which leds are interfaces with the respective pins of the port. When I write any value on Port 5, the interfaced leds lights up accordingly. However if the same value is being written on the port 5, but the function is being called from another file. Then the output on the LEDs does not appear. Kindly help.
bye, Nick.
Kindly help.
why do you not help us by posting your code as code the garbage is unreadable
Erik
www.danlhenry.com/.../keil_code.png