- This topic has 2 replies, 2 voices, and was last updated 11 years ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › touchscreen
Hello, could someone help me with sample code for touch screen with TSC2046 touch screen controler. My microcontroller is C8051f022.
Hi Boris,
The complexity of the touchscreen interface has been reduced by that touchscreen controller, now the touchscreen can be simply interfaced to the SPI port of the microcontroller.
It dosen’t sounds that complex, suggest you to give a try yourself and keep posting, we will help you to finish the project.
Hello, I write a part of code for SPI interface but I can’t understant how to read from the TSC2046.
#include “c8051F020.h”
#include “touchscreen.h”
/*
C8051f022
DCLK P0_0
CS (hardware to GND)
DIN P0_1 TSC out controler in
DOUT P0_2 Controler out TSC in
IRQ P0_7
SPI0CN = 0x03;
XBR0 = 0x02;
XBR2 = 0x40;
SPI0CKR = 0x3F;
SPI0CFG = 0x80; // data center on second edge
WDTCN = 0xDE;
WDTCN = 0xAD;
OSCICN = 0x07; // internal 16MHz
Mode_send = 0x90; // S A2 A1 A0 mode (12 bit) SER PD1 PD0 0b10010000
SPI0DAT = Mode_send;
*/
#define DCLK P0_0
#define DIN P0_1
#define DOUT P0_2
#define IRQ P0_7
unsigned char mode_send = 0x90;
void SPI0_init()
{
SPI0CFG = 0x80;
SPI0CN = 0x03;
SPI0CKR = 0x3F;
}
void Port_init()
{
P0MDOUT = 0x07; // DCLK, DIN, DOUT – push-pull,
EIE1 = 0x01; // Enable SPI interupt
}
void Oscillator_Init ()
{
OSCICN = 0x07; // Set the internal oscillator to 16MHz
}
void Watchdog_Init ()
{
WDTCN = 0xDE; // Disable the Watchdog Timer
WDTCN = 0xAD;
}
void Initialization_device ()
{
SPI0_init();
Port_init();
Oscillator_Init ();
Watchdog_Init ();
}
void SPI_Write()
{
SPI0DAT = mode_send;
while (SPI0DAT!=0)
{
}
}
void SPI_Read()
{
}
void SPI_start()
{
Initialization_device();
SPI_Write();
SPI_Read();
}