hi
I have a timer implemented which increments and overflows updating minute and hour registers. Each time 1 minute has passed,min_reg gets incremented. if 60 mins have passed, hour_reg gets incremented by 1.
I am now planning to implement a function whereby the user can read these registers (min_reg, hour_reg) to know the amount of time that has elapsed, the user will be reading these values via the UART.
Hence, the min_reg and the hour_reg has to be converted to ASCII before being sent out through the UART (say from a PIC-PC)
From the ASCII table , numbers 0-9 are respectively 0x30-0x39. Hence the value of the ASCII number to be converted is the [hex number + 0x30] but this is only applicable if the number in the register is below or equal to 9. Once this is a ten, then we have a problem.
So my question is, how should I implement number hex to ASCII number conversion that takes into account a hex number which has a decimal value more than 9?
THanks
I have a timer implemented which increments and overflows updating minute and hour registers. Each time 1 minute has passed,min_reg gets incremented. if 60 mins have passed, hour_reg gets incremented by 1.
I am now planning to implement a function whereby the user can read these registers (min_reg, hour_reg) to know the amount of time that has elapsed, the user will be reading these values via the UART.
Hence, the min_reg and the hour_reg has to be converted to ASCII before being sent out through the UART (say from a PIC-PC)
From the ASCII table , numbers 0-9 are respectively 0x30-0x39. Hence the value of the ASCII number to be converted is the [hex number + 0x30] but this is only applicable if the number in the register is below or equal to 9. Once this is a ten, then we have a problem.
So my question is, how should I implement number hex to ASCII number conversion that takes into account a hex number which has a decimal value more than 9?
THanks