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.

Beginner Program: 5 sec delay

Status
Not open for further replies.

cadvis

Junior Member level 1
Joined
Jun 11, 2008
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,479
Hi

Thanks to all professioanls over here,

i have made this program to have 5 sec. delay to on and off LED. but it is not working properly. Any suggestion

;*******************************************************************************
;Equates

TMR0 equ 01h
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
OPTION_REG equ 81h
COUNT1 equ 08h
COUNT2 equ 09h

;*******************************************************************************
bsf 03h,5
movlw b'00010'
movwf 85h
bcf 03h,5
movlw b'00000111'
movwf 81h
movlw 01h


start xorwf 05h


call delay

goto start
delay
loopA clrf TMR0
movf 01h
sublw .160
btfss 03h,2
goto loopA
retlw 0
return

end
 

Hi,

Well for those few lines yo have a load of numbers there .. ' 03H,5 81h, 01H .160 ..... how will you go on when you have a few hunded lines of code ... ? mind blowing !

You were shown earlier how it should be done but you still persist.

Have a look at this tutorial, its a good one, and it starts off by turning a led on, then using a delay to flash the led - its a whole lot easier to follow than the code you are using - why struggle on with a totally outdated and useless method of coding - it will only confuse and frustrate you in the near future.

PIC Tutorial One - LED's
 

Hi

Thanks to all professioanls over here,

i have made this program to have 5 sec. delay to on and off LED. but it is not working properly. Any suggestion

;*******************************************************************************
;Equates

TMR0 equ 01h
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
OPTION_REG equ 81h
COUNT1 equ 08h
COUNT2 equ 09h

;*******************************************************************************
bsf 03h,5
movlw b'00010'
movwf 85h
bcf 03h,5
movlw b'00000111'
movwf 81h
movlw 01h


start xorwf 05h


call delay

goto start
delay
loopA clrf TMR0
movf 01h
sublw .160
btfss 03h,2
goto loopA
retlw 0
return

end

Write the code more neatly & specifically.
Check out the following code with slight modifications:

;Equates

TMR0 equ 01h
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
OPTION_REG equ 81h
COUNT1 equ 08h
COUNT2 equ 09h

;************************************************* ******************************
bsf 03h,5
movlw b'00000010'
movwf 85h
bcf 03h,5
movlw b'00000111'
movwf 81h
movlw 01h


start:
xorwf 05h
call delay

goto start
call delay
loopA:
clrf TMR0
movf 01h
sublw .160
btfss 03h,2
goto loopA
retlw 0

end

Also where in the code is the sub-routine for Delay? I couldn't find that.Please include that also with the code.
The modifications i have made are:

movlw b'00010'
is changed to movlw b'00000010'
start xorwf 05h
is changed to
start:
xorwf 05h.
is changed to call delay
loopA clrf TMR0
is changed to
loopA:
clrf TMR0.
retlw 0
return
is changed to retlw 0 because only 1 return is needed if the condition is true.
Do check the code & still you have doubts post it here & we'll make it solved.
Regards,
Jerin. ;-)
 
  • Like
Reactions: cadvis

    cadvis

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top