Setting up ADC for touchscreen

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting up ADC for touchscreen

268 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by amlwwalker on Sun Oct 27 12:16:48 MST 2013
Hi.
I am trying to set my touchscreen up. I have attached a picture of the connections and I *think* I understand whats required of my ADC's on channel 0 and 1, however I get nothing back on my terminal when I touch the touch screen.
Can anyone shed some light on my mistake please?
Thanks
A
#define USB_OTG_LINK_ADC0_MASK   (1UL<<23)
#define USB_OTG_LINK_ADC1_MASK   (1UL<<24)
#define USB_OTG_LINK_ADCT_FDIR   LPC_GPIO0->DIR
#define USB_OTG_LINK_ADCT_FSET   LPC_GPIO0->SET
#define USB_OTG_LINK_ADCT_FCLR   LPC_GPIO0->CLR
#define USB_OTG_LINK_ADCT_FIO    LPC_GPIO0->PIN
#define USB_OTG_LINK_ADC0_IOCON  LPC_IOCON->P0_23
#define USB_OTG_LINK_ADC1_IOCON  LPC_IOCON->P0_24

uint16_t adc_result0, adc_result1;
FlagStatus done0, done1;

ADC_Init(LPC_ADC, 50000);
/* enable channel 0: */
ADC_ChannelCmd(LPC_ADC, 0, 1);
ADC_ChannelCmd(LPC_ADC, 1, 1);
/* start the conversion: */
ADC_StartCmd(LPC_ADC, 1);

/* wait until channel 0's data is ready */
done0 = 0;
done1 = 0;
ADC0_State(1);
ADC1_State(1);
while (1) {
 while(!done0 && !done1)
        {
                done0 = ADC_ChannelGetStatus(LPC_ADC, 0, 1);
                done1 = ADC_ChannelGetStatus(LPC_ADC, 0, 1);
        }


      adc_result0 = ADC_ChannelGetData(LPC_ADC, 0);
      adc_result1 = ADC_ChannelGetData(LPC_ADC, 1);

char value[20];
sprintf(value, "v: %d - %d", adc_result0, adc_result1);
UARTPuts_(LPC_UART0, value);
                  }

void ADC1_State (int set)
{
  if (set)
    LPC_GPIO0->SET = USB_OTG_LINK_ADC1_MASK;
  else
    LPC_GPIO0->CLR = USB_OTG_LINK_ADC1_MASK;
}


Im just trying to get the readings back at the moment from the ADC, then once I have an X and a Y I can work out what button was pressed, if any.....
Labels (1)
0 Kudos
0 Replies