I have the following code by which I connect to a sensor and I receive data from it that I keep in variables type "unsigned char"
#include <18f2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#USE delay(clock=48000000)
#use i2c(Master,Fast,sda=PIN_B0,scl=PIN_B1)
#include <usb_cdc.h>
void main() {
i2c_start();
i2c_write(0x54);
i2c_write(0x00);
i2c_write(0x83);
i2c_write(0x54);
i2c_write(0x00);
i2c_write(0x03);
i2c_stop();
usb_cdc_init();
usb_init();
while(TRUE) {
delay_ms(720);
i2c_write(0x54);
i2c_write(0x03);
i2c_write(0x55);
unsigned char RM=i2c_read(1);
unsigned char RL=i2c_read(1);
unsigned char GM=i2c_read(1);
unsigned char GL=i2c_read(1);
unsigned char BM=i2c_read(1);
unsigned char BL=i2c_read(1);
unsigned char IM=i2c_read(1);
unsigned char IL=i2c_read(0);
i2c_stop();
usb_task();
if (usb_enumerated()) {
printf(usb_cdc_putc,"%d",RM);
printf(usb_cdc_putc,"%d",RL);
printf(usb_cdc_putc, "\f ");
}
}
}
RM are the 8 most significant bits of the data and RL the least significant. I would like to know how to express this data as a total in Decimal using the command "printf".
For example if I get the data RM = 11111111 and RL = 11111111 that will appear on the screen as 65535.
Thank you very much.