Well now, this expalianed it! sometime (nearly all the time) the simple matters are that give you the most hassle, however, I will take every bodys advise on board and try my advanture with the timer. thanky Robert:--) rgds, Aslam >From: "Robert Monsen" >Reply-To: "Microcontroller discussion list - Public." >To: "Microcontroller discussion list - Public." >Subject: Re: Re:[PIC:] Code question >Date: Mon, 30 Aug 2004 15:09:34 -0700 > >Make sure you disable the watchdog timer. When I run the below routine >under MPLAB, the watchdog goes off after about 2 seconds. > >Regards, >Bob Monsen > >----- Original Message ----- From: "Aslam Jallali" > >To: >Sent: Monday, August 30, 2004 7:04 AM >Subject: Re:[PIC:] Code question > > >>First thanks to all who reply and give valuable tips >>The essential problem in my case, however, remains, namely that the 14.8s >>delay is not equal 14.8s not even near 14.8s. To test the code on the >>actual PIC device, I made the code simpler( just include the two delay >>routine) as bellow. Neverthe less it flashes for short time (I assume >>0.2s) and eclipse for approx. 4s ( just manual counting-could be 0.5s more >>or less). I have erased the PIC, verify the earasal and reprogrammed it >>but to no avail. The program is successfully compiled MPLAB. IDE with no >>errors. I begin to suspect that probably this method is not suitable for >>long delays (I know jumping to the conclusion). ...frustrating by the way >>I tried the base time delay and called it 148 times-admittedly, the long >>way with. I will consider the For loop thanks BAJ >> >>; >> Title "LED flasher." >>; >> list P = 16F877 >>; >> include "P16f877.inc" ; use definition file for 16F877 >>; >>; -------------------- >>; USER RAM DEFINITIONS >>; -------------------- >>; >> CBLOCK 0x20 ; RAM starts at address 20h >>d1 >>d2 >>d3 >> >> ENDC >>; >> org 0x0000 ; start address = 0000h >> >>; INITIALISE PORTS >>; binary used to see individual pin level >> >> movlw b'00000000' ; all port pins = low >> movwf PORTA >> movlw b'00000000' >> movwf PORTB >> movlw b'00000000' >> movwf PORTC >> movlw b'00000000' >> movwf PORTD >> movlw b'00000000' >> movwf PORTE >> >> bsf STATUS,RP0 ; set RAM Page 1 for TRIS registers >> >>; INITIALISE PORTS >>; binary used to see individual pin IO status >> >> movlw b'00000000' ; all IO pins = outputs >> movwf TRISA >> movlw b'00000000' >> movwf TRISB >> movlw b'00000000' >> movwf TRISC >> movlw b'00000000' >> movwf TRISD >> movlw b'00000000' >> movwf TRISE >> >> movlw b'00000110' ; all analog pins = digital >> movwf ADCON1 >> >> bcf STATUS,RP0 ; back to RAM page 0 >> >>; LED FLASH LOOP >> >>Loop bcf PORTC,7 ;RC6 & Rc7 are connected to inputs "c" and "D" >>bcf PORTC,6 ;of the decoder,if both Low, decoder's o/p No.1 =Low >>call Delay_0.2s ;LED = ON for 0.2s >> >>bsf PORTC,7 ;RC6 & Rc7 are connected to inputs "c" and "D" >>bsf PORTC,6 ;of the decoder,if high, decoder output invalid >>call Delay_14.8s ;LED = OFF for 14.8s >> >> goto Loop >> >>; DELAY SUBROUTINES WITH 4MHz CLOCK >> >>Delay_0.2s movlw 0x3F >>movwf d1 >>movlw 0x9D >>movwf d2 >> >>Delay_0.2 decfsz d1, f >>goto $+2 >>decfsz d2, f >>goto Delay_0.2 >> >>;2 cycles >>goto $+1 >> >>return >> >>Delay_14.8s >>movlw 0xED >>movwf d1 >>movlw 0x43 >>movwf d2 >>movlw 0x21 >>movwf d3 >>Delay_14.8 >>decfsz d1, f >>goto $+2 >>decfsz d2, f >>goto $+2 >>decfsz d3, f >>goto Delay_14.8 >> return >>end >> >>_________________________________________________________________ >>STOP MORE SPAM with the new MSN 8 and get 2 months FREE* >>http://join.msn.com/?page=features/junkmail >> >>_______________________________________________ >>http://www.piclist.com >>View/change your membership options at >>http://mailman.mit.edu/mailman/listinfo/piclist >> > > >_______________________________________________ >http://www.piclist.com >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist