2023-01-12 07:37 PM
2023-01-12 07:57 PM
The error is likely to be in the context. If you could post the code and the error, it'll save guessing, and most likely, you'll also get some suggestions, e.g. about unions, that'd save code and cycles.
2023-01-12 08:00 PM
#include <stdint.h>
2023-01-13 07:19 AM
Great Alister .... thanks ... i already included stdio.h stdlib.h & maths.h its's started working . i think stdint.h inclusion also additional help .
2023-01-13 06:01 PM
2023-01-14 02:31 AM
uint16_t number11=0;
union
{
uint8_t bytes[2];
uint16_t number1;
}memory16bits;
union
{
uint16_t value1;
struct
{
uint8_t byt[2];
}bytnumber;
}pixel;
int main(void ) {
while (1)
{
/* USER CODE END WHILE */
pixel.value1 =12345;
memory16bits.bytes[0]=pixel.bytnumber.byt[0];
memory16bits.bytes[1]=pixel.bytnumber.byt[1];
number11 = memory16bits.number1;
HAL_Delay(1000);
pixel.value1 =55555;
memory16bits.bytes[0]=pixel.bytnumber.byt[0];
memory16bits.bytes[1]=pixel.bytnumber.byt[1];
number11 = memory16bits.number1;
HAL_Delay(1000);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
}
Working perfect splitting 16 bit into two 8 bit and recombine two 8 bit into single 16 bit .
how to split four letter " STAT "or " STOP" string into single char and recombine using union and struct ?
2023-01-14 08:44 AM
There is no string type in C. A string is just an array of char elements terminated with a zero.