Description: Using the ITC232-A for Period Measurement.

Similar documents
RMV ELECTRONICS INC. Application Note:

General Purpose Programmable Peripheral Devices. Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar

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

Summer 2003 Lecture 21 07/15/03

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

The IIC interface based on ATmega8 realizes the applications of PS/2 keyboard/mouse in the system

MICROPROCESSOR MICROPROCESSOR. From the above description, we can draw the following block diagram to represent a microprocessor based system: Output

CHAPTER 5 : Introduction to Intel 8085 Microprocessor Hardware BENG 2223 MICROPROCESSOR TECHNOLOGY

8051 Microcontroller

These three counters can be programmed for either binary or BCD count.

Bachelor of Engineering in Computer and Electronic Engineering

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

CPE/EE 421/521 Fall 2004 Chapter 4 The CPU Hardware Model. Dr. Rhonda Kay Gaede UAH. The CPU Hardware Model - Overview

Lecture-55 System Interface:

Register Map for the PCM-QUAD02

The 8255A: Programmable Peripheral Interface

8051 Microcontrollers

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

8051 Microcontroller

UNIT - II PERIPHERAL INTERFACING WITH 8085

Microcomputers. Outline. Number Systems and Digital Logic Review

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

EECS 373 Midterm 2 Fall 2018

8032 MCU + Soft Modules. c = rcvdata; // get the keyboard scan code

Chapter 1: Basics of Microprocessor [08 M]

LSI Computer Systems, Inc Walt Whitman Road, Melville, NY (631) FAX (631) BIT QUADRATURE COUNTER

80C51 Block Diagram. CSE Overview 1

University of Technology

PIC-I/O Multifunction I/O Controller

Topics. Interfacing chips

SRS501 User s manual

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

Introduction to the MC9S12 Hardware Subsystems

The MC9S12 in Expanded Mode Using MSI logic to build ports Using MSI logic to build an output port Using MSI logic to build an input port

Chapter 16. PC-Compatible Bus Connectors Discussion. PC-Compatible Bus Connectors 97

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

Architecture of 8085 microprocessor

Chapter Operation Pinout Operation 35

Using Input Capture on the 9S12

Special Memory (SM) Bits

PCI bit Digital Input/ Output Card for PCI Bus. User s Manual

Interfacing a Hyper Terminal to the Flight 86 Kit

82C54 CHMOS PROGRAMMABLE INTERVAL TIMER

EE 308 Spring A software delay

LCD03 - I2C/Serial LCD Technical Documentation

PERIPHERAL INTERFACING Rev. 1.0

CONNECTING YOUR PC TO THE USB EVALUATION BOARD

Using FlexIO to emulate communications and timing peripherals

8051 Timers and Serial Port

Registers Format. 4.1 I/O Port Address

8/26/2010. Introduction to 8085 BLOCK DIAGRAM OF INTEL Introduction to Introduction to Three Units of 8085

8051 microcontrollers

NS9360. Errata _F. Release date: March 2008

12-Dec-11. Gursharan Singh Maninder Kaur. Introduction to 8085 BLOCK DIAGRAM OF INTEL Introduction to Introduction to 8085

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

CENG-336 Introduction to Embedded Systems Development. Timers

1. Internal Architecture of 8085 Microprocessor

Interfacing an Intel386 TM EX Microprocessor to an CAN Controller

The Memory Component


MICROPROCESSOR B.Tech. th ECE

QSB Command List. Document Version /15/2017

QBridge. I2C, SPI, CAN Control Software User s Manual. Date: Rev 1.3

LCD03 - I2C/Serial LCD Technical Documentation

In this tutorial, we will discuss the architecture, pin diagram and other key concepts of microprocessors.

Universal Asynchronous Receiver / Transmitter (UART)

Serial Peripheral Interface Bus SPI

EE 308 Spring Lecture 28 March 30, 2012 Review for Exam 2. Introduction to the MC9S12 Expanded Mode

EEPROM Emulation with the ez80f91 MCU. Discussion

