Re: asm

Thomas Chenot <tom.chenot-6tN4nzCoH/[email protected]> Thu, 17 Jun 2004 14:55:18 -0500
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
Daniel Young wrote:

>Hi all could anyone take a look at this asm code for an ISR and tell me
>what I am doing wrong? 
>  
>
What are your symptoms? See notes inline with your code.

I would not install and remove the IO_Poll if you plan to receive data 
asynchronously (can come at any time at unknown intervals). Instead I 
would install it once and register a ProcessDestroy function to clean up 
poll and other stuff. Use a flag (similiar to your data storage or use 
indirects as described in native docs) to signal from your ISR to your 
POLL routine that data is available.

>If so, much appreciated!  (code below)
>
>Thank you
>Daniel
>
>
>$include(tini_400.inc)
>$include(ds80c400.inc)
>$include(tinimacro.inc)
>$include(apiequ.inc)
>
>;INIT
>init:	
>	clr	a			;			
>	ret				;
>;END INIT
>
>;ISR SETUP
>Native_SetupISR:			;	
>	clr	a			;
>	clr	ea			;	
>	clr	EIE.3			;
>	setb	EIP.3			;	
>	PUSH_DPTR2			;	
>	push	dps			; 	
>	inc 	dps			;
>	mov	dptr, #ISR_Weigand	;
>	mov	a, #5Bh			;
>	lcall	System_InstallInterrupt	;
>	pop	dps			;
>	POP_DPTR2			;
>	setb	ea			;	
>	ret				;
>; END SetupISR
>
>;ISR ROUTINE
>ISR_Weigand:
>	clr	EIE.1			;
>  
>
;;;Why EIE.1??? This does not match your SetupISR.

>	FEEDDOG
>	;do read weigand data into TagData somehow
>		
>
>	RETI				;
>;END ISR
>
>;IO_POLL AWAKEN THREAD
>Weigand_Poll:			
>	PUSH_DPTR1			;	
>	mov	dptr,#ThreadID_Buffer	;
>	GETX				;
>	mov	R0,a			;
>	inc	dptr			;
>	GETX				;
>	lcall	System_ThreadResume	;
>	mov	dptr,#Weigand_Poll	;
>	lcall	System_RemovePoll	;
>  
>
;;; Why remove poll here and in ReadWeigand?

>	POP_DPTR1			;
>	ret				;
>;END POLL ROUTINE
>
>;NATIVE GET WEIGAND TAG DATA
>Native_ReadWeigand:			; INPUT == Java Byte Array
>
>	mov	dptr,#ThreadID_Buffer	;
>	lcall	System_GetCurrentProcessID;
>	PUTX				;
>	inc	dptr			;
>	lcall	System_GetCurrentThreadID;
>	PUTX				;	
>	mov	dptr,#Weigand_Poll	;
>	lcall	System_RegisterPoll	;			
>	setb	EIP.1			;
>	setb	EIE.1			;
>  
>
;;; Why EIE.1/EIP.1? Does not Match SetupISR.

>	clr	a			;	
>	lcall	Natlib_LoadJavaByteArray;
>	jnz	exit_poll		;
>  
>
;;; If you take this jump you will not remove your POLL

>	lcall	System_SaveJavaThreadState;			
>	PUSH_DPTR1			;
>	PUSH_BANK_0			;
>	mov	a, #254			;
>	lcall	System_ThreadSleep	;	
>	POP_BANK_0			;
>	POP_DPTR1			;
>	mov	a, #128			;
>	PUTX				;
>	inc	dptr			;
>	mov	a, #128			;
>	PUTX				;
>	inc	dptr			;	
>	mov	a, #128			;
>	PUTX				;
>	inc	dptr			;	
>	mov	a, #128			;
>	PUTX				;	
>	mov	dptr,#Weigand_Poll	;
>	lcall	System_RemovePoll	;		
>	
>exit_poll:
>	lcall	System_RestoreJavaThreadState;	
>	clr	a			;
>	ret				;
>;END NATIVE READ WEIGAND
>
>;DATA STORAGE
>TagData:
>DB 0,0,0,0
>
>THREADID_BUFFER:
>DB 0,0
>
>MyByteArray:
>DB 0,0,0
>
>
>
>END				
>
>  
>


-- 
Thomas Chenot

_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini