EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

sample algorithm for hex2dec and dec2hex in F2812

Started by naay...@gmail.com April 23, 2008
Hi all,

Can any one have sample code to convert hexadecimal ADC result register output value to decimal output and vice versa?

If so, please send me the sample codes.

Can any one come across this issue?
Thanks in advance

regards

OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Hi Naayagi,

There's no conversion required for decimal to
hexadecimal and vice-versa. Hexa-decimal and decimal
are representations of the same number. They are just
two different formats. We also have the binary format.

The ADC of TMS320F280x and TNMS320F281x processors is
12-bit and right-justified. What this means is that
even though the result is in the 16-bit result
registers, the first 12 bits are to be used as the
converted code. The range of the ADC is from 0-3V and
the output code varies from 000h-FFFh. But the actual
result in the result register will applear as
0000h-FFF0h. You will have to right shift the result 4
times (using the >> 4 operation) and get the actual
output of the ADC.

For an ADC input of 1V, the ADC code will be (1/3)*4096 = 1365.33d. Since the processors are fixed
point, the converted code for a 1V signal will be
1365d. This could also be represented as 555h.

For an ADC input of 2V, the ADC code will be (2/3)*4096 = 2730.66d. Since the processors are fixed
point, the converted code for the 2V signal will be
2730d. This could also be represented as AAAh.

Hope this helps.

Thanks,
Vishal

--- n...@gmail.com wrote:

> Hi all,
>
> Can any one have sample code to convert hexadecimal
> ADC result register output value to decimal output
> and vice versa?
>
> If so, please send me the sample codes.
>
> Can any one come across this issue?
> Thanks in advance
>
> regards


OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Sorry, in my previous reply, I had not understand it was about ADC !
+1, I confirm you don't need !

Envoypar : c...
Pour : n...@gmail.com, c...
cc :

Objet : Re: [c28x] sample algorithm for hex2dec and dec2hex in F2812

Hi Naayagi,

There's no conversion required for decimal to
hexadecimal and vice-versa. Hexa-decimal and decimal
are representations of the same number. They are just
two different formats. We also have the binary format.

The ADC of TMS320F280x and TNMS320F281x processors is
12-bit and right-justified. What this means is that
even though the result is in the 16-bit result
registers, the first 12 bits are to be used as the
converted code. The range of the ADC is from 0-3V and
the output code varies from 000h-FFFh. But the actual
result in the result register will applear as
0000h-FFF0h. You will have to right shift the result 4
times (using the >> 4 operation) and get the actual
output of the ADC.

For an ADC input of 1V, the ADC code will be (1/3)*4096 = 1365.33d. Since the processors are fixed
point, the converted code for a 1V signal will be
1365d. This could also be represented as 555h.

For an ADC input of 2V, the ADC code will be (2/3)*4096 = 2730.66d. Since the processors are fixed
point, the converted code for the 2V signal will be
2730d. This could also be represented as AAAh.

Hope this helps.

Thanks,
Vishal

--- n...@gmail.com wrote:

> Hi all,
>
> Can any one have sample code to convert hexadecimal
> ADC result register output value to decimal output
> and vice versa?
>
> If so, please send me the sample codes.
>
> Can any one come across this issue?
> Thanks in advance
>
> regards


OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables
developers to start building applications based on the OMAP35x
architecture: http://www.DSPRelated.com/omap35x

The 2024 Embedded Online Conference