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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/10/12 07:43
Read: 603 times


 
#186556 - Jumping from RET to Jump Start
Responding to: Robert Revens's previous message
Ok, my module has decided to start talking to my MCU, I didnt change anything, might do lotto later seems to be a lucky day....

Now it is reading the ack packet from module and storing it in RAM.

When my program gets to RET instruction of my READ_SERIAL_TABLE, it jumps back up to JMP START which is the start of my entire program.
Its suppose to LJMP COMPARE_ACK.

The READ_SERIAL_TABLE is very similar to WRITE_TABLE_SERIAL and i have no issues with Write subroutine

I have included all the code that i think is relevant to the issue, if more is needed I can post

Dave


#define BUF 0X40				;DECLARE BUF AT LOCATION 40 OF MEMORY
RS EQU P2.2					;DELARE RS (REGISTER SELECT) TO PORT 2 PIN 2
E EQU P2.3					;DECLARE E (ENABLE LINE) TO PORT 2 PIN 3 
ORG 0						;START OF PROGRAM (RESET)
			JMP START		;INSTRUCTS PROGRAM TO JUMP TO START SUBROUTINE
;ORG A3H					;UART1 INTERRUPT IS RECOGNISED
			;LJMP ISR_SERIAL	;INSTRUCTS PROGRAM TO JUMP TO INTERRUPT SUBROUTINE FOR SERIAL COMMS
							
;===========================================================================
;HERE IS THE MAIN PROGRAM WHERE ALL THE SUBROUTINES ARE CALLED AND DEVICES ARE INITILIZED,
;STACK POINTER IS SET TO LOCATION 4FH WHILE THE WATCHDOG IS DISABLED AS IT IS NOT NECESSARY FOR THIS PROGRAMME
;REGISTER 1 IS SET AS BUF TO STORE ACK PACKET FOROM FINGERPRINT MODULE WHEN NEEDED,
;REGISTER 2 IS SET AT 25 AS THIS IS THE SIZE OF THE COMMS PACKETS BEING SENT AND RECIEVED FROM FINGERPRINT MODULE.
;THE LCD,PORTS, PUSHBUTTONS AND UART ARE CALLED AND INITILIZED. ALSO A REQUSET CONECTION IS SENT TO THE MODULE TO ALLOW COMMS BETWEEN IT AND THE MCU
;============================================================================

ORG 100H

START:
			MOV SP,#4FH			;START STACK @ 50H
			MOV WDTCN,#0DEH 	        ;DISABLE WATCHDOG							 
			MOV WDTCN,#0ADH
			LCALL LCD_INIT			;INITILIZE LCD DISPLAY
			;LCALL CONFIGURE_INTERRUPT      ;SETS UP INTERRUPTS FPR SERIAL COMMS (IF REQUIRED)									 
			LCALL CONFIGURE_PORTS		;CALLS SUBROUTINE TO INITILIZE PORTS
			LCALL CONFIGURE_UART1		;CALLS SUBROUTINE TO INITILIZE UART ON CROSSBAR
			LCALL REQUEST_CONNECTION	;CALLS REQUEST CONNECTION TO FINGERPRINT MODULE
			LCALL MAIN

MAIN:
			LCALL DISPLAY_6			;CALLS DISPLAY 'PRESS BUTTON TO SCAN FINGER'
			LCALL PUSHBUTTONS		;CALL PUSHBUTTON SUBROUTINE THATS CHECKS TO SEE IF A BUTTON IS PUSHED
LJMP MAIN 										
;===========================================================================================
;THESE SUBROUTINES ARE WHERE THE PROGRAME COMES TO ONCE A PUSHBUTTON IS PRESSED, THEY INITIATE READ/WRITE COMMANDS FOR SERIAL PORT COMMS,
;AND ALSO DISPLAY MESSAGES ON LCD DISPLAY
;============================================================================================
REQUEST_CONNECTION:
			LCALL REQUEST_CONNECT           ;CALL RQST CONNECT SUBROUTINE TO CONNECT MODULE TO MCU
			;LCALL DISPLAY_ACK              ;NOT BEING USED
			LCALL COMPARE_REQUEST_ACK       ;CALL TO COMPARE ACK PACKET WITH GIVEN ACK PACKET STORED IN CODE MEMORY
			
			LJMP MAIN

;============================================================================================================
;THIS SECTION IS THE SUBROUTINES FOR SENDING THE 25 BYTE PACKET OVER THE SERIAL PORT ONCE THE BUTTON IS PUSHED,
;============================================================================================================
	
