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.

please advice for pic 16f877

Status
Not open for further replies.

dayanpad

Advanced Member level 4
Joined
Mar 23, 2009
Messages
114
Helped
17
Reputation
34
Reaction score
17
Trophy points
1,298
Location
Colombo
Activity points
1,921
I used bit wise command, so it works well in simulator but does not in pic (16f877)


command is

movlw b'00000001'
movwf portd
loop rlf portd,1:?:
call delay
btfss portd,1
goto loop
return

( just blink only bit one of portd ) it does not shift please advice
 

Just to clarify your objective:

You have LEDs on all of Port D lines.

You're trying to shift the lit LED from RD1 to RD2 to RD3 to .....

If this is correct then:

btfss portd,1

continuely tests on bit 1 of Port D, which after the first iteration it is set to 1, therefore it jumps over the 'goto loop' ending the program.

BTFSS means: Do a bit test in the register and bit we specify. If it is set to a 1, then we skip the next instruction.

Why test Port D at all, just have it loop continuously? After the first pass the code with start back at RD1.

Hope this helps.
 
Last edited:
Dear bigdogguru,

yes I need first D0 next D1 next D2 --------- D7. I used btfss to shift to portc, no code here
my problem is it dose not happened with rlf or rrf command later I done it using table but I need using bit wise commands. please advice
 

According to your code it looks like it lights D1 and then ends. Is this correct?

---------- Post added at 08:53 ---------- Previous post was at 08:50 ----------

Try this code:

movlw b'00000001'
movwf portd
loop call delay
rlf portd,1
goto loop
return

I'm a little rusty with PIC assembly, so if I make a mistake forgive me.

Let me know the results.
 
Dear bigdogguru,
thanks your prompt reply
I did it, still same just portd 0 led will lite on and off never on
 

I'll have to breakout my testbed and run the program. In the mean time checkout this link I found with a project almost exactly like yours:



It's getting close to 3AM here, so I'll have to get back with you tomorrow after I run a couple of tests.

Thanks for the helpful post ratings by the way.

---------- Post added at 09:42 ---------- Previous post was at 09:37 ----------

Aftering looking over the link, I noticed he disabled the watchdog timer:

If you comment out, or remove the CLRWDT command, you will find that the PIC will not go past lighting the second LED. This is because the WDT is resetting the PIC. With the CLRWDT in place, the program works as it should.

Make sure you sisable the Watchdog Timer, reassemble and rerun.

---------- Post added at 09:44 ---------- Previous post was at 09:42 ----------

Watchdog Timer disable routine:

OPT equ 81h ; Option Register to control the WDT
;*************Set up the ports, WDT and prescaler******************
clrf 01h ;Clear TMR0
bsf STATUS,5 ;Switch to bank 1
clrwdt ;reset the WDT and prescaler
movlw b’1101’ ;Select the new prescaler value and assign
movwf OPT ;it to WDT
 

Dear bigdogguru,
thanks for rely
I cleared WDT
here all codes
status equ 0x03
portd equ 0x08
trisd equ 0x88

delay_1 equ 0x20
delay_2 equ 0x21
delay_3 equ 0x22
INCLUDE "p16f877.inc"
org 0x000
start clrwdt
call sys_init
goto main

main call sys_one

goto main


sys_one movlw b'00000001'
movwf portd
loop ;call delay
rlf portd,1
goto loop
return

delay movlw 0xff
movwf delay_1
s1 decfsz delay_1
goto delay1
return

delay1 movlw 0xff
movwf delay_2
s2 decfsz delay_2
goto s2
goto s1

sys_init bsf status,5
movlw 0x00
movwf trisd
bcf status,5
clrf portd
return


end
 

Mkae sure you disable the watchdog timer when you complie the code, otherwise the code will keep restarting.


In mplab menu -> Configure Menu -> Configuration bits or at the start of your code set up __config
 
Last edited:
Mkae sure you disable the watchdog timer when you complie the code, otherwise the code will keep restarting.


In mplab menu -> Configure Menu -> Configuration bits or at the start of your code set up __config


Dear cubanflyer
thanks for reply
I did it well
but problem remaining same
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top