In , out and cmp
Brian_B
Posts: 842
I'm trying to read 3 switches on pins 0,1,2 and display results on pins 4,5,6· . any suggestions on my code ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
spin
685B
Comments
·Changed it and it's still not working.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
The way the code is written, one and only one switch (I/O pins 0-2) at a time should be connected to Vdd and the others have a pulldown.
The LEDs (I/O pins 3-5) should be connected from an I/O pin through a series resistor to ground. 3 LEDs on = pin 0 on, 2 LEDs (pins 3-4) on = pin 1 on, 1 LED (pin 3) on = pin2 on
This program works fine for reading a pin and displaying results.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
Clever code. Very nice!
Jim C
·Thanks
Mike ,
·Heres how my LEDS and pushbottons are hooked up , still trying to get the CMP code to work. Also I am trying to light up 1 led ,2 leds and 3 leds .
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
Post Edited (Brian Beckius) : 5/31/2007 11:56:47 AM GMT
·Heres another chunk of code thats giving me grief· , this one is to suppose to inca djnz·the 6 leds and then start over .·But instead it·turns all leds on and waits 10 minutes to start . Is this a mask issue also ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
Post Edited (Brian Beckius) : 6/1/2007 2:33:23 AM GMT
So it loads outa with 111111000 and then gets the waitcnt where it misses the time and then sits until it comes around again. So you need to add delay to time not 9.
And rather than doing
mov outa,testpin
you might consider doing
or outa, testpin
That way if you are doing something with any of the other pins in a different part of the code you won't effect them because remember 111111000 is really:
0000000000000000000000111111000
That may be the point you are missing and why you are not sure when to use a mask.
Graham
I meant djnz not inca . Changed 9 to 255 , works great
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
Just so I have my brain fully wraped around waitcnt.
· CLOCK
12_000_012
12_000_013······' Mov time,cnt
12_000_014······ 'add· time,#9
12_000_015······ 1
12_000_016······ 2
12_000_019······ 3
12_000_020······ 4.....8
12_000_025···· 9·······' stop what your doing and wait 6_000_000 clock ticks
18_000_025······ ' quit sitting around and get moving
delay···· long····· 6_000_000
So by adding 9 to the time ,you need to make sure that the instructions your trying to exacute don't take longer than 9 clock ticks ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
Post Edited (Brian Beckius) : 6/1/2007 1:30:32 AM GMT
Graham
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian
www.truckwiz.com
·"Imagination is more important than knowledge..." ·· Albert Einstein
http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)