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??
 

where should i add the delay???

- - - Updated - - -

can u write an algorithm for this??
 


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;}

 
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

Cookies are required to use this site. You must accept them to continue using the site. Learn more…