Typecasting in PSoC 3 | Cypress Semiconductor
Typecasting in PSoC 3
I would like to convert a 12 bit reading from the delta-sigma ADC (range = 1.024V single ended) into an 8 bit DAC value (range = 1.024V).
I had originally thought to typecase the int16 adc conversion into a uint8 DAC value:
sprintf(buffer,"%d, %d\n\r", adc_val, (uint8)adc_val);//Note the typecast
However, when I do this I get the following (using the sprintf function):
adc_val = 3491
(uint8)adc_val = - 23773
Can anyone suggest how I could better go about this process? Is this error a compilier thing or did I make a silly mistake?