Page 1 of 1

BSF command will not work as it should HELP

Posted: Wed Jan 11, 2017 1:03 am
by chloe4479
with a great deal of help from Martin medelec35

we have come stuck on a simple command that is not doing what it should, so im asking if anyone else could shed some light on to this for me please

I using the EB006v9 board with the pic16f1937 that come with it
uisng pic basic assembly NOT FLOWCODE

I have a program that lights up portb leds in order from portb 0 to 7 then repeats.

It's meant to light them up in order and keep the last led lit showing all 8 lights lit at the end then repeat all over again

The program is very simple just using the bsf command, However when we run the program on the board, the port b led comes on 1 by 1, like the knight rider, however portb 0 comes on then portb 1 comes on but turns off portb 0 led this should not be happening

why are the led's turning off during the sequence??

See attached e03 v2 asm

I then modified the program completely removing the bsf command And instead added the Movlw command Now the program does what it should do,

Attached is the sequence asm file

My question is why is the simple bsf command not doing what it should The leds are turning off by themselves, there is no bcf command We are at a loss. Please help

chloe

Re: BSF command will not work as it should HELP

Posted: Wed Jan 11, 2017 1:50 am
by kersing
You are directly writing to the output port, however you should be writing to the LATCH for the port. (LATB in your case), check this document for an explanation. (A led connected to a pin will drain a charge rapidly)

Re: BSF command will not work as it should HELP

Posted: Wed Jan 11, 2017 2:30 am
by chloe4479
Hi kerbing

Could u please show me the code I need to enter please
I am a beginner to this,
And that would help a great deal

Thanks

Chloe

Re: BSF command will not work as it should HELP

Posted: Wed Jan 11, 2017 9:55 am
by kersing
LATB is at the same memory position PORTB is at, only in bank 2. So you need to add

Code: Select all

#DEFINE   PAGE2  MOVLB 2
next to the other definitions and where you use bsf you need to add PAGE2 before it and PAGE0 after. Or consider moving COUNT to page 2 memory location 20 as well so you can switch to page 2 at the start of the code and stay at that page (after initializing the clock etc)
To get the addresses for registers you can check the data sheet of the micro controller. Page 31 lists all registers.

Re: BSF command will not work as it should HELP

Posted: Wed Jan 11, 2017 10:43 am
by chloe4479
hi C.S. Lewis

Thanks so much for that info and that documentation

yes that should be available in all tutorials, i think matrix should give this out with every board, very useful information inded

I have the project now working using the LATB register, something i did not even know about or how to use, so thanks
the good thing with forums is you learn alot.

the pic16f1987 is new to me, i am a beginner, and its fun making mistakes to learn what went wrong but frustrating too

Thanks
Chloe

Re: BSF command will not work as it should HELP

Posted: Wed Jan 11, 2017 12:35 pm
by Steve
Please see here for an update to this issue:

http://www.matrixtsl.com/mmforums/viewt ... 165#p79165