hi Engineers;
i want set up touch screen lcd but i have some problem.
i can't working with ADC and geting x,y coordinate.
this below is my code of codevision :
thanks for your help.
LCD specifications:
3.2 inch
chip : ssd1289
microcontroller:
AT mega32
i want set up touch screen lcd but i have some problem.
i can't working with ADC and geting x,y coordinate.
this below is my code of codevision :
thanks for your help.
LCD specifications:
3.2 inch
chip : ssd1289
microcontroller:
AT mega32
Code:
#include <mega32a.h>
#include <delay.h>
#include<stdlib.h>
#include "SSD1289.h"
#define ADC_VREF_TYPE 0x00
// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
int xx,yy;
char strx[5];
char stry[5];
void main(void)
{
char strx[16];
char stry[16];
int x,y;
int Temp_adcY,Temp_adcX;
// ADC initialization
// ADC Clock frequency: 1000.000 kHz
// ADC Voltage Reference: AREF pin
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x83;
lcd_init();
DDRB=0xff;
DDRC=0xff;
DDRD=0xff;
while(1)
{
lcd_clear();
lcd_background_color(YELLOW);
DDRA= 0xF3;
PORTA.0= 0;
PORTA.1=1;
xx = read_adc(2);
DDRA= 0xFC;
PORTA.2= 0;
PORTA.3=1;
yy = read_adc(0);
itoa(yy,stry);
itoa(xx,strx);
lcd_gotoxy(0,0);
lcd_puts(strx,RED,BLACK);
lcd_gotoxy(10,10);
lcd_puts(stry,RED,BLACK);
delay_ms(125);
lcd_clear();
}
}
Last edited: