PDA

View Full Version : ones tens hundreds counter to eliminate and up/down counter[ASM]



Trickae
- 27th September 2007, 17:43
I have a speed alert code which i need to modify with 3 extra push buttons (Used on a PIC16F886) - A ones, tens and hundreds placeholder to input the speed limit

Would you think it would be viable to have both a three button input and an up down input? If not how would i replace the up down counter with these three buttons.

If i keep the up down buttons - How could I add the ones, tens and hundreds placeholder buttons ontop of this? I will be using PORTC - (excluding PIN17 and PIN18 NEEDED FOR EUARTS (RC6 and RC7))

so I'm thinking i'll do the following



STATUS equ 03h
TRISA equ 87h
PORTC equ 07h

bsf STATUS,5
movlw 03h ; RC0,RC1, RC2 = inputs
; (Hundreds,Tens,Ones)
movwf TRISC
bcf STATUS,5




Register map is included here
http://img511.imageshack.us/img511/1430/registermapic16f886ua5.jpg

(i'll play with RC6 and RC7 once i read up on EUSARTS )


I was planning on having a temp variable - templimit such that I can store the actual speed limit in it as follows:

templimit = (hundreds*100)+(tens*10) + ones.
This would set the speed limit then I'd use the serial EUSART to overwrite this if it needs to be automatically updated.

the locations for the up/down counter is:
*Polling for
- down button: Line 863
- up button: Line 869
* incrementing the speed
- line 925
* decrementing the speed
- line 936


Any help - whether theory or advice would be highly appreciated.

Archangel
- 27th September 2007, 20:15
Hi Trickae,
look at this thread: http://www.picbasic.co.uk/forum/showthread.php?t=3423