Newbi BCD question
w4fej
Posts: 264
I'm just switching over to the prop from the BS2 world and I have been playing with the Prop Pro board (Love that piece of hardware, wish I had purchased one for the BS2 back in the day).
I am tryng to read a two digit BCD thumb wheel switch that will be my "keyboard" for making choices in my current project. I setup the PPDB to read the 8 dip switches hooked up to P0..P7. Using "INA" and outputting the info to a 2 line serial display. All works ok. In the BS2 you can define a "nibble" of four bits, one for each of the digits and then use the two variables to display the digits.
Using the INA method I am outputting the INA using fullduplex serial TX.DEC which works but is showing the 8 bit value. Due to lack of experience with the prop I can't figure out a clean way to get the two four bit groups seperated out to use as a two digit BCD quanity. There must be a better way that escapes me.
Anyone care to enlighten me??
Than you, Mike B.
I am tryng to read a two digit BCD thumb wheel switch that will be my "keyboard" for making choices in my current project. I setup the PPDB to read the 8 dip switches hooked up to P0..P7. Using "INA" and outputting the info to a 2 line serial display. All works ok. In the BS2 you can define a "nibble" of four bits, one for each of the digits and then use the two variables to display the digits.
Using the INA method I am outputting the INA using fullduplex serial TX.DEC which works but is showing the 8 bit value. Due to lack of experience with the prop I can't figure out a clean way to get the two four bit groups seperated out to use as a two digit BCD quanity. There must be a better way that escapes me.
Anyone care to enlighten me??
Than you, Mike B.
Comments
TX.DEC( INA[0..3] )
TX.DEC( INA[4..7] )
Maybe you have to use [3..0] and [7..4] intead. I did not use this to often so far and don't remember which direction is the right one.
Another way would be
TX.DEC( INA[0..3]*10+INA[4..7] ) which would remove the leading zero. (again maybe [3..0] ...)
Dohhh... Ok, thanks. didn't occur to me to output the INA that way. Off to try that with my tail between my legs... lol.