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

Back to Subject List

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


 
#143670 - re:
Responding to: ???'s previous message
Andy and Neil,

Is this better?


/* main.c */


#include <stdio.h> 
#include <ADuC834.h>
#pragma NOREGPARMS
extern unsigned char Blink_func (unsigned char Dly_time);
extern void Delay_func (void);

void main (void)
{
while(1){
    Blink_func (1); /* blink at a 0.2 second interval */
	Delay_func();  /* delay for 5 seconds */

	Blink_func (5); /* blink at a 1.0 second interval */
	Delay_func();  /* delay for 5 seconds */
	
	Blink_func (10); /* blink at a 2.0 second interval */
	Delay_func();  /* delay for 5 seconds */
	
	Blink_func (20); /* blink at a 4.0 second interval */
	Delay_func();  /* delay for 5 seconds */
	}
}


;======================================================================
;======================================================================

;Blink_func.a51
;routine to blink LED


NAME	Blink_FUNC

?PR?Blink_func?Blink_FUNC                SEGMENT CODE
?DT?Blink_func?Blink_FUNC                SEGMENT DATA OVERLAYABLE
	PUBLIC	?Blink_func?BYTE
	PUBLIC	Blink_func

	RSEG  ?DT?Blink_func?Blink_FUNC
?Blink_func?BYTE:
 Dly_time?040:   DS   1

	RSEG  ?PR?Blink_func?Blink_FUNC
Blink_func:

		MOV	R7,#40
BLINK:		CPL	P3.4			; blink LED using compliment instruction
		CALL 	DELAY			; Call Software delay 100mS
		DJNZ    R7,BLINK
		RET

;------------------------------------------------------------------

DELAY:					; Delays by 100ms * A


	        MOV  	A,Dly_time?040

		MOV	R0, A		; Acc holds delay variable
 DLY0:		MOV	R1,#01Ah	; Set up delay loop0
 DLY1:		MOV	R2,#0FAh	; Set up delay loop1
		DJNZ	R2,$		; Dec R2 & Jump here until R2 is 0
		DJNZ	R1,DLY1         ; Dec R1 & Jump DLY1 until R1 is 0
		DJNZ	R0,DLY0		; Dec R0 & Jump DLY0 until R0 is 0
		RET			; Return from subroutine

;======================================================================
	END

;======================================================================
;======================================================================

;Delay_func.a51
;routine delays approximately 5 seconds

NAME	Delay_FUNC

?PR?Delay_func?Delay_FUNC    SEGMENT CODE
	PUBLIC	Delay_func

	RSEG  ?PR?Delay_func?Delay_FUNC
Delay_func:

					; Delays by 100ms * A

		MOV     A,#50
		MOV	R0,A		; Acc holds delay variable
 DLY0:		MOV	R1,#019h	; Set up delay loop0
 DLY1:		MOV	R2,#0FEh	; Set up delay loop1
		DJNZ	R2,$		; Dec R2 & Jump here until R2 is 0
		DJNZ	R1,DLY1         ; Dec R1 & Jump DLY1 until R1 is 0
		DJNZ	R0,DLY0		; Dec R0 & Jump DLY0 until R0 is 0
		RET			; Return from subroutine

;======================================================================
	END



List of 39 messages in thread
TopicAuthorDate
C function with embeded ASM            01/01/70 00:00      
   You can call ASM from C...            01/01/70 00:00      
      I know nothing of Keil...            01/01/70 00:00      
         thanks            01/01/70 00:00      
      It seems to work.            01/01/70 00:00      
         Inelegant!            01/01/70 00:00      
            thanks for the article            01/01/70 00:00      
               I have certain examples available ...            01/01/70 00:00      
                  Make it public?            01/01/70 00:00      
                  Keil example            01/01/70 00:00      
                     It is a complete project with different files.            01/01/70 00:00      
                        Code library            01/01/70 00:00      
                           thanks!!!            01/01/70 00:00      
                              re;assembly language            01/01/70 00:00      
                                 ASM instructions in C            01/01/70 00:00      
                                    No, don\'t do that!            01/01/70 00:00      
                                 This is a really bad idea!            01/01/70 00:00      
                                    re;bad idea            01/01/70 00:00      
                                    re:bad idea II            01/01/70 00:00      
                                       The Best way is the C way            01/01/70 00:00      
   re: best way            01/01/70 00:00      
      Why not parameter passing?            01/01/70 00:00      
      What Compiler            01/01/70 00:00      
         re:parameter passing            01/01/70 00:00      
            Yes, but why?            01/01/70 00:00      
               re:            01/01/70 00:00      
               re:why            01/01/70 00:00      
                  Yes, But            01/01/70 00:00      
                  Parameter Passing R6, R7            01/01/70 00:00      
                     re:parameter passing using #pragma NOREGPARMS            01/01/70 00:00      
            REGPARMS/NOREGPARMS            01/01/70 00:00      
               re:NOREGPARMS            01/01/70 00:00      
                  ... and you always can use a global variable ...            01/01/70 00:00      
                     ???            01/01/70 00:00      
                        who said external???            01/01/70 00:00      
                           I            01/01/70 00:00      
                           re:??? 2            01/01/70 00:00      
                        re:???            01/01/70 00:00      
                           As long as you are aware of the issues.            01/01/70 00:00      

Back to Subject List