Hi everyone,

Hope you are all doing very well. I have run into a new problem with this project I am working on...

Currently, I get data in the following format across my UART communication:

g_Uart1RxData[0] = "1"
g_Uart1RxData[1] = "2"
g_Uart1RxData[2] = "3"
g_Uart1RxData[3] = "4"
g_Uart1RxData[4] = "5"

I am now required to split this array and form the following:

EEPROM_addr1 = "0x01"
EEPROM_addr2 = "0x23"
EEPROM_data = "0x45"

Any ideas on how I could get this to work?

Kind Regards,

This is what I had in mind:

i2c20_ID[0] = g_Uart1RxData[0];
i2c20_ID[1] = g_Uart1RxData[2] | (g_Uart1RxData[1] << 4);
i2c20_ID[2] = g_Uart1RxData[4] | (g_Uart1RxData[3] << 4);

but this does not seem to work correctly... if I do this:

i2c20_ID[0] = 0x01;
i2c20_ID[1] = 0x03 | (0x02 << 4);
i2c20_ID[2] = 0x05 | (0x04 << 4);

it works perfectly :)

PS: both arrays are of type char

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.