You must generate the 21 registers UNLESS you are sure that two different delays are not executed at the same time. I mean: You call Delay1 Delay1 calls delay2 ---> You need different registers for delay1 and delay2 You call Delay1 You call Delay2 ---> You can use the same registers for both delays. $+2 means (Current Address + 2) Mauricio Jancic Janso Desarrollos Microchip Consultant Program Member (54) 11-4542-3519 info@janso.com.ar www.janso.com.ar >>-----Original Message----- >>From: pic microcontroller discussion list >>[mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Aslam Jallali >>Sent: Wednesday, August 25, 2004 3:45 PM >>To: PICLIST@MITVMA.MIT.EDU >>Subject: [PIC:] code question >> >>Hello to you >>Using the delay generator from >>I have generated 21 different delay routines. (I need these >>for different LED flash sequences). The question is: do I >>need to define 21 different temporary registers in CBLOCK? >>i.e. see below please. What is $+2? In the manual it says >>return program counter (see my comment beside the code line) >>I appreciate your input & advice on this one ;-) Regards >> >> >>CBLOCK 0x20 ; RAM starts at address 20h >>D1 >>D2 >>D3 >>. >>. >>. >>D21 >>ENDC >> >>Follwoing are the two example and then the third one is that >>I merge them. >>; Delay = 0.2 seconds >> cblock >> d1 >> d2 >> endc >> >> ;199998 cycles >> movlw 0x3F >> movwf d1 >> movlw 0x9D >> movwf d2 >>Delay_0 >> decfsz d1, f >> goto $+2 ; Does this mean go two lines >>back (delay_0)? >> decfsz d2, f >> goto Delay_0 >> >> ;2 cycles >> goto $+1 >> >>; Delay = 0.4 seconds >> cblock >> d1 >> d2 >> d3 >> endc >> >> ;399999 cycles >> movlw 0x36 >> movwf d1 >> movlw 0xE0 >> movwf d2 >> movlw 0x01 >> movwf d3 >>Delay_0 >> decfsz d1, f >> goto $+2 >> decfsz d2, f >> goto $+2 >> decfsz d3, f >> goto Delay_0 >> >> ;1 cycle >> nop >> >>; delay for 0.2 and 0.4 can I call form this code upon delay >>0.2s or ; ; 0.4s or if I add more into it >> >> cblock >> d1 >> d2 >> d3 >> d4 >> d5 >> >> endc >> >>delay_0.2s ;199998 cycles >> movlw 0x3F >> movwf d1 >> movlw 0x9D >> movwf d2 >>Delay_0.2 ; note 0.2 and 0.2s >> decfsz d1, f >> goto $+2 >> decfsz d2, f >> goto Delay_0.2 >> >> ;2 cycles >> goto $+1 >> >>delay_0.4s ;399999 cycles >> movlw 0x36 >> movwf d3 >> movlw 0xE0 >> movwf d4 >> movlw 0x01 >> movwf d5 >>Delay_0.4 >> decfsz d3, f >> goto $+2 >> decfsz d4, f >> goto $+2 >> decfsz d5, f >> goto Delay_0.4 >> >> ;1 cycle >> nop >> >>_________________________________________________________________ >>MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. >>http://join.msn.com/?page=features/virus >> >>-- >>http://www.piclist.com hint: The list server can filter out >>subtopics (like ads or off topics) for you. See >>http://www.piclist.com/#topics >> -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics