Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top