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.

accessing memory location in PIC16f887

Status
Not open for further replies.

charu2539211

Junior Member level 3
Joined
Jul 22, 2013
Messages
31
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
200
Hi

i am writing a code for pic 16f887 in assembly language which has to count how many times the porta0 is switched on and set the respective port to indicate it

loop:
first time a0=1 => b0=1
second time a0=1 => b1=1
third time a0=1 => b2=1
fourth time a0=1 => goto loop

when a0=0
portb= ffh

i tried it by myself, but only b0 is getting set every time i switch on a0.
can anyone suggest a proper alogrithm code it??
 

charu2539211

Junior Member level 3
Joined
Jul 22, 2013
Messages
31
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
200
where should i add the delay???

- - - Updated - - -

can u write an algorithm for this??
 

Joined
Dec 4, 2012
Messages
4,294
Helped
822
Reputation
1,654
Reaction score
793
Trophy points
1,393
Location
Bangalore, India
Activity points
0

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
if(a0 pressed){
    delay of 50 ms()
    if(a0 pressed){
        shift++;
            
    }
}
 
if(shift < 4)b = b<<shift;  //b is assumed as PORTB
else {shift = 0; b = 0;}

 

charu2539211

Junior Member level 3
Joined
Jul 22, 2013
Messages
31
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
200
i am using a push button. so each time i press and release the button, it has to select the appropriate bit to be set... how can i code this??
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top