Hi @Chish
Many thanks for your patience.
Regarding your question about "what could be the problem in your code", as I can see, you are probably missing to divide by 100 in the MSB, so, "how can you separate the 324 to MSB=3, MIDB=2, LSB=4" , we would like to suggest you this code snippet that you might use in your code:
void stunden (uint32_t hour, uint8_t bit);
typedef struct{
uint8_t msb;
uint8_t midb;
uint8_t lsb;
}stunden_t;
stunden_t g_stunden;
void stunden (uint32_t hour, uint8_t bit)
{
switch (bit)
{
case QUERY_STUNDEN_MSB:
hour /= 100;
g_stunden.msb = hour;
break;
case QUERY_STUNDEN_MIDB:
hour /= 10;
g_stunden.midb = hour % 10;
break;
case QUERY_STUNDEN_LSB:
g_stunden.lsb = hour % 10;
break;
default:
break;
}
return;
}
And then you can use this function like this:
main.c :
stunden(324, QUERY_STUNDEN_LSB);
stunden(324, QUERY_STUNDEN_MIDB);
stunden(324, QUERY_STUNDEN_MSB);
So this function can return the value that you want for 3 digits, and for 3+ digits you may add to the function the other cases dividing the hour by 1000, 10,000, and so on.
If you require more assistance, we would be glad if you let us know.
Best Regards.
Pablo Avalos.