Pallavipatil
Newbie level 5
Hi, I need to implement an up down counter on DS5000 board. Whne DIP34 is in up pos, with each INT1 the counter should increment and with DIP34 in down pos with each INT1 press it should decrement.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
Pallavipatil said:Whne DIP34 is in up pos, with each INT1 the counter should increment and with DIP34 in down pos with each INT1 press it should decrement. I'm completely new to asm code.
;the following ASSumes that when Int1 is pressed,
;the pin is brought low (grounded)
;also ASSumes that both P34 and P36 switches are low when UP
Int1 equ p3.2 ;not sure about this one since there is no schematic
P34 equ p3.4
P36 equ p3.6
count equ 08h
;
;here you can either check P36 or check Int1
;don't do anything if P36 is down
;I checked it below
;
Main:
jb Int1,Main ;loop until INT1 is pressed
;change to jnb if switch is high when on
;if it is pressed, wait until it is released
lcall Delay50mS ;need this for debouncing
;do a google search on "switch debouncing"
Main1:
jnb Int1,Main1 ;here we wait until the switch is released
;change to jb if switch is high when on
CheckSwitches:
jb P36,Main ;P36 off, function disabled
;change to jnb if switch is high when on
Next:
jb P34,Down ;P34 high, decrement counter, else increment counter
;change to jnb if switch is high when on
;---------------------------------------
;here you increment counter
UP:
inc count
mov a,count
cjne a,#100,UP_Exit
mov count,#0
UP_Exit:
;go write the value of count to LED here
sjmp main ;go wait for Int1 to be pressed again
;---------------------------------------
Down:
mov a,count ;check if count = 0
jz restore_count ;if it is, restore it
dec count ;else decrement
sjmp Down_Exit
restore_count:
mov count,#100
Down_Exit:
;go write the value of count to LED here
sjmp main ;go wait for Int1 to be pressed again
;---------------------------------------
I have to assume that you copied my code to your asm file. Before writing the counter value to the display you should copy the register "count" to the accumulator like so:Pallavipatil said:Hello, Sorry to bother you again, but I tried with your code also but the display doesn't work. It seems to be working fine in the debug mode. What could the problem be?
mov a,count
:00000001FF