Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

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
 

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
 

Re: 10 imutes delay in pic16f877a not working

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

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.
 

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?
 


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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top