ARM

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

ARM

Post by wayne millard »

Hi everybody

Has any one got away of converting a decimal number to hex for ARM its got to convert small numbers and large numbers. ie upto 30000

Thanks
Wayne

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times

Re: ARM

Post by Spanish_dude »

if you want to convert a decimal value (int) to hex (string of 4 chars) you could do something like this :

Code: Select all

char dummy_var = 0;
int decimal_value;
char hex_string[5] = {0};

for (i = 0; i < 4; i++)
{
    dummy_var = (decimal_value >> (12 - 4 * i)) & 0x0F;

    if (dummy_var < 10)
        hex_string[i] = dummy_var + '0';
    else
        hex_string[i] = (dummy_var - 10) + 'A';
}

This "dummy_var = (decimal_value >> (12 - 4 * i)) & 0x0F;" should write each nibble in dummy_var, starting from the highest nibble to the lowest one.

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM

Post by wayne millard »

Hi Spanish Dude,

i calculate a number of counts in 1us and then need to load this into
the timer in hex

how do i pass a Flowcode Variable number to your maths.
And what is the output called is it Hex string?

Thanks
Wayne

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM

Post by wayne millard »

Sorry,

What i need to do is have a decimal number then * 0x18 to load into timer overflow register.

Thanks
Wayne

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ARM

Post by Benj »

Hello Wayne,

You can just do it in decimal if you like. Its all the same to the uC so it doesn't matter if your using hex, binary or decimal.

0x18 is 24 in decimal.

EG

5 * 0x18 = 120
is the same as
5 * 24 = 120

And

register = 0x78
is the same as
register = 120

Hope this helps.

The Windows Calculator (calc.exe) allows you to switch between hex, decimal and binary in "programmer" mode.

Post Reply