In the 8-bit MCU, there is no 16-bit operation instruction. All int data must be operated separately by two bytes. The used method is not used, and the generated code is different. Of course, the efficiency is not the same. The number of bits can be manipulated to get efficient code.
For example, receiving data through a serial port, or reading data from a serial EEPROM, or reading data from an A/D greater than 8 bits, since the data line of an 8-bit microcontroller is 8-bit, higher than 8 bits. The data must be read into two bytes, then written to RAM for calculation, or 16-bit int data can be read from RAM and stored in EEPROM or sent to D. /A, or send out through the serial port, there are many ways, the following ways to achieve this operation, only the case of writing to 16-bit, the reading is very similar, not to repeat.
(1) Use union (union)
Typedef union{ unsigned int i; unsigned char c[2]; }u_int; unsigned char dH = 0x11, dL=0x22; unsigned int d; u_int ud; ud.c[0] = dH; ud.c[1] = dL; d = ud.i; at this time d = 0x1122;
(2) Using the shift instruction
The data definition is the same as d * ((unsigned int)dH) or d = dH; dd |= dL; // or: d = d | dL; the latter compiled code may not be the simplest
(3) using pointers
Unsigned char *cptr; cptr = (unsigned char*)(&d); cptr[0] = dH; cptr[1] = dL;
(4) Force pointer type conversion
*((unsigned char*)(&d)) = dH;*((unsigned char*)(&d)+1) = dL; or ((unsigned char*)(&d))[0] = dH;((unsigned Char*)(&d))[1] = dL;
These two methods seem to be the same but the code compiled by Keil is not used. There is an addition before the latter, but the latter does not. The latter generates more simple code, which is exactly the same as the code used to join the students. of.
Among the above methods, the second generated code of (1) and (4) is the most convenient and recommended. From the perspective of software engineering, it is recommended to use the method (1). Type conversion, no pointers are used, and it is less prone to errors. From the written code, the second method of (4) is the best, the code is simple and efficient, but the syntax is a bit complicated.
Product catagories of stylus pen for ipad, which is just for iPad Versions 2018 & 2019 and above.
It can work on following:
iPad 6th 2018: A1893/A1954
iPad 7th 2019: A2197/A2198/A2200
iPad 8th 2020: A2270/A2428/A2429/A2430
iPad air 3rd: A2152/A2153/A2154/A2123
iPad Air 4th: A2072/A2316/A2324/2325
iPad mini 5th: A2124/A2125/A2126/A2133
iPad Pro 1st/2nd 11: A1980/A2013/A1934/A1979/A2228/A2068/A2230/A2231
iPad Pro 3rd/4th 12.9: A2069/A2229/A2233/A2232/A1876/A2014/A1895/A1983
Stylus Pen For Ipad,Stylus Pen,Stylus Pen For Drawing,Touch Pencil
Shenzhen Ruidian Technology CO., Ltd , https://www.wisonens.com