4. Configuring Cyclone II Devices

Digital UART Product Specification

Basics of Microprocessor

PCI-1751U. 48-bit Digital Input/Output Card with Universal PCI Bus. User Manual

Code No: R Set No. 1

Microcomputer Architecture and Programming

The 9S12 in Expanded Mode - Using MSI logic to build ports Huang Chapter 14

To Interface The 8085 Microprocessor

C:\Users\Jacob Christ\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

MCU: Interrupts and Timers. Ganesh Pitchiah

Hello, and welcome to this presentation of the STM32 Universal Synchronous/Asynchronous Receiver/Transmitter Interface. It covers the main features

Sound Programming with PC Speaker

HC12 Built-In Hardware

C Language Programming, Interrupts and Timer Hardware

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

Architecture of 8086 Microprocessor

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission.

Control Unit: The control unit provides the necessary timing and control Microprocessor resembles a CPU exactly.

PCI-HPDI32A-COS User Manual

Problem Set 10 Solutions

Course Introduction. 2009, Renesas Technology America, Inc., All Rights Reserved

LSI/CSI LS7166A 24-BIT QUADRATURE COUNTER

INTERFACING INTERFACING. Richa Upadhyay Prabhu. NMIMS s MPSTME February 25, 2016

USB-4303 Specifications

EE 354 September 16, 2016 C Sample Programs

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

EE251: Tuesday December 4

Chapter 13 Direct Memory Access and DMA-Controlled I/O

ericssonz LBI-38616B MAINTENANCE MANUAL FOR MTD TM SERIES AND DATA RADIO LOGIC BOARD 19D902151G3 DESCRIPTION CIRCUIT ANALYSIS TABLE OF CONTENTS

Microprocessors B (17.384) Spring Lecture Outline


Transcription:

RMV ELECTRONICS INC. Application Note: Description: Using the ITC232-A for Period Measurement. Application #: 00004 Date: September 1994 Status: Draft version The basic operating principle to measure period is to generate a known reference frequency, and then use the input pulse stream to gate this frequency into a counter. The counter is then read and the period calculated. For example, the reference frequency is 1 Mhz (i.e. the counter is being incremented every 1 microsecond). For one period of the input pulse stream, the period gates the reference into a counter. If, at the end of this cycle, the counter reads 11432, the input period can be calculated by: Counter Value / Reference Frequency = Period in seconds In our example, the result is 11432 / 1,000,000 = 0.011432 (or about 11 msec.) The higher the reference frequency, the more counts are received and the higher the effective resolution of the period measurement. The limitation is the size of the counter. If the input period is too long, the counter may overflow and the results will be incorrect. OPERATIONAL DESCRIPTION Please refer to the schematic diagram and the functional software listing. Also refer to the appropriate manufacturers' data sheets and the ITC232-A user's manual for further detail. The circuit is implemented using timer/counter combinations. In this example we have used the Intel (or equivalent) 82C53 Programmable Interval Timer (PIT), the LSI Computer Systems LS7166 MultiMode Counter (MMC), and a crystal based oscillator module. The 82C53 contains three independent 16 bit counters, each capable of running in one of several modes. The LS7166 is similar in nature and contains a single counter. The LS7166 was used because of its enhanced operation and 24 bit counter. If a reduced counter size (and therefore a reduced resolution) and slower operation is adequate, the LS7166 can be removed and another counter within the 82C53 can be used instead. This would reduce the chip count and lessen the circuit cost. The circuit also includes a 74HC73 dual JK flip flop. The input pulses pass through one of JK flip flops to divide the input frequency by two. This results in an output pulse width that corresponds to the input period. The interface between these devices and the ITC232-A is through all of Port C, 6 bits of Port B, and both interrupt lines. Port C is used as a bidirectional data bus, while the Port B lines act as address and bus control lines. A sequence of port writes and reads effectively emulates the operation of a microprocessor data bus, which both the PIT and MMC were designed for. Counter 0 in the PIT is used as a programmable rate generator, dividing the frequency of the oscillator module by the value programmed into the counter, i.e. there will be one output pulse produced every time the counter reaches the preset number. The output of this counter is the reference frequency and directly feeds the MMC counter input. The MMC is initialized as a standard up counter with carry (CY) output. The entire circuit is controlled by a single signal from an ITC232-A port pin (Port B, bit 7) and monitored by the ITC232-A interrupt lines. With the control signal in a low state, the flip flops are cleared. The counter gate (ABGT) signal is high, disabling counts. To start the sequence, the control line is brought high. This releases the clear signal to the flip flops. The first flip flop U4A will now change output states (the Q output going from low to high) on the first rising edge on the input. At the same time, the ABGT signal goes from high to low, allowing the MMC counter to begin counting the reference frequency. The falling edge of the input signal has no effect. The next rising edge will again toggle the outputs of U4A. The falling edge of the Q output will clock U4B. The Q output of U4B will then go low, and since this line feeds the J and K inputs of U4A, U4A will be stopped from any further toggling. At the same time U4A Q output goes low, U4A not Q goes high, freezing the MMC counter. The IRQH line will be set, causing the ITC232-A to notify the PC that the cycle has been completed. This state will remain in effect until the ITC232-A once again asserts and releases the flip flop clear lines. The counter can be read and the pulse width calculated. If the MMC counter overflows, the carry output signals the ITC232-A through the IRQL line, notifying the PC. 1

As described above, the final value would then be calculated by dividing the number of counts by the reference frequency. The input pulse stream frequency (and thereby the minimum period measurable) is limited by the flip flops. Using ICs such as 74F73 instead of the HC series would increase the maximum input. The resolution of the system is limited to the frequency of the PIT 0 output clock. The input to the PIT is 8 Mhz maximum and the minimum divide rate is two. The maximum reference frequency fed to the MMC is therefore 4 Mhz (a time base of 250 nsec.). The maximum resolution in this case would be one count or 250 nsec. Maximum pulse width at this resolution would be 24 bits binary (~16 million counts) or slightly over 4 seconds. For period measurement in excess of 4 seconds, the reference frequency would be reduced by increasing the divide rate in PIT counter 0. By increasing the divider to maximum, periods in the order of hours could be measured. Circuit accuracy is based primarily on the accuracy of the crystal oscillator, which is usually quite good. Other sources of error are the clock input to gate output delays in the flip flops and the ABGT response time in the MMC. All these delays are in the tens of nanosecond range and should contribute no significant error (on the order of 1 count or less at high reference frequency rates). /* /* a = 0 for break */ Functional code listing for the input period measurement /* = 1 for space */ application circuit. ITC232 port assignments are as follows (refer to schematic diagram): Port C is a bidirectional 8 bit data bus Port B, bits 0 and 1 are address lines used to select particular registers on the PIT and MMC Port B, bits 2 and 3 are the active low read and write lines respectively Port B, bit 4 is the active low chip select for the PIT Port B, bit 5 is the active low chip select for the MMC Port B, bit 6 is an input for monitoring the count cycle status Port B, bit 7 is an output for controlling the count cycle operation IRQH is used to indicate the count cycle has completed IRQL is used to indicate an overflow condition /* /* Constant definitions */ #define OSC_FREQ 8000000 #define PIT_CTR_0 0xec #define PIT_CTR_1 0xed #define PIT_CTR_2 0xee #define PIT_CONTROL 0xef #define MMC_DATA 0xdc #define MMC_CONTROL 0xdd #define BAUD_9600 0x0c #define COMM_1 0x01 #define COMM_2 0x02 #define NULL 0x00 /*function declarations*/ /* function for sending data thru the ITC232 to peripherals */ void out_data(unsigned char a, unsigned char b); /* function for receiving data from ITC232 peripherals */ char in_data(unsigned char a); void ITC_send(char *ptr); /* function to send a string to ITC232 */ void ITC_send_no_wait(char *ptr); /* function to send a string to ITC232 */ char ITC_data(void); /*function that returns the data value in response to a port read operation */ /* external function for setting up serial ports */ extern void far Setup(unsigned int Rate, unsigned char Parms, unsigned char SelBase); /* Setup(Divisor, Parms, SelBase) */ /* Divisor = 115200/desired baud rate */ /* Parms = 0 a bcd e fg */ /* bcd = 000 none parity */ /* = 001 odd parity */ /* = 011 even parity */ /* e = 0 for 1 stop bit */ /* = 1 for 2 stop bits */ /* fg = 10 for 7 bits per character */ /* = 11 for 8 bits per character */ /* SelBase = 1 for COM1 */ /* 2 for COM2 */ /* 3 for COM3 */ /* 4 for COM4 */ /* external functions for installing an comm interrupt, removing same, and restoring previous port operation */ extern void far Restore(); extern void far SetInt(); extern void far RemInt(); extern unsigned int far Receive( unsigned char Rfl, unsigned char Rvalue); extern unsigned int far SendChar ( unsigned char Sfl, unsigned char Tvalue); main() char count_hi,count_mid,count_lo, input; long count_total; float result, ref_freq; int rate_gen; /*Initialize the PC serial port as for 9600 baud, no parity, 8 bits, 1 stop*/ Setup(BAUD_9600, 3, COMM_1); /*Initialize the ITC232 for Configure Results Ascii Program*/ ITC_send("CRAP\r"); /*Set Port B outputs bit 6 thru 0 high*/ /*Set Port B direction as bits 7 and 5 thru 0 as outputs, bit 6 as input*/ ITC_send("PCB$BF\r"); /*Set PIT counter 0 mode to 2 (rate generator), two byte xfer, binary counting*/ out_data(pit_control,0x34); /*Setup PIT counter 0 divide rate to 8. This example assumes a 8 Mhz oscillator, resulting a 1 microsecond time base. */ 2

