Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

10 minutes delay in pic16f877a not working

Status
Not open for further replies.

SREENATH P S

Newbie level 1
Joined
Aug 19, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Thrissur, Kerala
Activity points
1,306
iam using pic16f877a to design a automatic turn off a device after 10 mins.
delay program for 50seconds is working well.
so i programmed in such a way to call this delay function of 50sc 6 times.
but then program is not working.this is the program:
List p=16f877A ; List directive mentioning the PIC
; Microcontroller part number
#include p16f877A.inc; file having standard definitions

org 0x00 ; The address 0x00 at which the next
; next instruction 'goto' will be stored
goto start ; Go to the beginning of main program

org 0x20 ; The address at which main program starts
start

bsf STATUS,RP0 ; Choose the memory bank by setting bits
; in STATUS register
movlw 0x00 ; Move 0x00 to working register
movwf TRISB ; Move working register contents 0x00 to
; TRISB register
bcf STATUS,RP0 ; Choose the memory bank by setting bits
begin ; in STATUS register

bsf PORTB,0;turnon relay/device
call delay ; Calling subroutine
call delay ; Calling subroutine
call delay ; Calling subroutine
call delay ; Calling subroutine
call delay ; Calling subroutine
call delay ; Calling subroutine
bcf PORTB,0;turnoff relay/device
sleep

delay
movlw 0xff ; Move 0x05 to Working Register
movwf 0x23 ; Move working register contents to 0x23
loop1
movlw 0xff ; Move 0xff to Working Register
movwf 0x22 ; Move working register contents to 0x22
loop2
movlw 0xff ; Move 0xff to Working Register
movwf 0x21 ; Move working register contents to 0x21
loop3
decfsz 0x21,1 ; Decrement value in 0x21 by 1 and store to 0x21 itself
goto loop3 ; Looping back to 'loop3'
decfsz 0x22,1 ; Decrement value in 0x22 by 1 and store to 0x22 itself
goto loop2 ; Looping back to 'loop2'
decfsz 0x23,1 ; Decrement value in 0x23 by 1 and store to 0x23 itself
goto loop1 ; Looping back to 'loop1'
return ; Returns to the next line after the call command

end
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
Re: 10 imutes delay in pic16f877a not working

Hi,

Have just run your code in MPLAB SIM and as you say the first delay gives 50.005251secs delay.
However it then fails with the message the WatchDog has activated which resets the micro.

You have not specified any CONFIG parameters, watchdog being one of them which defaults to ON.

Insert this line after your Include statement and it should run ok.

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF

Note that the OSCillator is set to RC, if you are using a crystal (4meg I assume ) then it needs changing.

For more info, open up and look at these two files found in the respective folders within MPASM

Includes - pic16F877a.inc
Template - pic16f877a.temp
 

Zwilorg

Member level 5
Joined
Oct 13, 2010
Messages
89
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
1,906
Re: 10 imutes delay in pic16f877a not working

You only want asm language? i can help you if you can program in C
 

sahu

Advanced Member level 2
Joined
Oct 9, 2009
Messages
516
Helped
67
Reputation
128
Reaction score
61
Trophy points
1,308
Location
Uttar pradesh (INDIA)
Activity points
3,887
Re: 10 imutes delay in pic16f877a not working

You only want asm language? i can help you if you can program in C
can u give program in C and HEX .

---------- Post added at 15:51 ---------- Previous post was at 15:45 ----------

You only want asm language? i can help you if you can program in C
can u give program in C and HEX . I hope u do it.
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
Re: 10 imutes delay in pic16f877a not working

What kind of on/off do you require? That an output (relay or transistor or something) turns on, stays on for 2 hours, then stays off for 2 hours, then on for 2 hours and so on?
 

sahu

Advanced Member level 2
Joined
Oct 9, 2009
Messages
516
Helped
67
Reputation
128
Reaction score
61
Trophy points
1,308
Location
Uttar pradesh (INDIA)
Activity points
3,887

Zwilorg

Member level 5
Joined
Oct 13, 2010
Messages
89
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
1,906
sorry i am not having the time to help you right now.

I will get you what you want in a few hours.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top