Problem face with 16bit ADC scanning

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi all,

i am relatively new to Psoc development pardon my ignorance.
i am working on integrating accelerometer with the development kit.

after consulting several experts' advice from this forum, my setup was working quite fine. however i met with some issue about the conversion from 8bit to 16 bit of the ADC use.

sample project which i use to reference,
1) ADC Channel Scan with Software - http://www.cypress.com/?rID=38799
2) UART sample project- http://www.cypress.com/?id=2232&rtID=113

code:
char OutputString[36];
char zout[10];
char yout[10];
char xout[10];

sprintf(zout,"%x",iAdcValue[0]);
sprintf(yout,"%x",iAdcValue[1]);
sprintf(xout,"%x",iAdcValue[2]);

strcat(OutputString,zout);
strcat(OutputString,"y:");
strcat(OutputString,yout);
strcat(OutputString,"x:");
strcat(OutputString,xout);
strcat(OutputString,"@");//to indicate end of one set of conversion

UART_1_PutString(OutputString);

as the ADC channel scan is working with a 8bit ADC, i tried to setup the project and it looks ok when it display on the LCD and hyperterm.

however there is a slight issue when it display on the hyperterm, the value of what i see from the LCD and the hyperterm tally, but when it send out through the serial port using UART, the value show on the hyperterminal something like:

eg z:aa1fy:bb1fx:cc1f;
there is always a 1f follow behind each value.

next,i wish to change the ADC resolution to 16bits.

changes i made to the default ADC scanning example project:
-change the ADC resolution to 16bits.
-change the voltage reference to 2times which now is 2.048V.
-change the ADC_DelSig_1_IRQ.c files, under the function

"CY_ISR(ADC_DelSig_1_IRQ_Interrupt)"

iAdcValue[iIndex]=ADC_DelSig_1_GetResult8(); to iAdcValue[iIndex]=ADC_DelSig_1_GetResult32(); ==> cause the data sheet indicated that if i use 16 it will return me signed 16bit result.

i cant print out properly on the LCD screen as i do not really catch the below method of displaying

LCD_Position(iChannel/4,((4*iChannel)%16));
LCD_PrintInt16(iAdcValue[iChannel]);
iChannel=(iChannel+1)%3;

thus i use a hyperterm to check the output,
it always show as:

eg z:aa20y:bb20x:cc20;
now there is always a 20 follow behind each value.

i was wondering why it never return me a 4 hex value?
why there is either 1f tag behind each value of the 8bit ADC output, and 20 tag behind the 16bit output?

please help.
any help will be greatly appreciated.

0 Likes
8 Replies