0

I need to convert a DWORD into 4 bytes to send to serial RAM. All the examples of using SPIRAM, EEPROM and FLASH use *variable to send and receive. I can break the DWORD down into bytes which I stuck in a char[3]. I don't, apparently even with all my books and Google, know how to convert to a *variable. How is this done?

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by Ancient Dragon
0

I always copied it into an unsigned char 4-byte buffer

DWORD dwValue = 123;
unsigned char buf[sizeof(DWORD)];
memcpy(buf,&dwValue, sizeof(DWORD);

Or you could just typecast a pointer
unsigned char* ptr = (unsigned char*)&dwValue;

Edited by Ancient Dragon

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.