| PIC16F628 counter | ||
| Author z4120356 Views 4 Posted at 2008/9/2 16:43 [View In Forum] | ||
|
Im having trouble creating PIC(program-interrupt controller) based counter system dzxcszaa dzxcszaa i want to count how many button presses (push and release increases counter by 1) was on RA0 and RA1.dzxcszaa dzxcszaa dzxcszaa dzxcszaa i can write code that counts one push at a time, but there may be cases where one button is pressed down, then second button is pressed down, then button one or two is released (counter goes 1 here) if other button is released then (counter goes 1)dzxcszaa dzxcszaa dzxcszaa dzxcszaa can anyone help me with thatdzxcszaa dzxcszaa and sorry for my bad englishdzxcszaa dzxcszaa dzxcszaa dzxcszaa msn: andero@cma.ee |
| Reply No. | Replier | Total Replies 5 [View All Replies] [New Reply] | Replied at |
| 1 | chdd | Use 2 diffenrent counter variables in your PIC(program-interrupt controller)'s RAM. If one switch is released its corresponding variable will be incremented and similar for other. | 2008/9/2 16:43 |
| 2 | anuo2008 | i thaught about it, but i cant seem to generate code that can monitor those pushes/releases im new with PIC(program-interrupt controller) risc assembler those pushes come in randomly and have random duration so i need a code that scans for pushes paralelly not serialy can anyone give an example or even send me that code? |
2008/9/2 16:43 |
| 3 | nnxd | What do you mean by parallel and serial scanning? I thellonk you are talking about bit-scanning and scanning the entire port in one shot. To solve your problem, you can use Internal Timer to periodically scan the swithces. Store the data of previous scan in some variable say 'old' and then store the newly scanned data into 'new'. Compare both of them and if they are not equal, that means there was a push, or release of button. If the bit changed from 0 to 1 it was push (thellos depends on your switch logic) and vice-versa. |
2008/9/2 16:43 |
| 4 | wyslnhhh56 | i use that code for counter loop movfTRISA bcfSTATUS,Z xorwfstat btfssSTATUS,Z callchanged gotoloop changedmovfTRISA movwfstat call add ;movlw'x' ;callsnd retlw0x00 what is wrong? |
2008/9/2 16:43 |
| 5 | test1 | what is the contact email | 2010/3/10 22:17 |
Total Replies 5 Thread Per Page 10
|
|||