How to create a counter in decimal and display the counter value on LCD display?

Status
Not open for further replies.
How to create a counter in decimal and display the counter value on LCD display

Please don't create multiple threads asking the same basic questions, this has already been answered in your previous thread - check my PIC LCD tutorials.
 
I am sorry Nigel

I read your tutorial but still I have not solved the issue.

I am using 16x2 display

Please see the instruction addlw 0xF6
That allows me to count from 1 to 9

but the moment I need to count beyond 9 by changing F6 to another value

I get ascii characters on the display and not 10,11,12........

Please brother help me out on this
Following is my code:

LCD_counter:
movlw 0xCE
movwf PORTD
call SND_CMD
movf counter,0
addlw 0xF6
btfss CARRY
goto LCD2
movlw 0x31
movwf PORTD
call SND_DTA
movlw 0x30
movwf PORTD
call SND_DTA
return
LCD2:
movlw 0x20
movwf PORTD
call SND_DTA
movlw 0x30
addwf counter,W
movwf PORTD
call SND_DTA
return
 
I want to have counter that will count from 1 to 99 but it should show decimal values from 1 to 99 and not ascii

Please let me know if anyone has an idea. I would really appreciate your help

Thank you
 
The above code is only the part of program where I have implemented the counter

If you only want to count and display decimal '0' thru '9', OR the binary count with 0x30 [ 30h] to convert to ASCII.
eg:
say the binary counter value is 0x02, when OR'd with 0x30 [30h] it becomes 0x32 which is ASCII '2'

There is a conversion subroutine in Nigel's tutorials
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…