TW8816 Built-in MCU. Application Notes

Similar documents
ENE 334 Microprocessors

8051 Microcontroller

8051 Microcontroller

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

80C51 Block Diagram. CSE Overview 1

ISSI. IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH ISSI IS89C51 NOVEMBER 1998 FEATURES GENERAL DESCRIPTION

Three criteria in Choosing a Microcontroller

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

UNIT IV MICROCONTROLLER

Introduction To MCS-51

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

3. (a) Explain the steps involved in the Interfacing of an I/O device (b) Explain various methods of interfacing of I/O devices.

8051 Microcontroller. Ali Ziya Alkar 1

EE6502- MICROPROCESSOR AND MICROCONTROLLER

Chapter 9. Programming Framework

Rev. No. History Issue Date Remark

8051 Microcontrollers

8051 Timers and Serial Port

Lecture 9. Timer Operations and Programming

CPEG300 Embedded System Design. Lecture 8 Timer

ELEG3923 Microprocessor Ch.9 Timer Programming

Embedded Controller Programming

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

7.2.1 Timer 2 Capture LSB... 24

AT89S4D12. 8-Bit Microcontroller with 132K Bytes Flash Data Memory AT89S4D12. Features. Description. Pin Configurations

MODULE-1. Short Answer Questions

Q.1. A) Attempt any THREE of the following:

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

CPEG300 Embedded System Design. Lecture 3 Memory

DS89C420 Ultra High-Speed Microcontroller User s Guide

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC.

20uA at VDD=5.5V 5uA at VDD=3.6V. 1T up to 20 (1T~8T can change on fly) RC ( 24MHz) Program Flash ( byte) 4K 4K RAM( byte)

MEGAWIN MPC89L516X2. 8-bit micro-controller. Features

M16C R8C FoUSB/UART Debugger. User Manual REJ10J

Department of EIE / Pondicherry Engineering College. Timer/Counters. Department of EIE / Pondicherry Engineering College 1

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

W77E058A Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

Preliminary W77E58 8 BIT MICROCONTROLLER. Table of Contents-- Publication Release Date: March Revision A1

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

Introducing The MCS 251 Microcontroller -- 8XC251SB

UNIT-III ASSEMBLY LANGUAGE PROGRAMMING. The CPU can access data in various ways, which are called addressing modes

MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller and Applications Subject Code:

TOSHIBA Original CMOS 8-Bit Microcontroller. TLCS-870/C Series TMP86F808DMG TMP86F808NG. Semiconductor Company

MODEL ANSWER SUBJECT- MICROCONTROLLER(12187) CLASS-EJ5E CLASS TEST-02 Q1.)Attempt any THREE of the following.

SH79F166 APPLICATION NOTE

ELEG3924 Microprocessor

W77LE58/W77L058A Data Sheet 8-BIT MICROCONTROLLER. Table of Contents- Publication Release Date: April 17, Revision A7

VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU

Vidyalankar T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution

Chapter 09. Programming in Assembly

W77IE58 8-BIT MICROCONTROLLER. Table of Contents-- Publication Release Date: December Revision A2

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

SECTION 1: INTRODUCTION 5 SECTION 2: ORDERING INFORMATION 5 SECTION 3: ARCHITECTURE 5

CS 320. Computer Architecture Core Architecture

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5

~: Simple Programs in 8051 assembly language :~

MSM80C154S MSM83C154S MSM85C154HVS USER'S MANUAL

8XC51RA RB RC Hardware Description

Preliminary W77C32 8 BIT MICROCONTROLLER GENERAL DESCRIPTION FEATURES

Microcontroller and Embedded Systems:

W77L516A DATA SHEET 8-BIT MICROCONTROLLER. Table of Contents-

VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU

8051 MICROCONTROLLER WITH 64K FLASH AND ISP. Latch PSW ALU. Latch. Instruction Decoder & Sequencer. Bus&Clock Controller. Port 4. Latch.

8051 Serial Communication

Handshake Solutions. HT80C51 User Manual

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

8051 Microcontroller

PGT302 Embedded Software Technology. PGT302 Embedded Software Technology

Lecture 1. Course Overview and The 8051 Architecture

DS80C390 Dual CAN High-Speed Microprocessor

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

SH57K12. High Performance 8031 Microcontroller. Preliminary. Features. General Description

INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal, Hyderabad ELECTRONICS AND COMMUNICATION ENGINEERING QUESTION BANK

8051 MICROCONTROLLER

W77E532/W77E532A DATA SHEET 8-BIT MICROCONTROLLER. Table of Contents-

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052

VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU

8051 Microcontroller memory Organization and its Applications

M16C R8C FoUSB/UART Debugger. User s Manual REJ10J

A. This Errata sheet represents the known bugs, anomalies and work-arounds for the ADuC812 MicroConverter.

AT Bit Spread- Spectrum Microcontroller. Preliminary. Features. Description. Pin Configuration

DRAFT COPY FUNCTIONAL BLOCK DIAGRAM P0.0 P0.7 P1.0 P1.7 P2.0 P2.7 P3.0 P3.7. ADuC BIT Successive Approximation ADC & ADC Control Logic COMP


Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 4199

High-Speed Microcontroller User s Guide

Digital Blocks Semiconductor IP

MICROPROCESSOR & MICROCONTROLLER

Intel 8051 Family Standard PODs

Timer programming

EC6504 MICROPROCESSOR AND MICROCONTROLLER

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1.

TDA General description. 2. Features. Low power single card reader

W77E532 Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

More on the 9S12 SPI Using the Dallas Semiconductor DS1302 Real Time Clock with the 9S12 SPI

8051 Core Specification

8-Bit Microcontroller with 8K Bytes Flash AT89S8252. Features. Description

High-Speed Microcontroller User s Guide

DS87C520/DS83C520. EPROM/ROM High Speed Micro PRELIMINARY PACKAGE OUTLINE FEATURES

8051 MICROCONTROLLER

Transcription:

TW8816 Built-in MCU Application Notes Disclaimer This document provides technical information for the user. Techwell Inc. reserves the right to modify the information in this document as necessary. The customer should make sure that they have the most recent data sheet version. Techwell Inc. holds no responsibility for any errors that may appear in this document. Customers should take appropriate action to ensure their use of the products does not infringe upon any patents. Techwell Inc. respects valid patent rights of third parties and does not infringe upon or assist others to infringe upon such rights. TECHWELL, INC. Silicon Rev. B

Functional Description Overview Techwell s TW8816 s internal MCU core is very similar to Dallas Semiconductor s DS82C320. It is running directly from SPI flash memory. External program memory space is up to 64 banks of 64Kbytes( Totally 4Mbytes ) see bank access application note. Variable running MCU clock more efficiently access Program SPI Flash memory. 4 clocks/instruction cycle versus 12 in standard 8051 - Up to three times faster execution on average versus standard 8051 Dual data pointers - Improves efficiency when moving large blocks of data Additional Interrupts for Power Down(INT5), TW8816IRQ(INT3) see application notes for interrupts Program can address up to 64KB of program memory at address 0000h-FFFFh. Internal 256 Bytes RAM module and external 256 Bytes RAM module Three timers(timer0, 1, 2) One external serial port it can be used as I/O ports also. One external interrupt it can be used as I/O ports also. 12 I/O ports MCU core 27MHz 27MHz 27MHz Timer Div0 16bit divider 9Ch, 9Dh Timer Div1 16bit divider 9Eh, 9Fh Timer Div1 16bit divider 93h, 94h Timer0 Timer1 Timer2 Port2.0 2.7 Port1.0 Port1.1 Port1.6 Port1.7 RXD-Port3.0 TXD-Port3.1 INT0-Port3.2 Address / Data/ Bank Register(9Ah) SPI Controller Block 83~89:P2.0 2.7 93:P1.0 94:P1.1 114:P1.6 113:P1.7 92:RXD(P3.0) 91:TXD(P3.1) 112:INT0(P3.2)_ SCLK SPICS MOSI MISO 27MHz Simple Block Diagram TECHWELL, INC. 2 REV. 0

Compiler Settings 1. Select processor: DS82C320 2. Use Dual DPTR: on this core has dual data pointer 3. Memory model compact core has 256bytes internal data and 256bytes external data 4. Code Rom Size depends user application program size, support up to 4Mbytes 5. Code banking depends user application, but support up to 64 banks Memory Organization Memory organization in the MCU is similar to that of the industry-standard 8051. There are three distinct memory areas: Program memory (ROM) Data memory (external RAM) Registers and Data memory(internal RAM) Figure Memory Map shows the MCU memory map. Program memory can be up to 64 KB address range (0000h FFFFh). Data memory is 256 bytes (00h-FFh). The internal RAM(256 bytes) addresses overlap the external RAM addresses, but are accessed through different instruction types. Inside the TW8816 TECHWELL, INC. 3 REV. 0

Program Memory The DW8051 can address up to 64 KB of program memory at addresses 0000h FFFFh. Program memory can be implemented as External ROM. (But user can extend it using bank accessing). TW8816 provides SPI interface for accessing Program Memory. Ext RAM Ext RAM 0h-255h is address indirectly as the same way to access external data memory with MOVX instruction. Address pointer are R0 and R1 of the selected register bank and DPTR register. TW8816 Registers TW8816 registers are mapped to external RAM C000h C0FFh. Actual TW8816 s register map is from 0h to 1FFh, but it is controlled by page selection. Register 0FFh is page selection register. This register can be accessed with MOVX instruction. Internal RAM The internal RAM, illustrated in Internal RAM Organization, consists of: 128 bytes of registers and scratchpad memory accessible through direct or indirect addressing. Upper 128 bytes of scratchpad memory accessible through indirect. 128 special function registers (SFRs) accessible through direct addressing (addresses 80h FFh). TECHWELL, INC. 4 REV. 0

Bank Access First use the compiler which is supporting bank mode programming. TW8816 provide SFR 9Ah for up to 64(6bit) banks selection. User should modify own bank switch routines.. Below is example for our demo board. BANKREG DATA 9AH ; Memory Bank select Function Register SWITCH0 MACRO ; Switch to Memory Bank #0 MOV BANKREG, #0H ENDM ; SWITCH1 MACRO ; Switch to Memory Bank #1 MOV BANKREG, #1H ENDM ; SWITCH2 MACRO ; Switch to Memory Bank #2 MOV BANKREG, #2H ENDM ; SWITCH3 MACRO ; Switch to Memory Bank #3 MOV BANKREG, #3H ENDM ; ** Bank switching routines are depend on compilers. See your compiler manuals. TECHWELL, INC. 5 REV. 0

Serial Port and Timer Setting TW8816 s MCU cannot use internal clock for making fixed frequency timer because of variable MCU clock. So using T0, T1 and T2 for getting fixed frequency. T0, T1 and T2 are derived from 16 bit dividers(named MCU External Timer Clock0(1, 2) Divider). Their input clock is 27MHz. MCU External Timer Clock0 Divider : SFR 0x9C(Upper 8bits), 0x9D(Lower 8bits) MCU External Timer Clock1 Divider : SFR 0x9E(Upper 8bits), 0x9F(Lower 8bits) MCU External Timer Clock2 Divider : SFR 0x93(Upper 8bits), 0x94(Lower 8bits) Serial Port 1.Serial port control register set to 50h SCON (98h) = 50h; // serial port mode 1( Async, Timer1, 8 Data bits, 1start, 1 stop, none 9 th bit) 2. Timer0, 1 control register set to 66h // serial port0 mode bit0 = 0, bi1 = 1, bit2 = 0 : baud rate = ToSerialPort/16 TMOD(89h) = 66h; // Timer0,1 using t0, t1 pin for clocking // Timer0, 1 Mode2 8bit counter with auto reload TECHWELL, INC. 6 REV. 0

Use Timer1 Mode for get Baud Rate. Below table shows MCU External Timer Clock1 divider number and TL1, TH1 value Baud Rate Timer Div1 value TH1 Real Baud Rate 9600 176 => 27MHz / 176 = 153.4KHz FFh 153.4 / 16 = 9588 4800 352 FFh 4794 2400 704 FFh 2397 1200 1408 FFh 1198 Timer0 for real time clock Use Timer0 for real time clock We can easily get combining Timer Div0 value(16bit) and TH0 27MHz / Timer Div0 / (256-TH0) = output Tick Ex1) Timer Div0 = 432, TH0 = 131 27MHz / 432 / (256-131) = 500 Hz Ex2) Timer Div0 = 270, TH0 = 56 27MHz / 270 / (256-56) = 500 Hz Ex3) Rimer Div0 = 540, TH0 = 206 27MHz / 540 / (256-206) = 1000Hz Timer2 for IR remote controller clock Use Timer0 for real time clock We can easily get combining Timer Div0 value(16bit) and TH2&TL2(16bit) IR timing = 1/27 * Timer Div2 * (0x10000 TH2&TL2) [usec] Ex1) RC5, Type 1, 209.62usec Timer Div2 = 283, TH2&TL2 = 65516 1/27 * 283 * 20 = 209.63usec Ex2) RC5, Type 2, 222.25usec ( one signal pulse is 889usec, sampling 4 times ) Timer Div2 = 300, TH2&TL2 = 65516 1/27 * 300 * 20 = 222.22usec Ex3) NEC type,186.7usec ( one signal pulse is 560usec, sampling 3 times) Timer Div2 = 252, TH2&TL2 = 65516 1/27 * 252 * 20 = 186.7usec TECHWELL, INC. 7 REV. 0

Using Low Speed ADC TW8816 provides 2 8bit resolution LADCs(Low Speed ADC). It s input range is 0V ~ 1.25V TW8816 REG 0C9h : LADC channel0 TW8816 REG 0CAh : LADC channel1 Application as Key Input Below diagram shows how to make key input using resister ladder. To LADC Key Input Using Resister Ladder TECHWELL, INC. 8 REV. 0

Algorithm for using LADC as Key Input Below sample source code shows how to make key input using resister ladder. BYTE ReadKey( void ) { BYTE i, j, min, max; WORD key_in; } i = GetLADCn Cn(); // get LADC value if ( i<0x10 ) return (0); // smaller than MIN return 0 Delay(30); // 30msec delay chattering i = GetLADCn Cn(); // get LADC value if ( i<0x10 ) return (0); // smaller than MIN return 0 key_in = i; // save Key value min = i; max = i; for ( j=0; j<17; j++ ) { // add 18 key inputs i = GetLADCn Cn(); if ( i<0x10 ) return (0); key_in += i; if ( i < min ) min = i; // save min value else if ( i > max ) max = i; // save max value } key_in -= min; // subtract min key_in -= max; // subtract max key_in >>= 4; // divide by 16 if ( key_in < 0x10 ) return( 0 ); // smaller than MIN return 0 else if ( key_in < 0x33 ) return( MODE ); // MODE else if ( key_in < 0x5a ) return( RIGHT ); // RIGHT else if ( key_in < 0x80 ) return( UP ); // UP else if ( key_in < 0xa0 ) return( MENU ); // MENU else if ( key_in < 0xcc ) return( DOWN ); // DOWN else if ( key_in < 0xf5 ) return( LEFT ); // LEFT else return( POWER ); // POWER TECHWELL, INC. 9 REV. 0