![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi I cant seem to work out how to increment a registry value from 0 to 24 and then have this registry reset to 0 and to display this on a lcd screen. What im trying to do is to enter a time into a pic to be compared for an alarm, the problem I have is as I press the button to increment the time the display goes from 0 - 9 then through the whole ascii code. Any help would be appreciated john | |
| |
| | #2 |
|
What language are you programming it in and wich pic? But you have to convert your HEX code to a BCD code, there are examples galore of that around here I bet.
__________________ There are no stupid questions, but PLEASE, think twice before asking them | |
| |
| | #3 |
|
Sorry I forgot to put I right in assembly and pic 16f877 I can do the bcd to hex conversion but my problem is getting the value to stop at 24 and then reset to 0 at the next button press Last edited by johnl69; 13th November 2008 at 08:05 PM. | |
| |
| | #4 |
|
Euhm, long time since I worked in asm for pics, but do they have a compare function? Or else you could decrement a register every time you increment and when that hits 0 you can do whatever... BTFSZ i believe that was?
__________________ There are no stupid questions, but PLEASE, think twice before asking them | |
| |
| | #5 |
|
To reset the count back to zero if "reg" increments higher than 24: Code:
incf reg,F ;Inc the reg
movlw D'25' ;load with 25 to check against reg
xorwf reg,W ;Xor but dont affect the reg yet
btfsc STATUS,Z ;Skip if not 25
clrf reg ;Reached 25 so set reg back to 0
movf reg,W ;Get the new value of reg into w to send to your display
| |
| |
| | #6 |
|
btfsC it was appearantly ![]() xor'ing it will work too I guess, and then when they are equal, the Z flag gets cleared or something? Pff i need to get back into my PicASM, it's all 8051 at our school now, and there are WAYY too many instructions, wich is nice too mind you, but a risc is a little different eh :d
__________________ There are no stupid questions, but PLEASE, think twice before asking them | |
| |
| | #7 |
|
Shouldn't you be counting from 0 to 23 or 1 to 24. Counting from 0 to 24 will result in a 25 hour day!! Mike. | |
| |
| | #8 |
|
Thanks alot guys for your help, ![]() ![]() Pommie, Yes it should be 0 - 23 and then 0 - 59 but it was late and I was still feeling the effects from the anastetic | |
| |
|
| Tags |
| incrementing, reset |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Reset | chandu13 | Micro Controllers | 7 | 9th March 2007 11:14 PM |
| Why my MCU get reset ? | manish12 | Micro Controllers | 6 | 24th October 2006 06:59 PM |
| incrementing and decrementing less than "1" | lompa | Micro Controllers | 6 | 15th January 2005 12:26 AM |
| on/off set/reset please help | svtiss | General Electronics Chat | 11 | 2nd November 2004 01:56 PM |
| Power-On Reset & Brown-Out Reset | hantto | Micro Controllers | 5 | 31st August 2004 12:14 PM |