1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Vi điều khiển PSoc docx

62 284 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Chapter 1: Introduction to PSoC • Introduction • 1.1 System Overview • 1.2 CPU • 1.3 Frequency generator • 1.4 Microcontroller power consumption • 1.5 Reset • 1.6 Digital inputs and outputs • 1.7 Analog inputs and outputs • 1.8 Accessing programmable digital blocks • 1.9 Global input lines • 1.10 Digital programmable blocks • 1.11 Analog programmable blocks • 1.12 Referent voltage generators • 1.13 Switch mode pump • 1.14 MAC • 1.15 Decimator • 1.16 I2C controller • 1.17 Interrupt controller • 1.18 Address space Introduction When developing more complex projects, there is often a need for additional peripheral units, such as operational and instrument amplifiers, filters, timers, digital logic circuits, AD and DA convertors, etc. As a general rule, implementation of the extra peripherals brings in additional difficulties: new components take space, require additional attention during production of a printed circuit board, increase power consumption All of these factors can significantly affect the price and development cycle of the project. The introduction of PSoC microcontrollers has made many engineers’ dream come true of having all their project needs covered in one chip. PSoC: Programmable System on Chip PSoC (Programmable System on Chip) represents a whole new concept in microcontroller development. In addition to all the standard elements of 8-bit microcontrollers, PSoC chips feature digital and analog programmable blocks, which themselves allow implementation of large number of peripherals. Digital blocks consist of smaller programmable blocks that can be configured to allow different development options. Analog blocks are used for development of analog 1 elements, such as analog filters, comparators, intrumentational (non–)inverting amplifiers, as well as AD and DA convertors. There’s a number of different PSoC families you can base your project upon, depending on the project requirements. Basic difference between PSoC families is the number of available programmable blocks and the number of input/output pins. Number of components that can be devised is primarily a function of the available programmable blocks. Depending on the microcontroller family, PSoC chips have 4– 16 digital blocks, and 3–12 analog programmable blocks. Characteristics of PSoC microcontrollers Some of the most prominent features of PSoC microcontrollers are: • MAC unit, hardware 8x8 multiplication, with result stored in 32-bit accumulator, • Changeable working voltage, 3.3V or 5V, • Possibility of small voltage supply, to 1V, • Programmable frequency choice. Programmable blocks allow you to devise: • 16K bytes of programmable memory, • 256 bytes of RAM, • AD convertors with maximum resolution af 14 bits, • DA convertors with maximum resolution of 9 bits, • Programmable voltage amplifier, • Programmable filters and comparators, • Timers and counters of 8, 16, and 32 bits, • Pseudorandom sequences and CRC code generators, • Two Full-Duplex UART’s, • Multiple SPI devices, • Option for connection on all output pins, • Option for block combining, • Option for programming only the specified memory regions and write protection, • For every pin there is an option of Pull up, Pull down, High Z, Strong, or Open pin state, • Possibility of interrupt generation during change of state on any input/output pin, • I²C Slave or Master and Multi-Master up to speed of 400KHz, • Integrated Supervisory Circuit, • Built-in precise voltage reference. Is PSoC good enough for my project? Perhaps the best way to recognize the true value of PSoC microcontrollers is through comparison with other options. Major advantages of PSoC microcontroller include the following: 2 • There is no other microcontroller that has programmable voltage, instrumentational, inverting, and non-inverting amplifiers; • Hardware generators of pseudorandom and CRC code, as well as analog modulators, are unique to PSoC families; • MAC (Multiply-accumulate) is an essential part of digital signal processors, which allows implementation of digital signal processing algorithms. It’s worth noting that hardware accumulator multiplication is not a common feature of 8-bit microcontrollers; • Having the advantage of changeable working voltage doesn’t really need a comment. This feature is particularly important for development of new devices as it eliminates the need for redesigning the PCB and implementing the level translator; • Option for low voltage supply (~1V) is a tremendous advantage in battery operated systems; • Timers, counters, and PWM units are more flexible than the usual implementation; • Automatic code writing for accessing all the peripherals in use; • In case you need a larger array of components, there is an option for dynamic reconfiguration, allowing you to change peripherals during run-time. In this way, it’s possible to minimize the processor workload at an time, leaving the largest part of the job to the specialized hardware. On the other hand, there are certain limitations of PSoC that could influence the choice of microcontroller for your design. • In systems which require highly precise or fast measurement, problems may occur with analog device characteristics. In this case, you should analyze if speed of AD convertors and offset/noise of analog amplifiers are able to satisfy the project demands. • Analog components do not have the ability to work with usual negative supply voltage. For example, zero voltage for inverting amplifiers is taken to be the analog ground AGND (usually 2.5V). All voltages above AGND are taken as positive, while voltages below AGND are taken as negative. • Most PSoC microcontrollers have 256 bytes of RAM, which could prove to be insuficient for some projects. 1.1 System overview PSoC microcontrollers are based on 8-bit CISC architecture. Their general structure with basic blocks is presented in the following image: 3 CPU unit is the main part of a microcontroller whose purpose is to execute program instructions and control workflow of other blocks. Frequency generator facilitates signals necessary for CPU to work, as well as an array of frequencies that are used by programmable blocks. These signals could be based on internal or external referent oscillator. Reset controller enables microcontroller start action and brings a microcontroller to regular state in the case of irregular events. Watch Dog timer is used to detect software dead-loops. Sleep timer can periodically wake up microcontroller from power saving modes. It could be also used as a regular timer. Input-Output pins enable communication between the CPU unit, digital and analog programmable blocks and outside world. Digital programmable blocks are used to configure digital programmable components which are selected by user. Analog programmable blocks are used to configure analog components, like AD and DA converters, filters, DTMF receivers, programmable, instrumental, inverting, non-inverting and operational amplifiers. Interrupt controller handles necessary operations in the case of interrupts. I2C controller Enables hardware realization of an I2C communication. 4 Voltage reference is vital for the work of analog components that reside inside of analog programmable blocks. MAC unit is used for operations of hardware signed multiplication of 8-bit numbers. SMP is a system which can be used as a part of a voltage regulator. For example, it is possible to supply power to a PSoC microcontroller from a single 1.5V battery. 1.2 CPU During the programming, instructions are stored in program (FLASH) memory in a way which is familiar to microcontroller. CPU fetches one instruction at a time from program memory, decodes it and executes appropriate operations. CPU unit has internal registers PC, SP, A, X and F, as well as ALU unit and instruction decoding unit, that are associated to instruction execution process. Internal Registers of CPU Program counter (PC) is used as a pointer to the next program instruction that should be executed. With each new instruction value of program counter is being set to point on the next instruction in program memory, which is going to be decoded and executed. Stack pointer (SP) points to the address of SRAM memory where data is written to or read from in case of PUSH and POP instructions respectively. When these instructions occur value stored in SP is internally incremented or decremented. Accumulator register (A) is the main register which handles all arithmetical, logical or data transfer operations. Index register (X) could behave as register A in large number of instructions. Also, register X is used in the case of index addressing. Flag register (F) contains bits which describe result of a previously executed instruction. It also has a role during selection of a RAM memory page in case when PSoC microcontroller has more than 256 bytes of RAM. Bit Flag Zero (Z) marks that accumulator stores a zero, while Carry (C) marks that there has been carrying during arithmetic or logic operations. 5 Arithmetic logic unit (ALU) is a standard part of a CPU, which is used for arithmetic operations like addition, subtracting and shifting (left or right), as well as logic operations. Data handled by instructions could be stored in internal registers A and X, or in RAM data memory 1.3 Frequency generator Frequency generator is vital to CPU unit functioning, as well as programmable blocks. Each of programmable components has certain demands regarding speed. PSoC microcontrollers have a system for generation of different frequency signals, which is done by graphically selecting appropriate parameters. Picture shows two independent systems for generating signals SYSCLK and CLK 32k. SYSCLK is the main internal clock signal with a speed of 24MHz. It is used as a reference clock for most of other signals. SYSCLKx2 is a clock signal with double frequency (48MHz) of SYSCLK signal. 24V1 is a signal derived by dividing frequency SYSCLK with parameter N1, which varies in range from 1 to 16. 24V1 frequency equals SYSCLK/N1, with a frequency from 1.5MHz (N1=16) to 24MHz (N1=1). 24V2 is a signal derived by dividing 24MHz frequency with parameter N1, which varies in range between 1 and 16. 24V2 signal frequency equals SYSCLK/N1N2., which means that possible frequency ranges from 93.75kHz (N1,N2=16) to 24MHz (N1,N2=1). 24V3 signal is derived by dividing frequency of one of the signals 24V2, 24V1, SYSCLK or SYSCLKx2, with number N, in the range from 1 to 256. 6 CPU_CLK is used as a CPU unit frequency which has a direct impact on instruction execution speed. CPU_CLK can have any of eight frequencies that are in range from 93.75MHz to 24MHz. Frequency 24V1, 24V2, 24V3 and CPUCLK selection is done easily, by setting appropriate parameters in Device Editor or during program runtime by selecting three lower bits of OSCCR0 register. CLK32K is a slow signal with a frequency of 32kHz. It can be used as a programmable component input. It can also be used for Sleep timer wake-up operation in the case when other SYSCLK derived signals are inactive. Signal SYSCLK can be acquired using internal main oscillator (IMO), while CLK32K signal is acquired through internal local oscillator (ILO). Fault tolerance of 2.5% in the case of internal frequency generation, is the limit factor in a precise timing applications. In such case external SYSCLK clock reference should be used. External frequency ranges from 1 to 24MHz. It connects to PSoC through pin P1[4]. Similar situation is in the case of CLK32K, which also can be generated by internal local oscillator (ILO), as said before, or more precise external 32kHz oscillator. In the both cases microcontroller starts with internal frequency generators, after which is necessary to satisfy appropriate procedure. 1.4 Microcontroller power consumption Processor signal frequency CPUCLK is directly connected with the instruction execution speed of the microcontroller. Doubling the frequency, program executes approximately twice faster. On the other hand, higher frequency doesn’t necessary always mean better overall performances. Main disadvantage in rising the frequency is it’s unwanted effect on microcontroller power consumption, which is one of the main problems it the case of battery supply. Other disadvantage of higher frequency is more intensive generation of electromagnetic interference, which may affect on surrounding devices. Because of these problems general rule should be applied, which says that lowest possible satisfactory frequency should be used. Default value of PSoC microcontroller signal frequency is 3MHz, which is a compromise between speed and consumption. To maintain the longest possible uninterrupted work time, it is an imperative to bring power consumption to its lowest satisfactory functional level in battery operated devices. Most of microcontrollers operate only periodically, while being in the idle state for the most of their time. Major power saving can be achieved by bringing microcontroller to sleep mode while microcontroller does no important role. Saving is achieved because of all the frequencies, except CPU32K and SLEEP become inactive, while processor stops instruction execution. Microcontroller could be woken up from sleep mode only by reset or a interrupt. Interrupt could be generated by a sleep timer or some digital block which use CPU_32k frequency. Also GPIO pin or analog column interrupts can be used for CPU waking-up. Sleep timer represents a special counter whose main role is to generate 7 periodic interrupts which enable waking microcontroller from power saving mode. Sleep timer frequency interrupt ranges from 1 to 512Hz. After waking microcontroller does all needed operations after which it’s being switched back to sleep mode and waits for another sleep timer interrupt. There is a appropriate type of interrupt needed to wake the microcontroller from sleep mode. Because of possibility for various irregularities to occurs during the work of microcontroller there is a need to reset it in those cases, or in other words, brought to beginning state. Begin state means all internal registers are initialized and program continues its execution from beginning. 1.5 Reset POR During the work of microcontroller, supply voltage variations occurs. It is very dangerous if voltage drops beneath certain limit, because microcontroller can make some unpredictable actions. In the case of such voltage drop detection, microcontroller is switched into Power on Reset mode in which it remains until voltage stabilizes above critical limit which is defined by Trip Voltage parameter. XRES External reset allows user to bring microcontroller to start state by switching a button. Reset is achieved when XRES pin reads logic ONE. Simplest reset circuit can be made with pull-down resistor and one switch. WDR Watch dog reset (WDR) is used for avoiding software dead-loops or other irregularities, bringing the system in the start state. Using WDR, it is watch dog timer (WDT) is periodically restarted inside of a main program, after which appropriate subprograms are executed. In normal mode after certain time WDT is being restarted once again and subprogram cycle continues. But, if program blocks in one of the subprograms WDT is not reset, and WDR occurs. 8 1.6 Digital Inputs and Outputs Connection between a PSoC microcontroller with an outside world is achieved over input-output pins. Eight pin group which could be accessed simultaneously are parts of one port. Although port number differs from the type of the microcontroller, write and read operations are done in the same way in any case. Port access registers are stored inside of register address space noted as PRT0DR, PRT1DR, PRT2DR, PRT3DR, PRT4DR or PRT5DR. Writing to port Writing value to PRTxDR initializes register which through init circuit drives the state of pins. Init circuit can pass the signal from PRTxDR register directly (strong), over pull-up or pull-down resistors or through open drain output. Beside that, there is a possibility to isolate value of register from pin state (Hi-Z). Reading port Reading value from address PRTxDR digital state of voltage on pins is stored to register A. In case that voltage is dictated by some external device, read value could differ from voltage on PRTxDR register. Drive Mode Selection of the way in which init register PRTxDR is connected to pins can be set inside of Device Editor or during runtime initializing registers PRTxDM2, PRTxDM1 and PRTxDM0. There is eight methods to initialize pins in total, which enables connection to different types of devices, with considerate smaller amount of external 9 components. Pin work modes are defined according to the following table depending on contents of appropriate bit from registers DM2, DM1 and DM0. DM2 bit DM1 bit DM0 bit Mode Data = 0 Data = 1 0 0 0 Resistive Pull Down Resistive Strong 0 0 1 Strong Drive Strong Strong 0 1 0 High Impedance Hi-Z Hi-Z 0 1 1 Resistive Pull Up Strong Resistive 1 0 0 Open Drain, Drives High Hi-Z Strong (Slow) 1 0 1 Slow Strong Drive Strong (Slow) Strong (Slow) 1 1 0 High Impedance Analog Hi-Z Hi-Z 1 1 1 Open Drain, Drives Low Strong (Slow) Hi-Z Strong mode is used when it is needed to connect the state on PRTxDR register directly to pins. This way of connection is applied when pin is used as an input. Analog Hi-Z mode is used when connecting analog signals, like AD converter input. In this case, all internal connections between PRTxDR register and pin are disconnected, so not to interfere with value of brought voltage. Pull-up or pull-down resistors are used when connecting with buttons or some other devices which demand this type of components. These resistors are defining the state on input when button is not pushed. Open drain mode is used when it is needed to bring several devices to the same line, when it is needed to add one external pull-up or pull-down resistor. This mode is convenient for realization of a line which signals if there has been a mistake to one of the microcontrollers. For example, when used pull-up resistor version when zero (error) occurs on any of output pins state of this line will be zero. Pins on PSoC 10 [...]... the family of PSoC microcontrollers and is 2, 4, 8, 16 and 32 kB Supervisory ROM Supervisory ROM is part of ROM which is used during start of PSoC microcontroller, as well as for calibration of components With special instruction SSC, it is possible access this part of memory RAM RAM enables storing of variables and stack which are used during work of microcontroller Size of RAM, in most PSoC microcontrollers,... familiar with two main parts of PSoC Designer: • • Device Editor Application Editor Beside these two, there is also a debugger part, but during the course of this book it is only mentioned as an option, because it demands additional hardware Device editor consists of two windows First one is for selection and is called User Module selection View Other, is called Interconnection View It is used for setting... programmable blocks V1 signal frequency value can be derived by dividing system frequency of 24MHz with prescaler N1 V2 signal frequency value is aquired by dividng signal V1 with N2 Acquiring signal V3 is done in similar fashion, by dividing some signal with value in N3, with possibility to choose from several different signals the one that will be divided CPU_Clock represents frequency value, based on who... Interconnection View It is used for setting and connecting components and parameter adjustment Transfering from one to the other part of the PSoC Designer is done easily by clicking appropriate icon To open Interconnection View or User Module Select windows, Device Editor icon must be selected first Lower image shows look of the programmable component choice window 2.1 Programmable Component Selection... the component he uses, because this part holds all necessary information 2.2 Interconnection View Previously selected components are still unusable, until they are placed in digital or analog programmable blocks, and until appropriate parameters are set This important part of work can be done in Interconnection View window Central part of this window is graphical representation of programmable blocks... and M8C_SetBank1, which delete or set bit XIO in CPU_F register *************************** - 23 Chapter 2: PSoC Designer • • • • Introduction 2.1 Programmable Component Selection 2.2 Interconnection View 2.2 Application Editor Introduction PSoC Designer is program package that leads user through all stages of developing project Version discussed here will be 4.2, but this... some variable, user apart from 8-bit address must state appropriate page Register Register address space contains registers used for peripheral's global parameters and programmable blocks of a PSoC microcontroller PSoC microcontrollers have 512 registers, which are grouped in two 256 bytes banks To access some register, beside stating its name, what is needed is to also state the name of the bank in which... Inside of digital programmable blocks user can configure components like timers, counters, PWM, PRS, CRC generators and devices for SPI, IrDA and UART communication, which enables custom hardware adjustment of the system for specific uses The process of setting and connecting using PSoC Designer is very simple to understand, but at first is necessary to understand the way those components function Most... is selected through the multiplexer 1.12 Referent voltage generators There are three stable voltage generators in PSoC microcontroller: • • • AGND RefH RefLo AGND is ground voltage for analog components Voltage values higher than AGND are considered as positive, while less are negative PSoC microcontrollers have oneside power supply, so value of analog ground is somewhere in between GND and VDD AGND... voltage, for AD and DA components PSoC microcontrollers have a system that can generate several referent signal values AGND, RefHi and RefLo This enables simple adjustment to different types of voltage sensors Referent voltages are made from internal temperature stabilized bandgap voltage reference Vbg = 1.3V, supply voltage VDD or external signal as shown in the following table PSoC microcontrollers are well . project. The introduction of PSoC microcontrollers has made many engineers’ dream come true of having all their project needs covered in one chip. PSoC: Programmable System on Chip PSoC (Programmable. 400KHz, • Integrated Supervisory Circuit, • Built-in precise voltage reference. Is PSoC good enough for my project? Perhaps the best way to recognize the true value of PSoC microcontrollers is. AGND are taken as negative. • Most PSoC microcontrollers have 256 bytes of RAM, which could prove to be insuficient for some projects. 1.1 System overview PSoC microcontrollers are based on

Ngày đăng: 07/07/2014, 11:20

TỪ KHÓA LIÊN QUAN

w