Author Topic: PIC18 DEC to HEX conversion in C  (Read 4842 times)

0 Members and 1 Guest are viewing this topic.

Offline RebelgiumTopic starter

  • Supreme Robot
  • *****
  • Posts: 638
  • Helpful? 0
  • It's called the future ... We like it here
PIC18 DEC to HEX conversion in C
« on: September 13, 2008, 09:23:58 AM »
Hi everyone,
Is it possible to do a DEC to HEX conversion in C language?
(Or ASM if it's not possible in C)

I googled it, but didn't get satisfying results... :/

I have a variable called "ServoPos", and after a dec to hex conversion I need to fill this value into a CCP register. (could I use a BIN value for this to? if so, a DEC to BIN conversion is also ok)
« Last Edit: September 13, 2008, 10:04:36 AM by Rebelgium »
To relax after some hard work on robotics: A very fun free online text based MMORPG
orgcrime.net

Offline MadMax

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: PIC18 DEC to HEX conversion in C
« Reply #1 on: September 13, 2008, 05:16:21 PM »
You know that every variable is stored in HEX in memory right... So, when you have (for example) TRISD, and you would assign the value 3 to it. You would be assigning the HEX value 0x03.
I came up with this link, if the above is not what you're looking for:
http://mathforum.org/library/drmath/view/54347.html

 


Get Your Ad Here

data_list