??? 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 |