rate_gen = 8; /* 0x0008 */ out_data(pit_ctr_0,0x08); /*counter 0 low byte*/ /* out_data */ out_data(pit_ctr_0,0x00); /*counter 0 hi byte*/ /* sets up 'bus' for a write operation */ /*Reset MMC, then setup for counting up, normal mode, carry enabled, count gate enabled, binary count */ /* send master reset */ out_data(mmc_control, 0x20); /* set input control register */ out_data(mmc_control, 0x78); /* set output control register */ out_data(mmc_control, 0x80); /* set quadrature control register */ out_data(mmc_control, 0xc0); /* main loop is here, the process is stopped by hitting any key */ while(!kbhit() ) hex string */ /* enable the flip flop one shot to enable counting */ if(b < 0x10) ITC_send("PWB$FF\r"); strcat(string,"0"); /* now wait for either an IRQL or IRQH interrupt from the ITC232 */ input = Receive(0,0); while(input == 0); /* if nothing received, just wait */ if((char)input == 'H') /* cycle has ended normally, disable gate and get counts */ /* first disable the flip flops */ ITC_send("PWB$7F"); /* request a transfer of the counts to the output latches */ out_data(mmc_control, 0x03); /* start getting count values */ count_lo = in_data(mmc_data); count_mid = in_data(mmc_data); count_hi = in_data(mmc_data); /* reset MMC counters for the next cycle */ out_data(mmc_control, 0x04); /* combine the three byte wide counter reads into a single value */ count_total = (count_hi << 16) + (count_mid << 8) + count_lo; ref_freq = OSC_FREQ / rate_gen; result = count_total / ref_freq; printf("\ninput Period = %2.6f seconds.", result); /* code can be entered here to evaluate the results and see if the count value is too low. If so, the reference frequency can be increased */ else /* cycle has caused a counter overflow, first wait for gate to complete, disable counting, then print message */ input = Receive(0,0); while(input == 0); /* if nothing received, just wait */ /* disable the flip flops */ printf("\noverflow\n"); /* code can be entered here to reduce the reference frequency */ /*end of while(kbhit... loop */ printf("\ninput Period Measurement function halted\n"); /*end of main*/ void out_data(a,b) unsigned char a,b; char string[8], value[3]; /* set string ends to NULLS */ string[7] = value[2] = NULL; /* set port C to output */ ITC_send("PCC$FF\r"); /*setup data value on Port C*/ strcpy(string,"pwc$"); itoa(b, value, 16); /* convert the number to be sent to an ascii /*setup register address */ itoa((a 0x7c), value, 16); /*bring chip select low */ itoa((a & 0x7f), value, 16); /*bring write low */ itoa((a & 0x77), value, 16); /*bring write high*/ itoa((a & 0x7f),value,16); /*bring chip select high */ itoa((a 0x7c), value, 16); /* then return to idle state */ /* in_data */ /* sets up 'bus' for a read operation */ char in_data(a) unsigned char a; char string[8], value[3], read_data; 3

