Glad you got it worked out! I typically do this as a union of the UINT32 and a UINT8 array. This DOES rely on the endianness of the processor, so it's not completely portable. But I think it makes pretty clean code. Harold > Awesome, you guys nailed it. > > (((uint32_t)=E2=80=99D=E2=80=99) << 24) does the trick. > > Thanks > > justin > > On 11 August 2018 at 20:37, Michael Graff wrote: > >> I believe you want to cast the characters. Example, from memory vs >> trial: >> >> (((uint32_t)=E2=80=99D=E2=80=99) << 24) >> >> The problem seems to be when the arduino 16-bit compiler promotes the >> char >> to its longest natural integer size, which is 16 bits. The ESP handles >> 32 >> bit into natively so chars become the desired length automatically. >> >> On the arduino, without casting the target of the shift to a long enough >> size manually, it basically shifts all the bits off the end and becomes >> zero. There=E2=80=99s probably a warning about this in your compile logs= .. >> >> --Michael (from an iPhone) >> >> >> > On Aug 11, 2018, at 7:09 AM, Jason White > gmail.com> wrote: >> > >> > Method A: Cast each of the characters to uint32_t and be sure to >> completely >> > surround the casted value in parentheses. >> > >> > Method B (probably better in my opinion): structure , union, or even >> just >> > an array of uint8_t. >> > >> > On Saturday, August 11, 2018, Justin Richards >> > > >> > wrote: >> > >> >> Probably best posed in an arduino forum but hoping someone could pick >> an >> >> obvious mistake, steer me in the right direction or suggest a better >> way. >> >> >> >> I have generally avoided the << and >> operators but I thought they >> would >> >> be ideal to pack a 32bit variable with commands. >> >> >> >> So trying this >> >> >> >> uint32_t ds =3D ('D'<<24)|('C'<<16) |('B'<<8)|('A'); >> >> >> >> when compiled for an ESP8266 target in arduino IDE and printed gives >> >> >> >> 0x44434241 as expected. >> >> >> >> when the target is UNO it produces >> >> >> >> 0x4241 >> >> >> >> Doing this >> >> >> >> uint32_t ds =3D 'D'; >> >> ds =3D (ds << 8)| 'C'; >> >> ds =3D (ds << 8)| 'B'; >> >> ds =3D (ds << 8)| 'A'; >> >> >> >> for either target works ok. >> >> >> >> I have tried type casting (not sure that is the right phrase) like >> >> >> >> uint32_t ds =3D uint32_t('D'<<24)|uint32_t('C'<<16) >> >> |uint32_t('B'<<8)|uint32_t('A'); >> >> >> >> But no joy for the uno target. >> >> >> >> The final goal is to construct SPI commands with a esp8266 master >> with a >> >> UNO slave. >> >> >> >> The following compiles and works fine for the esp8266 target but has >> the >> >> issues mentioned above for the UNO target. >> >> >> >> #define UNO1_ADDR uint32_t(uint32_t('U')|uint32_t('1'<<8)) //Address >> UNO1 >> >> #define cmdREADPIN uint32_t(UNO1_ADDR | uint32_t('R'<<16)) >> >> #define cmdWRITEPIN uint32_t((UNO1_ADDR | uint32_t('W'<<16)) >> >> #define cmdREADPIN1 uint32_t(cmdREADPIN | uint32_t('1'<<24)) >> >> #define cmdREADPIN2 uint32_t(cmdREADPIN | uint32_t('2'<<24)) >> >> #define cmdREADPIN3 uint32_t(cmdREADPIN | uint32_t('3'<<24)) >> >> >> >> Any tips? >> >> >> >> Justin >> >> -- >> >> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >> >> View/change your membership options at >> >> http://mailman.mit.edu/mailman/listinfo/piclist >> >> >> > >> > >> > -- >> > Jason White >> > -- >> > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >> > View/change your membership options at >> > http://mailman.mit.edu/mailman/listinfo/piclist >> >> >> -- >> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 FCC Rules Updated Daily at http://www.hallikainen.com Not sent from an iPhone. --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .