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 > --=20 Jason White --=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 .