3/7/2024 0 Comments Verilog decimal hex binaryThere are also several little optimisations that are 'PIC specific'. This is the actual statement of your problem or request. You want to convert this to an unsigned int16 You have an int16 with four BCD digits, that can have a value fromĠ000 to 9999 (in BCD). You're actually describing BCD (binary coded decimal) format. so you could store up to DEC 99 in a singe HEX byte.Īre you just trying to get ASCII _NUMBER_ inputs like from a serial com to register as decimal? or at least I've always thought you could.Īlso, you can consider using BCD which uses 4 bits per DEC digit. I'm almost certain you can print to a variable. If there are any tricks to clean this up I would greatly appreciate any direction. This works, but I am using a 16f pic, with limited memory, currently my ROM is at 90%, but commonly I am getting issues to push it over 100%. Tmp_byte = tmp_byte > 4 // shifts the 4 back to LSB to remove the 3, and give tmp_byte a value of 4 (decimal)īyte_1 += (tmp_byte) // adds 4 (decimal) to 30 decimalīyte_0 = (dataByte > 8) // gets the MSB of dataByte byte_0 = 12 (hex)īyte_0 = ((byte_0 > 4) *10 ) // now byte_0 is 10 (1 * 10) Uint8 tmp_byte = dataByte // gets the LSB of dataByte, tmp_byte = 34 (hex)īyte_1 = ((tmp_byte >4) *10) // shifts over the 3, then * 10, byte_1 = 30 (decimal) The greatest any hex number will be is 0x9. These values need to be converted from hex to decimal. dataBytes = 4 hex digits that are inputs from the user for data values. I have my code commented to what is going on. I searched the forums and found a few posts but they deal with ASCII hex, this isn't quite that. I am doing a hex to decimal converter, and it works, but I feel that I am doing it "the hard way" Send them to to decimal converter - efficiency Please do not post bug reports on this forum. CCS :: View topic - hex to decimal converter - efficiencyįAQ Forum Help Official CCS Support Search Register Profile Log in to check your private messages Log inĬCS does not monitor this forum on a regular basis.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |