Could it be problem in my reading function regarding how i shift MSB and LSB in order to get the 12 bit result ?
I first( shift 8 rows left MSB and add LSB ) then i shift this result 3 rows right, it that correct ?
Once result has been returned, i've tried to convert it to ascii character and display the X and Y positions of the touched point in my GLCD screen :
Here is my reading function :
I first( shift 8 rows left MSB and add LSB ) then i shift this result 3 rows right, it that correct ?
Code:
return ((msb << 8) | lsb) >> 3;
Once result has been returned, i've tried to convert it to ascii character and display the X and Y positions of the touched point in my GLCD screen :
Code:
// Int table for 10 sample storage :
unsigned short int PEN_position_X[10];
unsigned short int PEN_position_Y[10];
// Buffer for int to ascii conversion :
unsigned char ascii_PEN_position_X;
unsigned char ascii_PEN_position_Y;
...
uitoa(PEN_position_X[0],(BYTE*)ascii_PEN_position_X);
uitoa(PEN_position_Y[0],(BYTE*)ascii_PEN_position_Y);
Here is my reading function :
Code:
unsigned short int ADS7843_read(unsigned char address)
{
volatile BYTE Dummy;
unsigned int msb, lsb;
// Configure SPI
ADS7843_SPIEN = 0;
ADS7843_SPICON1 = ADS7843_SPICON1_CFG;
ADS7843_SPIEN = 1;
ADS7843_CS_IO = 0;
ADS7843_SPI_IF = 0;
/*********************************/
ADS7843_SSPBUF = address;
while(!ADS7843_SPI_IF);ADS7843_SPI_IF = 0;
Dummy = ADS7843_SSPBUF;
/*********************************/
/*********************************/
// Get MSB :
ADS7843_SSPBUF = 0x00;
while(!ADS7843_SPI_IF);ADS7843_SPI_IF = 0;
msb = ADS7843_SSPBUF;
/*********************************/
/*********************************/
// Get LSB :
ADS7843_SSPBUF = 0x00;
while(!ADS7843_SPI_IF);ADS7843_SPI_IF = 0;
lsb = ADS7843_SSPBUF;
/*********************************/
ADS7843_CS_IO = 1;
ADS7843_SPIEN = 0;
return ((msb << 8) | lsb) >> 3;
}
Last edited: