400 likes | 496 Views
dsPIC30F4011. High-Performance, Modified RISC CPU: Modified Harvard architecture C compiler optimized instruction set architecture with flexible addressing modes 83 base instructions 24-bit wide instructions, 16-bit wide data path 48 Kbytes on-chip Flash program space (16K instruction words)
E N D
High-Performance, Modified RISC CPU: • Modified Harvard architecture • C compiler optimized instruction set architecture with flexible addressing modes • 83 base instructions • 24-bit wide instructions, 16-bit wide data path • 48 Kbytes on-chip Flash program space (16K instruction words) • 2 Kbytes of on-chip data RAM • 1 Kbyte of nonvolatile data EEPROM • Up to 30 MIPS operation: • DC to 40 MHz external clock input • 4 MHz-10 MHz oscillator input with PLL active (4x, 8x, 1 6x) • 30 interrupt sources: • 3 external interrupt sources • 8 user-selectable priority levels for each interrupt source • 4 processor trap sources • 16 x 16-bit working register array
The core has a 24-bit instruction word. The Program Counter (PC) is 23 bits wide with the Least Significant bit (LSb) always clear and the Most Significant bit (MSb) is ignored during normal program execution, except for certain specialized instructions. Thus, the PC can address up to 4M instruction words of user program space. • The working register array consists of 16x16-bit registers, each of which can act as data, address or offset registers. One working register (W15) operates as a software Stack Pointer for interrupts and calls. • The data space is 64 Kbytes (32K words) and is split into two blocks, referred to as X and Y data memory. Each block has its own independent Address Generation Unit (AGU). Most instructions operate solely through the X memory, AGU, which provides the appearance of a single, unified data space. The Multiply-Accumulate (MAC) class of dual source DSP instructions operate through both the X and Y AGUs, splitting the data address space into two parts. • Each data word consists of 2 bytes, and most instructions can address data either as words or bytes. • Program loop constructs, free from loop count management overhead, are supported using the DO and REPEAT instructions, both of which are interruptible at any point.
Data Accessing • The upper 32 Kbytes of data space memory can be mapped into the lower half (user space) of program space at any 16K program word boundary, defined by the 8-bit Program Space Visibility Page (PSVPAG) register. This lets any instruction access program space as if it were data space, with a limitation that the access requires an additional cycle. Moreover, only the lower 16 bits of each instruction word can be accessed using this method. • SWWLinear indirect access of 32K word pages within program space is also possible, using any working register via table read and write instructions. Table read and write instructions can be used to access all 24 bits of an instruction word.
Overhead-free circular buffers (Modulo Addressing) are supported in both X and Y address spaces. This is primarily intended to remove the loop overhead for DSP algorithms. • The X AGU also supports Bit-Reversed Addressing on destination effective addresses, to greatly simplify input or output data reordering for radix-2 FFT algorithms. • For most instructions, the core is capable of executing a data (or program data) memory read, a working register (data) read, a data memory write and a program (instruction) memory read per instruction cycle. As a result, 3-operand instructions are supported, allowing C = A + B operations to be executed in a single cycle.
DSP Engine • The DSP engine consists of a high-speed, 17-bit x 17-bit multiplier, a barrel shifter and a 40-bit adder/ subtracter (with two target accumulators, round and saturation logic). • The dsPIC3OF devices have a single instruction flow which can execute either DSP or MCU instructions. Many of the hardware resources are shared between the DSP and MCU instructions. For example, the instruction set has both DSP and MCU multiply instructions which use the same hardware multiplier. • The DSP engine also has the capability to perform inherent accumulator-to-accumulator operations which require no additional data. These instructions are ADD, SUB and NEG. • The DSP engine has various options selected through various bits in the CPU Core Configuration register (CORCON), as listed below: • Fractional or integer DSP multiply (IF). • Signed or unsigned DSP multiply (US). • Conventional or convergent rounding (RND). • Automatic saturation on/off for ACCA (SATA). • Automatic saturation on/off for ACCB (SATB). • Automatic saturation on/off for writes to data memory (SATDW). • Accumulator Saturation mode selection (ACCSAT).
The output of the 1 7x1 7-bit multiplier! scaler is a 33-bit value, which is sign-extended to 40 bits. Integer data is inherently represented as a signed two’s complement value, where the MSB is defined as a sign bit. • When the multiplier is configured for fractional multiplication, the data is represented as a two’s complement fraction, where the MSB is defined as a sign bit and the radix point is implied to lie just after the sign bit (QX format). • Saturation and Overflow modes: • Bit 39 Overflow and Saturation: • When bit 39 overflow and saturation occurs, the saturation logic loads the maximally positive 9.31 (Ox7FFFFFFFFF) or maximally negative 9.31 value (0x8000000000) into the target accumulator. The SA or SB bit is set and remains set until cleared by the user. This is referred to as ‘super saturation’ and provides protection against erroneous data or unexpected algorithm problems (e.g., gain calculations). • Bit 31 Overflow and Saturation: • When bit 31 overflow and saturation occurs, the saturation logic then loads the maximally positive 1.31 value (OxOO7FFFFFFF) or maximally negative 1.31 value (0x0080000000) into the target accumulator. The SA or SB bit is set and remains set until cleared by the user. When this Saturation mode is in effect, the guard bits are not used (so the OA, OB or DAB bits are never set). • Bit 39 Catastrophic Overflow • The bit 39 overflow Status bit from the adder is used to set the SA or SB bit, which remain set until cleared by the user. No saturation operation is performed and the accumulator is allowed to overflow (destroying its sign). If the COVTE bit in the INTCON1 register is set, a catastrophic overflow can initiate a trap exception.
Rounding • Conventional rounding takes bit 15 of the accumulator, zero-extends it and adds it to the ACCxH word (bits 16 through 31 of the accumulator). If the ACCxL word (bits 0 through 15 of the accumulator) is between 0x8000 and OxFFFF (0x8000 included), ACCxH is incremented. If ACCxL is between Ox0000 and Ox7FFF, ACCxH is left unchanged. A consequence of this algorithm is that over a succession of random rounding operations. the value tends to be biased slightly positive. • Convergent (or unbiased) rounding operates in the same manner as conventional rounding, except when ACCxL equals 0x8000. If this is the case, the LSb (bit 16 of the accumulator) of ACCxH is examined. If it is ‘1’, ACCxH is incremented. If it is ‘0’, ACCxH is not modified. Assuming that bit 16 is effectively random in nature, this scheme removes any rounding bias that may accumulate. • BARREL SHIFTER • The barrel shifter is capable of performing up to 16-bit arithmetic or logic right shifts, or up to 16-bit left shifts in a single cycle. The source can be either of the two DSP accumulators or the X bus (to support multi-bit shifts of register or memory data).
PROGRAM SPACE MEMORY MAP FORdsPIC3OF4O11I4O12 • The program address space is 4M instruction words. It is addressable by the 23-bit PC, table instruction Effective Address (EA) or data space EA, when program space is mapped into data space as defined by Table 3-1. Note that the program space address is incremented by two between successive program words in order to provide compatibility with data space addressing. • User program space access is restricted to the lower 4M instruction word address range (Ox000000 to Ox7FFFFE) for all accesses other than TBLRD/TBLWT, which use TBLPAG<7> to determine user or configuration space access. In Table 3-1, read/write instructions, bit 23 allows access to the Device ID, the User ID and the Configuration bits; otherwise, bit 23 is always clear.
DATA ACCESS FROM PROGRAM MEMORY • This architecture fetches 24-bit wide program memory. Consequently, instructions are always aligned. However, as the architecture is modified Harvard, data can also be present in program space. • There are two methods by which program space can be accessed; • via special table instructions, or • through the remapping of a 16K word program space page into the upper half of data space
DATA ACCESS FROM PROGRAM MEMORY • The PC is incremented by two for each successive 24-bit program word. This allows program memory addresses to directly map to data space addresses. Program memory can thus be regarded as two, 16-bit word-wide address spaces, residing side by side, each with the same address range. TBLRDL and TBLWTL access the space which contains the least significant data word, and TBLRDH and TBLWTH access the space which contains the Most Significant Byte of data. • Program space access through the data space occurs if the MSb of the data space EA is set and program space visibility is enabled by setting the PSV bit in the Core Control register (CORCON). • Data accesses to this area add an additional cycle to the instruction being executed, since two program fetches
Timer 0 • The Timer0 module timer/counter has the following • features: • 8-bit timer/counter • Readable and writable • 8-bit software programmable prescaler • Internal or external clock select • Interrupt on overflow from FFh to 00h • Edge select for external clock • Figure 5-1 is a block diagram of the Timer0 module and the prescaler shared with the WDT. • Timer mode is selected by clearing bit T0CS • (OPTION_REG<5>). In Timer mode, the Timer0 module will increment every instruction cycle (without prescaler). If the TMR0 register is written, the increment is inhibited for the following two instruction cycles. The user can work around this by writing an adjusted value to the TMR0 register.
TIMER 1 MODULE • The Timer1 module is a 16-bit timer/counter consisting of two 8-bit registers (TMR1H and TMR1L) which are readable and writable. • The TMR1 register pair (TMR1H:TMR1L) increments from 0000h to FFFFh and rolls over to 0000h. • The TMR1 interrupt, if enabled, is generated on overflow which is latched in interrupt flag bit, TMR1IF (PIR1<0>). This interrupt can be enabled/disabled by setting/clearing TMR1 interrupt enable bit, TMR1IE (PIE1<0>). • Timer1 can operate in one of two modes: • As a Timer • As a Counter
TIMER 1 MODULE • Counter mode is selected by setting bit TMR1CS. In this mode, the timer increments on every rising edge of clock input on pin RC1/T1OSI/CCP2 when bit T1OSCEN is set, or on pin RC0/T1OSO/T1CKI when bit T1OSCEN is cleared. • If T1SYNC is cleared, then the external clock input is synchronized with internal phase clocks. • If control bit T1SYNC (T1CON<2>) is set, the external clock input is not synchronized.
TIMER 2 MODULE • Timer 2 is an 8-bit timer with a prescaler and a postscaler. It can be used as the PWM time base for the PWM mode of the CCP module(s). The TMR2 register is readable and writable and is cleared on any device Reset.
CAPTURE/COMPARE/PWM MODULES • Each Capture/Compare/PWM (CCP) module contains a 16-bit register which can operate as a: • 16-bit Capture register • 16-bit Compare register • PWM Master/Slave Duty Cycle register • In Capture mode, CCPR1H:CCPR1L captures the 16-bit value of the TMR1 register when an event occurs on pin RC2/CCP1. An event is defined as one of the following: • Every falling edge • Every rising edge • Every 4th rising edge • Every 16th rising edge
CAPTURE/COMPARE/PWM MODULES • In Compare mode, the 16-bit CCPR1 register value is constantly compared against the TMR1 register pair value. When a match occurs, the RC2/CCP1 pin is: • Driven high • Driven low • Remains unchanged • In Pulse Width Modulation mode, the CCPx pin produces up to a 10-bit resolution PWM output. Since the CCP1 pin is multiplexed with the PORTC data latch, the TRISC<2> bit must be cleared to make the CCP1 pin an output. • Note: Clearing the CCP1CON register will force the CCP1 PWM output latch to the default low level. This is not the PORTC I/O data latch.
Master SSP (MSSP) Module • The Master Synchronous Serial Port (MSSP) module is a serial interface, useful for communicating with other peripheral or microcontroller devices. These peripheral devices may be serial EEPROMs, shift registers, • display drivers, A/D converters, etc. The MSSP module can operate in one of two modes: • Serial Peripheral Interface (SPI) • Inter-Integrated Circuit (I2C) • Full Master mode • Slave mode (with general address call) • The I2C interface supports the following modes in hardware: • Master mode • Multi-Master mode • Slave mode
ADDRESSABLE UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER (USART) • The Universal Synchronous Asynchronous Receiver Transmitter (USART) module is one of the two serial I/O modules. (USART is also known as a Serial Communications Interface or SCI.) • The USART can be configured as a full-duplex asynchronous system that can communicate with peripheral devices, such as CRT terminals and personal computers, or • it can be configured as a half-duplex synchronous system that can communicate with peripheral devices, such as A/D or D/A integrated circuits, serial EEPROMs, etc.
ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE • The Analog-to-Digital (A/D) Converter module has five inputs for the 28-pin devices and eight for the 40/44-pin devices. The conversion of an analog input signal results in a corresponding 10-bit digital number. The A/D module has high and low-voltage reference input that is software selectable to some combination of VDD, VSS, RA2 or RA3.
COMPARATOR MODULE • The comparator module contains two analog comparators. The inputs to the comparators are multiplexed with I/O port pins RA0 through RA3, while the outputs are multiplexed to pins RA4 and RA5. The on-chip voltage reference (Section 13.0 “Comparator Voltage Reference Module”) can also be an input to the comparators. • Comparator Configuration • There are eight modes of operation for the comparators. The CMCON register is used to select these modes. Figure 12-1 shows the eight possible modes. The TRISA register controls the data direction of the comparator pins for each mode. If the Comparator
Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin. • Additional information on I/O ports may be found in the PICmicro™ Mid-Range Reference Manual (DS33023). • 4.1 PORTA and the TRISA Register • PORTA is a 6-bit wide, bidirectional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a • High-Impedance mode). Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin).
Port A • The write operation is read-modify-write • For Port A if the next value of PORTA depends on the previous value of PORTA, analog inputs should be selected on ADC • RA4 needs Pull-up
Port B • In general as the ports might be different, in case of problem check the port architecture
RESET • 14.4 MCLR. PIC16F87XA devices have a noise filter in the MCLR Reset path. The filter will detect and ignore small pulses. • 14.6 Power-up Timer (PWRT). The Power-up Timer provides a fixed 72 ms nominal time-out on power-up only from the POR. The Powerup Timer operates on an internal RC oscillator. The chip is kept in Reset as long as the PWRT is active. The PWRT’s time delay allows VDD to rise to an acceptable level. • 14.7 Oscillator Start-up Timer (OST). The Oscillator Start-up Timer (OST) provides a delay of 1024 oscillator cycles (from OSC1 input) after the PWRT delay is over (if PWRT is enabled). This helps to ensure that the crystal oscillator or resonator has started and stabilized. • 14.8 Brown-out Reset (BOR). The configuration bit, BODEN, can enable or disable the Brown-out Reset circuit. If VDD falls below VBOR (parameter D005, about 4V) for longer than TBOR (parameter #35, about 100 µS), the brown-out situation will reset the device. If VDD falls below VBOR for less than TBOR, a Reset may not occur. Once the brown-out occurs, the device will remain in Brown-out Reset until VDD rises above VBOR. • 14.13 Watchdog Timer (WDT). The Watchdog Timer is a free running, on-chip RC • oscillator which does not require any external components. This RC oscillator is separate from the RC oscillator of the OSC1/CLKI pin. During normal operation, a WDT time-out generates a device Reset (Watchdog Timer Reset). If the device is in Sleep mode, a WDT time-out causes the device to wake-up and continue with normal operation (Watchdog • Timer Wake-up).