Greetings,
I am looking for a C function to convert a raw hex data to a char. Recently I developed a program in PIC18F2550 that reads the data from the ADC and sends to the serial port.
The program is working all right but I am having difficulties in writing a function that receives the raw hex data and convert to char. It should look something like this:
unsigned char convert2hex(unsigned char data)
The ADC and Serial is working all right but I need to convert the ADC data to a readable string to send to serial port o look something like this in the terminal: "0EFF" "00A1" "0012" and etc...
Also, one import aspect to tell is that the PIC18F2550 have to registers that represents the 10-bits resolution of the ADC. The register ADRESH has the 8 most significant bits of the ADC and the ADRESL register has the 2 less significant bits of the ADC.
Thanks,
FBorges22
I am looking for a C function to convert a raw hex data to a char. Recently I developed a program in PIC18F2550 that reads the data from the ADC and sends to the serial port.
The program is working all right but I am having difficulties in writing a function that receives the raw hex data and convert to char. It should look something like this:
unsigned char convert2hex(unsigned char data)
The ADC and Serial is working all right but I need to convert the ADC data to a readable string to send to serial port o look something like this in the terminal: "0EFF" "00A1" "0012" and etc...
Also, one import aspect to tell is that the PIC18F2550 have to registers that represents the 10-bits resolution of the ADC. The register ADRESH has the 8 most significant bits of the ADC and the ADRESL register has the 2 less significant bits of the ADC.
Thanks,
FBorges22
Last edited: