EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / Hello, I write a part of code

Hello, I write a part of code

|

Microcontroller › 8051 › touchscreen › Hello, I write a part of code

February 12, 2014 at 5:54 pm #11017
Boris
Participant

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();

}
 

 

RSS Recent Posts

  • Please could you advise me on this circuit for car OBD2 March 8, 2026
  • MCS-51 Development Ecosystem March 8, 2026
  • Mitsubishi projection lamp March 8, 2026
  • LM016L + PCF8574 I2C Backpack Schematic with Backlight Control March 8, 2026
  • ESP32 Sub Forum March 8, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise