application note 982 cop888gw features and applicationscop888gw features and applications...
Post on 07-Mar-2021
5 Views
Preview:
TRANSCRIPT
COP888GW
Application Note 982 COP888GW Features and Applications
Literature Number: SNOA343
COP888GW Features andApplications
INTRODUCTION
The COP888GW is a member of National Semiconductor’sCOP888 family of microcontrollers fabricated in M2CMOS™
technology. The device was established using CCM (Config-urable Controller Methodology) design techniques whichprovide a fast and reliable way to create new derivatives fora fast growing and demanding controller market. In additionto the COP888 feature core this controller includes a mathunit to allow fast multiply/divide operations. The controllerhas special timers for motor control allowing it to be used inapplications where enhanced processing power and motorcontrol capabilities are required (as in plotters, robot-arms orinformation systems.)
This note describes the COP888GW microcontroller empha-sizing the powerful new features. The reader will be giveneasy to use macros to take full advantage of the new CCMblocks.
COP888GW KEY FEATURES
• Multiply/Divide Unit
• Two 16-bit capture modules with 8-bit prescalers
• Four pulse train generators with 16-bit prescalers
• Full duplex UART
• MICROWIRE/PLUS™ serial port with interrupt
• 16 kbytes of on-board ROM
• 512 bytes of on-board RAM
• Multi-Input Wakeup pins (8) optionally usuable hardwareinterrupts either on falling or rising edge
• Two 16-bit timers, each with two 16-bit autoreload/capture registers supporting:
— Processor independent PWM mode
— External Event counter mode
— Input Capture mode
• Low EMI
• Two power saving modes: HALT and IDLE
• Fourteen multi-source vectored interrupts
• Software selectable I/O options
• Package:
— 68 PLCC with 56 I/O pins
CAPTURE TIMERS
With its two high speed, high resolution capture timers, theCOP888GW is ideally suited high resolution frequency mea-surement. To give a feeling for the capabilities, Table 1shows the capture timers resolution versus the measuredsignal freuency with a processor clock (CKI) of 10 MHz. Thesampling rate is CKI divided by a 8-bit prescaler. In the table,the prescaler is set to 1 to allow maximum performance. Thisresults in a maximum resolution of 100 ns.
TABLE 1. Capture Timer Resolution vs SignalFrequency
Resolution/16 14 12 10 8
Bits
Max.Frequency
152Hz
610Hz
2.4kHz
9.6kHz
39kHz
The capture timer can be used for a closed loop control in aDC motor. One of the standard COP888 timers (T1 or T2)generates a PWM signal to control the motor. One of thecapture timer modules measures the actual RPM of the mo-tor. A simple algorithm is used to adjust the motor’s speed tothe desired value.
Figure 1 shows a block diagram of a closed loop DC motorcontrol with one capture and one PWM timer. The MOSFETX1 acts as a low-side driver for the motor and controls thecurrent flow. The current through the motor is proportional tothe duty cycle of the PWM signal, generated by T1, at thegate of X1. An optical disk, in conjunction with an LED/phototransistor senses the motor’s RPM. The pulses generated bythe photo transistor are directly fed to the capture timer’s in-put. The capture timer inputs are alternate functions ofPort-L. This I/O-port features integrated schmitt trigger in-puts eliminating the need for external signal conditioning ofthe input signals.
SOFTWARE MODULES
The following section provides a guide to general purposemacros and subroutines to set-up the capture timer and thestandard timers T1 to T2. The fuctions are written as of mac-ros so the user can easily include them in the applicationsoftware.
CAPTURE TIMERS
Capture Timers Setup Routine
This routine sets the capture timer module CCM1 or CCM2to allow input capture of a signal on the respective port pin.
MICROWIRE/PLUS™, M2CMOS™, COPS™ microcontrollers, NeuFuz™ are trademarks of National Semiconductor Corporation.
AN012376-1
FIGURE 1. Closed Loop DCMotor Control Block Diagram
National SemiconductorApplication Note 982Martin EmbacherApril 1995
CO
P888G
WFeatures
andA
pplicationsA
N-982
© 1998 National Semiconductor Corporation AN012376 www.national.com
Additionally the I/O pins Port L6 for CCM1 and Port L7 forCCM2 are configured as inputs. This macro should beplaced in a separate macro file and included in the sourcecode after the processor specific include file. Figure 2 showsthe source code to include the macros in the applicationsprogram.
The macro is called in the source code as:
__CT __SETUP , __MODULE, __PRESCALER, __EDGE,__INTR
__MODULE is the capture module number
1 = capture module 1
2 = capture module 2
__PRESCALER is the prescaler value the range is 0 to 255.
EDGE selects the input capture edge
0 = rising edge
1 = falling edge
__INTR select if capture interrupt is used
0 = disable capture interrrupt
1 = enable capture interrrupt
The macro will check that all values are in the acceptablerange and warn the user if this is not the case.
An example of the generated code is shown below. Themacro is called to setup capture timer 1 with a prescaler of100 (dec) to capture signals on a falling edge without thegeneration of an interrupt.
Special attention is needed if the interrupts are enabled inthe macro by setting the __INTR directive to one. An appro-priate interrupt handler must be placed elsewhere in thecode. The macro will allow the capture timer to generate in-terrupts, however it will not provide the respective interruptservice routine.
Capture Timer Read Macro
__CT __READ __MODULE __VARIABLE
__MODULE is the capture module number
1 = capture module 1
2 = capture module 2
__VARIABLE is a variable to hold the contents of the cap-ture register
Standard Timer Setup for PWM Output
__TIM __SETUP __NUMBER __CYCLE __TON __INIT
__NUMBER is the timer number
1 = timer 1
2 = timer 2
3 = timer 3
__CYCLE is the cycle time of the PWM signal the range is 0to 65535
__TON is on time of the PWM signal
__INIT is the initialization value
0 = start with low
1 = start with high
Standard Timer Glitch Free PWM Output
This macro is used to provide a glitch free switched PWMoutput with the standard COP8 PWM timer. In the macro in-terrupts are disabled to wait until a PWM cycle is completedand then reload the registers are re-written. Thisproduces — in difference to an interrupt driven routine — aglitch free output of the PWM signal.
__TIM __PWM __NUMBER __CYCLE __TON
__NUMBER is the timer number
1 = timer 1
2 = timer 2
3 = timer 3
__CYCLE is the cycle time of the PWM signal the range is 0to 65535
__TON is on the time of the PWM signalNote: The source of the macros is found in Section Capture Module Macros
on page 5.
DC Motor Control Example
An example for the application of the macros is basic DCmotor closed loop control. The motor drive consists of thephases start and run. During start, the motor’s speed in-creases up to the maximum speed set by speed__max. Dur-ing run, the speed is kept around speed __max. The slope ofspeed increase is set by speed__plus and the maximum al-lowable speed increase or decrease during run is set byadj__speed. The speed update cycle time may be controlledby the IDLE timer, generating an interrupt every 4096 tC.
.incld cop888gw.inc
.incld gw_macros.inc
.sect main_prog,rom
..
..
.end
FIGURE 2. Including a Macro Into Source Code
AN012376-2
FIGURE 3. __CT__SETUP Resulting Code
www.national.com 2
Figure 4 shows the flowchart of a simple closed loop DC-motor control. The macros can be used to setup the timesand to read the current speed value.
Pulse Train Generators
The COP888GW contains four independent pulse train gen-erators designed for stepper motor control. The pulse traingenerator provides a programmable number of 50duty cycle pulses on the output pin. Depending on the exter-nal sequencer logic these timers can be used for regularstep control or for microstep driving.
If the user does not require pulse train outputs on all pins thepulse train generators can be used as four independent tim-ers with interrupt capability.
Microstepping is used in applications where the step sizeshave to be very small to allow smooth transitions from onestate to another. Special microstep drivers and motors have
been developed. These devices turn the applied pulses intocurrent steps to run the motor. The standard input of thesedrivers is a pulse train as generated by the COP888GW mi-crocontrollers. To show the basic stepper motor control cir-cuit a standard stepper motor drive circuit is discussedbased on a four-phase motor. Figure 5 shows the waveformrequired to control a standard motor. CLK is the pulse traingenerated by the pulse train generator, PH1–PH4 are theoutputs to the motor drivers. These signals can be generatedby using a simple shift/rotate register.
Figure 6 shows an application circuit for a bidirectional step-per motor. The shift register is loaded under software controland then the pulse train is started. More than one motor canbe connected in the same manner. Each motor gets its ownsequencer the setup bus signals are common for every se-quencer. Two control signals, unique for every motor, selectthe direction and the mode of the sequencer. Mode can beload new pattern, shift left and shift right. The circuit shownabove is capable of controlling low current stepper motorsused in some applications, if a higher output drive is requiredappropriate driver stages should be used.
As stepper motors usually have some inertia the pulse trainstarts up slowly and increases its frequency, under softwarecontrol, up to full step speed. The same scheme as shown inFigure 4 can be applied if increase speed is replaced by in-crease pulse train frequency and decrease speed accord-ingly to decrease pulse train frequency.
Pulse Train Generator Routines
The first routine sets up the pulse train generators PT1–PT4.Additionally the respective output pins Port E0 for PT1, PortE1 for PT2, Port E2 for PT3 and Port E3 for PT4 can be con-figured if the user needs to output the data.
Pulse Train Generator Setup
__PT __SETUP __MODULE, __PRESCALER, __PULSES,__OUT, __INTR, __RUN
__MODULE is the pulse train module number
1 = pulse train module 1
2 = pulse train module 2
3 = pulse train module 3
4 = pulse train module 4
__PRESCALER is the prescaler value the range is 0 to65535. __ PULSES selects the number of pulses: 0 to65535.
__OUT enables or disables pulse output
0 = output disabled
1 = output enabled
AN012376-3
FIGURE 4. Basic DC Motor Control Loop Flowchart
AN012376-4
FIGURE 5. Standard Stepper MotorControl Waveform (Two Phases On)
AN012376-5
FIGURE 6. Simple Stepper Motor Sequencer
www.national.com3
__INTR select if an interrupt is generated on completion ofthe pulse generation
0 = disable interrupt
1 = enable interrupt
__RUN selects if the pulses are output directly after initializa-tion or at a later time.
0 = don’t start pulse train generator
1 = start pulse train generator
The macro will check that all values are in the acceptablerange and warn the user if this is not the case.
Pulse train output:
The second routine loads a new number of pulses into thepulse train registers and starts the generation. Setting re-garding interrupts and output are not affected. The macro iscalled in the source code as:
__PT __CHANGE __MODULE,__PULSES
__MODULE is the pulse train module number
1 = pulse train module 1
2 = pulse train module 2
3 = pulse train module 3
4 = pulse train module 4
__PULSES selects the number of pulses: 0 to 65535.
MULTIPLE/DIVIDE
The device contains a multiply/divide block to speed up themultiply/divide operations. To give an idea about the speedincrease, Table 2 shows a comparison of the standardmultiply/divide operations done in software with the sameoperation performed using the MUL/DIV unit.
TABLE 2. Multiply/Divide Operation Speed
MUL/DIVMUL/DIV
BlockType of Operation Operation in
Software
Multiply 8 x 8 129 tC 11 tCMultiply 8 x 16 243 tC 11 tCDivide 8 x 8 208 tC 14 tCDivide 24 x 8 827 tC 14 tC
Note 1: Comparisons include loading the registers for the MUL/DIV blockand accordingly the RAM cells used for software multiply/divide on standardCOP8 microcontrollers. The actual 16 x 8 multiply operation takes one tC anda 24 x 16 divide takes 2 tC. However for accurate comparison the registersetup times have to taken into account.
The following section provides software modules used to setup the multiply/divide unit and to load the respective regis-ters. Although the MUL/DIV block does not allow signedarithmetic it can be used with some additional software toperform signed operations. The signed operations check fora sign in every number to be divided ormultiplied — performs a sign conversion if negative — doesthe operation and adjusts the output accordingly.Note: These software modules use constants to show the basic operation ex-
ample of loading the MUL/DIV registers. These need to be customizedin the application software.
Macro for unsigne d 8 x 16 multiply
__MUL816U __MUL1 __MUL2
__MUL1 is the 8-bit unsigned multiplier
__MUL2 is the 16-bit unsigned multiplicand
Macro for unsigned 16 x 16 divide
__DIV1616U __DIV1 __DIV2
__DIV1 is the 16-bit unsigned dividend
__DIV2 is the 16-bit unsigned divisor
Macro for signe d 6 x 16 multiply
__MUL816S __MUL1 __MUL2
__MUL1 is the 8-bit signed multiplier
__MU21 is the 16-bit signed multiplicand
Macro for signed 16 x 16 divide
__DIV1616S __DIV1 __DIV2
__DIV1 is the 16-bit unsigned dividend
__DIV2 is the 16-bit unsigned divisor
FURTHER APPLICATION HINTS
It was shown that the COP888GW with its new and en-hanced functions can operate as a system contoller in vari-ous applications. Due to the large number of I/O lines addi-tional features can be included in the system with minimalexternal hardware effort. For example it was shown in appli-cation note AN-673 how a simple two way multiplexed LCDcontrol can be done with a COP8 microcontroller. The fea-ture can be easily adopted to the COP888GW allowing sys-tem e.g. a simple plotter device to be controlled. Another ap-plication example is a climate control system, whereCOP888GW can be used to control the heating process.Control algorithms can be generated with National’s Neu-Fuz™ software package. User interfaces can be done as de-scribed above with LCD drive. Diagnostics is possible withthe on-chip UART.
www.national.com 4
CAPTURE MODULE MACROS
AN012376-6
www.national.com5
AN012376-7
www.national.com 6
STANDARD TIMER PWM SETUP MACRO
AN012376-8
www.national.com7
AN012376-9
www.national.com 8
STANDARD TIMER PWM OUTPUT MACRO
AN012376-10
www.national.com9
AN012376-11
www.national.com 10
PULSE TRAIN GENERATOR SETUP MACRO
AN012376-12
www.national.com11
AN012376-13
www.national.com 12
PULSE TRAIN GENERATOR CHANGE MACRO
AN012376-14
www.national.com13
AN012376-15
www.national.com 14
MULTIPLY/DIVIDE MACROS
AN012376-16
www.national.com15
AN012376-17
www.national.com 16
AN012376-18
www.national.com17
LIFE SUPPORT POLICY
NATIONAL’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORTDEVICES OR SYSTEMS WITHOUT THE EXPRESS WRITTEN APPROVAL OF THE PRESIDENT OF NATIONALSEMICONDUCTOR CORPORATION. As used herein:1. Life support devices or systems are devices or
systems which, (a) are intended for surgical implantinto the body, or (b) support or sustain life, andwhose failure to perform when properly used inaccordance with instructions for use provided in thelabeling, can be reasonably expected to result in asignificant injury to the user.
2. A critical component in any component of a life supportdevice or system whose failure to perform can bereasonably expected to cause the failure of the lifesupport device or system, or to affect its safety oreffectiveness.
National SemiconductorCorporationAmericasTel: 1-800-272-9959Fax: 1-800-737-7018Email: support@nsc.com
www.national.com
National SemiconductorEurope
Fax: +49 (0) 1 80-530 85 86Email: europe.support@nsc.com
Deutsch Tel: +49 (0) 1 80-530 85 85English Tel: +49 (0) 1 80-532 78 32Français Tel: +49 (0) 1 80-532 93 58Italiano Tel: +49 (0) 1 80-534 16 80
National SemiconductorAsia Pacific CustomerResponse GroupTel: 65-2544466Fax: 65-2504466Email: sea.support@nsc.com
National SemiconductorJapan Ltd.Tel: 81-3-5639-7560Fax: 81-3-5639-7507
AN012376-19
AN
-982
CO
P88
8GW
Feat
ures
and
App
licat
ions
National does not assume any responsibility for use of any circuitry described, no circuit patent licenses are implied and National reserves the right at any time without notice to change said circuitry and specifications.
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements,and other changes to its products and services at any time and to discontinue any product or service without notice. Customers shouldobtain the latest relevant information before placing orders and should verify that such information is current and complete. All products aresold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment.
TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI’s standardwarranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except wheremandated by government requirements, testing of all parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products andapplications using TI components. To minimize the risks associated with customer products and applications, customers should provideadequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right,or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Informationpublished by TI regarding third-party products or services does not constitute a license from TI to use such products or services or awarranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectualproperty of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompaniedby all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptivebusiness practice. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additionalrestrictions.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids allexpress and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is notresponsible or liable for any such statements.
TI products are not authorized for use in safety-critical applications (such as life support) where a failure of the TI product would reasonablybe expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governingsuch use. Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications, andacknowledge and agree that they are solely responsible for all legal, regulatory and safety-related requirements concerning their productsand any use of TI products in such safety-critical applications, notwithstanding any applications-related information or support that may beprovided by TI. Further, Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products insuch safety-critical applications.
TI products are neither designed nor intended for use in military/aerospace applications or environments unless the TI products arespecifically designated by TI as military-grade or "enhanced plastic." Only products designated by TI as military-grade meet militaryspecifications. Buyers acknowledge and agree that any such use of TI products which TI has not designated as military-grade is solely atthe Buyer's risk, and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use.
TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products aredesignated by TI as compliant with ISO/TS 16949 requirements. Buyers acknowledge and agree that, if they use any non-designatedproducts in automotive applications, TI will not be responsible for any failure to meet such requirements.
Following are URLs where you can obtain information on other Texas Instruments products and application solutions:
Products Applications
Audio www.ti.com/audio Communications and Telecom www.ti.com/communications
Amplifiers amplifier.ti.com Computers and Peripherals www.ti.com/computers
Data Converters dataconverter.ti.com Consumer Electronics www.ti.com/consumer-apps
DLP® Products www.dlp.com Energy and Lighting www.ti.com/energy
DSP dsp.ti.com Industrial www.ti.com/industrial
Clocks and Timers www.ti.com/clocks Medical www.ti.com/medical
Interface interface.ti.com Security www.ti.com/security
Logic logic.ti.com Space, Avionics and Defense www.ti.com/space-avionics-defense
Power Mgmt power.ti.com Transportation and Automotive www.ti.com/automotive
Microcontrollers microcontroller.ti.com Video and Imaging www.ti.com/video
RFID www.ti-rfid.com
OMAP Mobile Processors www.ti.com/omap
Wireless Connectivity www.ti.com/wirelessconnectivity
TI E2E Community Home Page e2e.ti.com
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265Copyright © 2011, Texas Instruments Incorporated
top related