/* set string ends to NULLS */ while((char)rval!= '>'); /* continue looping until prompt string[7] = value[2] = NULL; character rx'd */ /* set port C to inputs */ ITC_send("PCC$00\r"); /* setup register address */ itoa((a 0x7c & 0x7f), value, 16); /* bring chip select low */ itoa((a & 0x7f), value, 16); /* bring read low*/ itoa((a & 0x7b),value,16); /* read Port C */ ITC_send_no_wait("PRC$\r"); read_data = ITC_data(); /*bring read high*/ itoa((a & 0x7f),value,16); /* then return to idle state */ /*return value read*/ return read_data; /****************************************/ /* ITC_send */ /* sends a string out the comm port */ /* then waits for the ITC '>' prompt */ /****************************************/ void ITC_send(str) char *str; int rval, tval; while(*str!= 0) /* loop until end of string (NULL) */ tval = SendChar(0, *str); /* wait until tx buffer empty */ while(tval == 0xff00); str++; /* after sending character, go send the next one */ /* after final character sent, went until '>' sent back */ rval = Receive(0,0); /* go get receive buffer status else and/or data */ result = result + (string[1] - 0x37); return result; /* return results converted to a number */ while(rval == 0); /* loop until a character received */ /* ITC_send_no_wait */ /* sends a string out the comm port */ /* es not wait for any response */ void ITC_send_no_wait(str) char *str; int rval, tval; while(*str!= 0) /* loop until end of string (NULL) */ tval = SendChar(0, *str); /* wait until tx buffer empty */ while(tval == 0xff00); str++; /* after sending character, go send the next one */ /* ITC_data */ /* retrieves the data recv'd from a */ /* port read operation */ char ITC_data() char string[3], value, *ptr, result; int rval=0; ptr = string; string[2] = NULL; rval = Receive(0,0); while(rval == 0); switch(value = (char)rval) case 'O': /* if characters are O, K, $, or >, ignore */ case 'K': case '$': case '>': case 'L': printf("\noverflow or Underflow has occured\n"); default: /* otherwise characters should be results */ *(ptr++) = value; /* put results in string */ while(value!= '>'); /* continue looping until prompt character rx'd */ /* string should now contain ascii hex value of result */ /* convert from hex string to a number */ if(isdigit(string[0])) result = (string[0] - 0x30) * 0x10; else result = (string[0] - 0x37) * 0x10; if(isdigit(string[1])) result = result + (string[1] - 0x30); RMV ELECTRONICS INC. #230-2250 Boundary Road Burnaby, B.C. V5M 3Z3 Canada Website: http://rmv.com Email: customer@rmv,com Phone 604 299-5173 Fax: 604 299-5174

RMV ELECTRONICS INC. #230-2250 Boundary Road Burnaby, B.C. V5M 3Z3 Canada Website: http://rmv.com Email: customer@rmv,com Phone 604 299-5173 Fax: 604 299-5174 5

RMV ELECTRONICS INC. #230-2250 Boundary Road Burnaby, B.C. V5M 3Z3 Canada Website: http://rmv.com Email: customer@rmv,com Phone 604 299-5173 Fax: 604 299-5174 6