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.

Assembly example of a multistate switch

Status
Not open for further replies.

No1Daemon

Newbie level 5
Joined
Apr 15, 2011
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,388
Hi there

I am doing a project of a timer device using a PIC12F683 and I am struggling to implement code to do 2 different functions for the same switch

I have 2 switches, Switch A on GP4 and Switch B on GP5. I want it to work like this

Switch A short press call increment timer routine
Switch A pressed and held call Low voltage cutoff routine
Switch B short press call Activate timer set by Switch A routine

Can someone please help me to work this code out using either an ocerflowing timer or a flip flop method which I have read about(or another if you have an easier method)

Thanks
Steve
 

sankar.m8

Advanced Member level 4
Joined
Apr 15, 2011
Messages
106
Helped
14
Reputation
28
Reaction score
14
Trophy points
1,298
Location
Chennai, Tamil Nadu, India
Activity points
1,884
This is for the following config of switches..."When switch is activated, pin goes low". Dont forgot to add debounce delays....

loop:
btfss PORTA,1
goto short
call delay //long delay
btfss PORTA,1
goto long
btfss PORTB,1
goto activate
goto loop

short:
for short press of PORTA switch

long:
for long press of PORTA switch

activate:
for short press of PORTB switch
 

No1Daemon

Newbie level 5
Joined
Apr 15, 2011
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,388
So I can simply set up a 1 second delay as a subroutine and change PORTA etc to GPIO,4 and GPIO,5 in my case correct?

Thanks for that, I didn't realise it would be so simple.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top