Attention to Internet Explorer users: ROHM website does not recommend browsing in IE 11. Please use latest browser to ensure the best performance on ROHM website.
I want to use a pointer to cast odd number address data to int type or long type data and read them, but I cannot do that successfully. How can I address this problem?
To cast odd number address data to int type or long type data and read them, specify a __packed modifier. This generates a code to be accessed in bytes whether or not the address is an odd or even number. An example is shown below. unsigned char ucbuf[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; unsigned int ui; ... void func(void) { ui = *(__packed unsigned int*)&ucbuf[3]; // ucbuf[3] and ucbuf[4] data are read to store 0x5544 in ui }
For the __packed modifier, refer to "11.1 How To Use __packed and __unpacked Modifiers" in "CCU8 User's Manual".