Hello,
May i ask assistance, i'm getting trouble to get a ADS7843 working with a Pic 18F97J60
I can't read X and Y positions, and PENIRQ won't get down.
Here is the schematic i use :
With no software running and No Touch i get the following voltages :
X+ = 2.28V X- = 2.30V Y+=0V Y- = 0V
With no software running + Touch i get the following voltages : ( maybe an issue there ? )
X+ = 0V X- = 0V Y+=0V Y- = 0V
The measured resistance between pins are :
X+ and X - = 415 ohms
Y+ and Y- = 555 ohms.
--------------------------------------------------------------------------------
First, i try to init the ADS7843 with the following function :
I need to use PENIRQ pin, so at the end of the init function i send (0xD0) in order to set the power down mode and get PENIRQ enabled. ( i'm not sure its the proper way to proceed )
#define ADS7843_SPICON1_CFG (0x21) /* (0x2x) is used for SPI mode 0,0 */
// 0x21 => Fosc/16 -> SCK frequency : 40/16 = 2.50 Mhz
...
void Init_ADS7843(void)
{
// Configure PENIRQ pin
Touch_PenIRQ_TRIS = 1; // Touch_PenIRQ is input
// Set up the SPI module on the PIC for communications with the ADS7843 :
ADS7843_CS_IO = 1; // Disable ADS7843 CS pin
ADS7843_CS_TRIS = 0; // Pic CS pin is output
ADS7843_SCK_TRIS = 0; // Set SCK pin as an output
ADS7843_SDI_TRIS = 1; // Make sure SDI pin is an input
ADS7843_SDO_TRIS = 0; // Set SDO pin as an output
ADS7843_SPI_IF = 0; // Clear SPI Flag
ADS7843_SPISTATbits.CKE = 0; // Transmit data on transition from Idle to Active clock state
ADS7843_SPISTATbits.SMP = 0; // Input sampled at middle of data output time
Delay10us(1);
ADS7843_read(0xD0); // Send a read sequence in order to activate PENIRQ (PD1 and PD0 = 0)
}
Here is my reading function :
unsigned short int ADS7843_read(unsigned char address)
{
volatile BYTE Dummy;
unsigned char msb, lsb;
ADS7843_CS_IO = 0; // Enable CS
ADS7843_SPI_IF = 0; // Clear SPI Flag
_asm NOP _endasm // Add delay after CS goes low (0.1 µs = 100 ns)
ADS7843_SSPBUF = address; // Transmit Start bit ( SSP1BUF )
while(!ADS7843_SPI_IF);ADS7843_SPI_IF = 0; // Wait until data is shifted out
Dummy = ADS7843_SSPBUF; // Reading SSPBUF clears SPI Buffer
ADS7843_SSPBUF = 0x00; // Send dummy value (0x00) in order to get the FIRST 8 bit byte
while(!ADS7843_SPI_IF);ADS7843_SPI_IF = 0; // Wait until data is shifted out
msb = ADS7843_SSPBUF; // Get the FIRST 8 bit byte ( 8 clock edges )
ADS7843_SSPBUF = 0x00; // Send dummy value (0x00) in order to get the SECOND 8 bit byte
while(!ADS7843_SPI_IF);ADS7843_SPI_IF = 0; // Wait until data is shifted out
lsb = ADS7843_SSPBUF; // Get the SECOND 8 bit byte ( 8 clock edges )
ADS7843_CS_IO = 1; // Disable CS
return ((msb << 8) | lsb) >> 3; // Put the result in 16 bits : msb goes right and add the lsb
}
From the main loop of the program i check if PENIRQ goes low, then i read X and Y positions afterwards.
while(1)
{
if (Touch_PenIRQ_IO == 0)
{
PEN_X_pos = ADS7843_read(0x90);
PEN_Y_pos = ADS7843_read(0xD0);
}
Here are attached 2 logic SPI screen captures :
- One is without Touch :
During Init_ADS7843 and later during ADS7843_read for X and Y positions :
MISO is not getting any response back to 0xD0 sent previously.
- Second one is when a Touch happens :
During Init_ADS7843 and later during ADS7843_read for X and Y positions :
MISO is not getting any response back to 0x90 and 0xD0 sent previously and PENIRQ stays high and won't get low !
Any help will be much appreciated,
Best regards,