REQUEST_CONNECT:

			PUSH ACC
			CLR A
			MOV DPTR,#REQUEST_CONN			;MOVE DATA POINTER RQST_CONN TABLE
			MOV R0,#25				;MOV R0 TO 25H TO ALLOW FOR THE 25 BITS IN TABLE
			LCALL WRITE_TABLE_SERIAL		;CALL WRITE_TABLE_SERIAL TO WRITE THE BYTES TO SBUF
			MOV R1,#BUF				;LET R1 = LOCATION 40 TO STORE ACK PACKET
			MOV R2,#25				;LET R2 = SIZE OF PACKET TO BE COUNTED (25)
			CLR A
			LCALL READ_TABLE_SERIAL
			POP ACC
			RET                                     ;RETURN TO CALL COMPARE ACK,


;=================================================================================================
;THIS SUBROUTINE WILL READ WHATS TRANSMITTED BACK FORM THE SERIAL PORTS (SBUF0) AND MOVE IT TO THE ACCUMULATOR
;=================================================================================================
READ_SERIAL:
TEST_RI:

			MOV A,SCON1
			ANL A,#01H			;TEST RI1 FLAG TO SEE IF A BYTE IS READY TO BE READ FROM PERIPHERAL DEVICE
			JZ TEST_RI
							
			MOV B,SBUF1			;MOVE VALUE IN SBUF TO B-REGISTER
									
			MOV A,SCON1			;CLEAR RI TO RECIEVE NEXT BYTE AND RETURN FROM ROUTINE
			ANL A,#0FEH
			MOV SCON1,A
			CLR A
RET

;===================================================================================================
;THIS SUBROUTINE TAKES EACH VALUE READ FROM SERIAL PORT (SBUF) AND STORES IT AT LOCATION SET BY REGISTER R0
;====================================================================================================

READ_TABLE_SERIAL:
NEXT_BYTE2:
			LCALL READ_SERIAL	;CALL SUBROUTINE
			MOV @R1,B		;MOVE VALUE IN B REGISTER TO LOCATION OF R1
			MOV B,#00H
			INC R1			;INCREMENT R1 TO ADD NEXT RECIEVED BYTE TO MEMORY
			DJNZ R2,NEXT_BYTE2      ;LOOP AROUND AND DECREMENT R2 UNTIL = 0 TO RECEIVE EACH OF 25 BYTES THEN RETURN FROM SUBROUTINE
RET                                             ;THIS IS WHERE PROGRAM JUMPS TO JMP START UNEXPECTEDLY

;=================================================================================================
;HERE IS WHERE THE ACKNOWLEDGEMENT PACKET FORM THE FINGERPRINT MODULE IS READ AND STORED AT LOCATION SET BY R1,
;IT IS THEN COMPARED TO A GIVEN VALUE TO SEE IF ITS CORRECT
;=================================================================================================
COMPARE_REQUEST_ACK:
			MOV DPTR,#REQUEST_ACK	;MOVE REQUEST_ACK PACKET TO DPTR
			MOV R1,#BUF		;LET R1 = LOCATION 40
			MOV R2,#25		;LET R2 = SIZE OF PACKET (25)
			LCALL CMP_MSG		;CALL COMPARE MESSAGE SUBROUTINE
			LJMP DISPLAY_5

List of 17 messages in thread
TopicAuthorDate
Serial coms, bytes not matching in serial capture      Dave McNamara      03/07/12 10:22      
   Couple of things at first glance...      Robert Revens      03/07/12 12:52      
      Response      Dave McNamara      03/07/12 13:13      
         OK      Robert Revens      03/07/12 14:09      
   what does the instruction spell out      Erik Malund      03/07/12 13:46      
      Instruction says      Dave McNamara      03/07/12 14:17      
         Got it      Dave McNamara      03/07/12 14:29      
            have a good read      Erik Malund      03/08/12 07:16      
               Nitgen FIM5360 module      Dave McNamara      03/09/12 11:46      
                  Not familiar with the module...      Robert Revens      03/09/12 14:03      
                     Boot up time...      Robert Revens      03/09/12 14:15      
                     Response      Dave McNamara      03/09/12 14:55      
                        Isn't boot time always time from reset or time from power-on      Per Westermark      03/09/12 15:10      
                           Ok      Dave McNamara      03/09/12 15:18      
                        SCON1...      Robert Revens      03/10/12 05:24      
                           Jumping from RET to Jump Start      Dave McNamara      03/10/12 07:43      
   Please Ignore last post, issue resolved      Dave McNamara      03/10/12 10:30      

Back to Subject List