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
 
A quick look through Nigel's tutorials may give you a little boost... There is a link in my signature...

I can't seem to imagine how the 5 PORTB pins will represent the digits!!!
 
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…