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.

help with converting dt command to BCD to display on PORTB (16f84a)

Status
Not open for further replies.

Adam Yarrow

New Member
Hi people, first of all Id like to thank everyone for reading this and if you can help that's even better!
I am new to assembly and I am a little stuck on a project
firstly I want to take a table (as below)
Code:
table1 PCL,F
 dt "1234567890"
and convert each digit in sequence to BCD to display on a LED bank located at PORTB using the below lookup table
Code:
table2 PCL,F
 retlw b'11000' ;BCD for decimal 0
 retlw b'00011' ;BCD for decimal 1
 retlw b'00101' ;BCD for decimal 2
 retlw b'00110' ;BCD for decimal 3
 retlw b'01001' ;BCD for decimal 4
 retlw b'01010' ;BCD for decimal 5
 retlw b'01100' ;BCD for decimal 6
 retlw b'10001' ;BCD for decimal 7
 retlw b'10010' ;BCD for decimal 8
 retlw b'10100' ;BCD for decimal 9
so far I have managed to get the contents of table2 to display on PORTB in sequence but am a little stuck as to how to take the first value from table1, convert it to the bcd value in table2 then display it on PORTB
any help would be great, even pointing me to a tutorial, or information would be great as I have no idea where to start
Thanks in advance
 
thanks for the reply, ill have a look at those tutorials, as for the "digits" it will be a bank of 5 LEDS and led on represents a "1" read left to right
so 10100 = on, off, on, off, off

I can get the BCD to display on PORTB and cycle through the retlw commands when I call table2 directly

thanks again
 
You get the value from table 1, subtract &h30 (48) from it and use that to index into table 2.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top