little help with ADS7843

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

little help with ADS7843

Postby daviddawe1982 » Thu May 16, 2013 12:42 pm

hello all
well i am back up and running again and would really like to use the touch screen on my lcd from what i can find the ADS7843 driver is fully compatible with mine i just don't know where to connect what pins to where and from what i can see in the board examples only cover 2 gpio's but my pin outs are
t-clk
t-cs
t-din
t-DO
t-irq
i am using a stm32f4 discovery
i did search the forum and know others have got them to work with the same board but did not share there configurations

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: little help with ADS7843

Postby Tectu » Thu May 16, 2013 1:04 pm

It's a normal SPI interface plus one pin extra (the IRQ) which tells the MCU that the screen has or is being touched. Therefore you connect it like any other SPI slave to your MCU. The IRQ pin is just a GPIO as well. The different board files show how to handle those. It's just a palReadPad() call.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Thu May 16, 2013 2:02 pm

OK i think i got most of it right but when i calibrate i get a same reading error

Code: Select all

/*

    ChibiOS/GFX - Copyright (C) 2012, 2013

                 Joel Bodenmann aka Tectu <joel@unormal.org>



    This file is part of ChibiOS/GFX.



    ChibiOS/GFX is free software; you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation; either version 3 of the License, or

    (at your option) any later version.



    ChibiOS/GFX is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

    GNU General Public License for more details.



    You should have received a copy of the GNU General Public License

    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/



/**

 * @file    drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h

 * @brief   GINPUT Touch low level driver source for the ADS7843 on an Olimex STM32E407.

 *

 * @defgroup Mouse Mouse

 * @ingroup GINPUT

 * @{

 */



#ifndef _GINPUT_LLD_MOUSE_BOARD_H

#define _GINPUT_LLD_MOUSE_BOARD_H



static const SPIConfig spicfg = {

    NULL,

   GPIOB,

    12,

    /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0,

};



/**

 * @brief   Initialise the board for the touch.

 *

 * @notapi

 */

static inline void init_board(void) {

   spiStart(&SPID2, &spicfg);

}



/**

 * @brief   Check whether the surface is currently touched

 * @return   TRUE if the surface is currently touched

 *

 * @notapi

 */

static inline bool_t getpin_pressed(void) {

   return (!palReadPad(GPIOC, 8));

}

/**

 * @brief   Aquire the bus ready for readings

 *

 * @notapi

 */

static inline void aquire_bus(void) {

   spiAcquireBus(&SPID2);

    //TOUCHSCREEN_SPI_PROLOGUE();

    palClearPad(GPIOB, 12);

}



/**

 * @brief   Release the bus after readings

 *

 * @notapi

 */

static inline void release_bus(void) {

   palSetPad(GPIOB, 12);

   spiReleaseBus(&SPID2);

    //TOUCHSCREEN_SPI_EPILOGUE();

}



/**

 * @brief   Read a value from touch controller

 * @return   The value read from the controller

 *

 * params[in] port   The controller port to read.

 *

 * @notapi

 */

static inline uint16_t read_value(uint16_t port) {

    static uint8_t txbuf[3] = {0};

    static uint8_t rxbuf[3] = {0};

    uint16_t ret;



    txbuf[0] = port;



    spiExchange(&SPID2, 3, txbuf, rxbuf);



    ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3);

   

   return ret;

}



#endif /* _GINPUT_LLD_MOUSE_BOARD_H */

/** @} */
Last edited by daviddawe1982 on Thu May 16, 2013 2:43 pm, edited 1 time in total.

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: little help with ADS7843

Postby Tectu » Thu May 16, 2013 2:14 pm

"Same reading error" means that you don't have a working connection. There's no way to check that board file without knowing the actual hardware wiring. Just make a 1:1 copy of one of the files (for example the E407) and fill in your pin configs.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Thu May 16, 2013 2:48 pm

yes thats what i did and then added my details i connected it like so
t-clk - pb13
t-cs - pb 12
t-din - pb 15
t-DO - pb14
t-irq - pb2
i have enabled spi in hal and enabled spid2 in mucconf
i just cant see where i went wrong??

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: little help with ADS7843

Postby Tectu » Thu May 16, 2013 3:09 pm

For one, you didn't set the right IRQ pin in the file you posted above. There's the pin PC8 used. For another, check that there are no hardware conflicts on the F4 discovery board. When something which is already on the board is connected for example to the IRQ or the CS line, there might develop some issues.
Also, make sure you set your PAL modes correctly. The init_board is usually used for this.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Thu May 16, 2013 3:12 pm

i have changed the irq to b2 it must be the pal modes thanks

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Fri May 17, 2013 12:00 pm

Ok,
Thank you Tectu for the hint.
It was the PAL mode's that was my problem but now when I use the GWIN DrawButton it will halt my code after drawing the button.
The button still works (it go's dark gray when touched) but my code will not progress past that point.
Even if I don't do any thing with the button the code will still stop, I am using button the example on your site as my guide.
Is there a wait programmed into DrawButton??

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: little help with ADS7843

Postby daviddawe1982 » Fri May 17, 2013 3:49 pm

Well I have played around a bit and have figured out the code is still running just no new drawing to lcd after ButtonDraw..

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: little help with ADS7843

Postby Tectu » Fri May 17, 2013 7:16 pm

The example from the webpage is working here fine. Are you 100% using that or did you do something on your own as well?
Also, make sure you have the font enabled that's getting used there.


~ Tectu


Return to “LCD Driver and Graphic Framework”

Who is online

Users browsing this forum: No registered users and 0 guests