Ik probeer in opvolging op het werkend krijgen van de aansturing van het lcd scherm nu ook het touchscreen van mijn 3.2inch 320x240 Touch LCD werkend te krijgen. Het gaat om een XPT2046 (compatible with ADS7843) controller.
Datasheet
De code tot dusver (mikroC, voor 18f4550 op 8mhz):
Ik krijg alleen nog geen data door. Ik heb al verschillende delays geprobeerd, en het lezen van de y in plaats van x, maar het wil niet lukken.
Datasheet
De code tot dusver (mikroC, voor 18f4550 op 8mhz):
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| // Software SPI module connections sbit SoftSpi_CS at RB0_bit; sbit SoftSpi_SDI at RB2_bit; sbit SoftSpi_SDO at RB4_bit; sbit SoftSpi_CLK at RB6_bit; sbit SoftSpi_CS_Direction at TRISB0_bit; sbit SoftSpi_SDI_Direction at TRISB2_bit; sbit SoftSpi_SDO_Direction at TRISB4_bit; sbit SoftSpi_CLK_Direction at TRISB6_bit; // End Software SPI module connections //---------------------------------------- // read the 12-bit result. unsigned int ads7843_read() { char lsb, msb; SoftSpi_CS = 0; Soft_SPI_Write(0x90); delay_us(2); // Tacq delay time msb = Soft_SPI_Read(0); lsb = Soft_SPI_Read(0); SoftSpi_CS = 1; return (msb << 8) | lsb; } char txt[7]; void main() { ADCON1 = 0x0F; // Configure all ports with analog function as digital CMCON = 7; // Disable comparators UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize UART1_Write_Text("Start"); UART1_Write(10); UART1_Write(13); SoftSpi_CS = 1; SoftSpi_CS_Direction = 0; // Set CS# pin as Output Soft_SPI_Init(); // Initialize Soft_SPI Delay_ms(100); while(1) { IntToStr(ads7843_read(), txt); UART1_Write_Text(txt); delay_ms(500); } } |
Ik krijg alleen nog geen data door. Ik heb al verschillende delays geprobeerd, en het lezen van de y in plaats van x, maar het wil niet lukken.