Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture – 6 PIC18 Family Hardware Specifications 1.

Similar presentations


Presentation on theme: "Lecture – 6 PIC18 Family Hardware Specifications 1."— Presentation transcript:

1 Lecture – 6 PIC18 Family Hardware Specifications 1

2 Outline Pin-outs and basic operating characteristics – Microcontroller packages – Power Supply Connections – I/O Connections – Reset – Clock I/O port pins Introduction to interrupt. Other internal peripherals – Timers – ADC – Data EEPROM 2

3 Microcontroller packages The PIC18 microcontroller has many versions, ranging from an 18-pin package to a l28-pin package. The microcontroller is manufactured in the following packages: – PDIP (plastic dual inline package), – SOIC (small outline integrated circuit), – PLCC (plastic lead less chip carrier), – QFN (quad flat no-lead), – QFP (quad flat pack), – TQFP (thin quad flat pack), – LQFP (low profile quad flat pack), and – SSOP (small shrink outline package). All of these packages, except the PDIP and PLCC, are designed for surface mounting and are not used for prototypical work. The PDIP is typically used for prototypical work, and surface mount packages are used for production. 3

4 Microcontroller packages 4 In general, I/O is limited to Ports A and B on the 18-pin PDIP versions; to Ports A, B, and C on the 28-pin versions; and to Port A, B, C, D, and E on the 40-pin versions.

5 Pinouts 5

6 Power Supply Connections The power supply connections are VDD for connection to a nominal +5.0 V power supply (this can be as low as 4.2 V for maximum speed operation) and VSS for connection to ground. In all cases, the maximum allowable supply voltage is listed as +7.5 V. These voltages allow a wide variety of power sources, including batteries. A low power version (PIC18L) is available that allows the VDD voltage to be as low as 2.5 V for full speed operation. The amount of power supply current is determined by the clocking frequency and can range from 60 uA when operated with a 31 KHz clock to 12 mA or higher when operated at 40 MHz. The absolute maximum current is 300 mA and the maximum device power dissipation is 1 W. 6

7 I/O Connections The I/O characteristics are important for interfacing. The maximum total allowable chip current is 200 mA with up to 25 mA per pin as long as 200 mA is not exceeded for the entire chip and the output does not connect to logic circuitry inputs. Generally, the amount of current at an output pin is sufficient to drive four standard TIL unit loads and 10 high-speed CMOS unit loads. 7 I/O characteristics with VDD = +5.0 volts.

8 Reset To properly operate the microcontroller it must be reset correctly. The MCLR input pin is the master clear input that initializes the microcontroller so that it begins operation by fetching an instruction from memory location zero, which is called the reset vector address. The master clear input is enabled with the #pragma config MCLRE = ON statement in C language. The microcontroller is also reset under the following conditions in addition to grounding the master clear input: – A watchdog timer reset (WDT), – A programmed brownout reset (BOR), – The RESET instruction (a Reset( ) function call in C language), – A stack full reset, – A stack underflow reset. 8

9 Watchdog timer The watchdog timer (WDT) is an internal counter that resets a microcontroller after a given period of time. This timer is programmable and the WDT can be enabled or disabled using #pragma commands or with software in a program. In C language, the #pragma config statement is often used to enable or disable the WDT for an entire software system. The WDT operates at a clock time of 4 ms that is generated by an internal oscillator. The WDT scaled from 1 to 32K and operates between 4 ms and 131 seconds. 9

10 Brownout Reset The brownout reset (BOR) restarts the system whenever the power supply voltage drops below a pre-programmed level for any reason. Once stopped by a brown out reset, the microcontroller does not restart until the power supply goes higher than the pre-programmed level. The voltage drop might be caused by an overload or, if battery powered, by a weak battery. The BOR reset prevents software errors in low power situations. The BOR is enabled with a BOR = ON or disabled with a BOR = OFF configuration value. 10

11 Stack Resets The stack never overflows or underflows during normal program operation. If a system program becomes erratic for whatever reason, the stack can underflow or overflow. The underflows are caused by too many returns or pops, and the overflows are caused by too many function calls or pushes. If one of these errors occurs, the system automatically resets if the stack reset is enabled. The stack reset is enabled/disabled with a #pragma config STVR = ON/OFF statement. An overflow occurs if more than 31 return addresses are placed on the stack, and an underflow occurs if too many return addresses are removed from the stack. 11

12 Sleep A microcontroller is placed into a sleep state or mode by using either the Sleep() function in C language or the SLEEP instruction in assembly language. In the sleep mode, the microcontroller's oscillator is turned off and the program stops operating to minimize the power consumption. This is useful in battery-operated systems. During the sleep mode, the watchdog timer can be programmed to continue running so when the watchdog times out, the microcontroller wakes from the sleep state. Events that generate an interrupt will also wake the microcontroller from the sleep mode because an interrupt also exits the sleep mode. 12

13 Clock The microcontroller is a synchronous system that requires a timing source or clock to operate. Most PIC18 family members have the feature of selecting the clock input, which is provided from up to 10 different sources. The oscillator determines the execution speed of the microcontroller and is used in determining time delays and other events inside of the microcontroller. To select the operation of the clock, the configuration bits are programmed. 13

14 Clock sources The clock sources are: – Low-power crystal (LP) – Crystal or ceramic resonator (XT) – High-speed crystal or ceramic resonator (HS) – High-speed crystal or ceramic resonator with PLL (HSPLL) – External resister/capacitor with Fosc/4 output on OSC2 (RC) – External resister/capacitor with I/O on OSC2 (RCIO) – Internal oscillator with Fosc/4 on RA6 and I/O on RA7 (INTIO1) – Internal oscillator with I/O on RA6 and RA7 (INTIO2) – External clock with Fosc/4 (EC) – External clock with I/O on RA6 (ECIO) 14

15 Clock sources The first four modes use an external crystal or ceramic resonator connected to the OCS1 and OSC2 pins on the microcontroller. These are the most common ways to provide a clock to the microcontroller. If a crystal is used, a parallel resonant crystal not a series resonant, must be selected. Series resonant crystals are rarely used in a system design. 15

16 Clock circuits 16 A crystal or ceramic resonator as the clock input RC circuit A close approximation of the operating frequency is 1/(4.2RC)

17 I/O port pins The I/O pins on the PICl8 are grouped into 8-bit ports that vary in number from one family member to another. All versions contain Ports A and B, and other versions contains Ports C to J. An I/O port contains – a TRIS register for programming the direction of the port pins, – a PORT register for reading or writing to a port, and – a port LAT register for writing to an internal port latch. Many versions also contain an ADCONl register that programs port pins for either analog or digital operation. 17

18 Example TRISBbits.TRISB3 0; // program RB3 as output TRISBbits.TRISB5 0; // program RB5 as output PORTA = 0x45; // Port A is 0x45 PORTBbits.RB3 = 0; // RB3 = 0 PORTBbits.RB5 = 1; // RB5 = 1 This example shows how to write a 0x45 to Port A, a zero to Port B bit 3, and a one to Port B bit 5. 18

19 Introduction to interrupts (1) An interrupt is either a hardware or software event that is initiated when a function call interrupts the currently executing program. Because an interrupt calls a function, the point of interruption is placed on the program stack so a return will return to the point of interruption at the end of the interrupt function. The function called by the interrupt is often referred to as an interrupt service function (ISF) or an interrupt service procedure (ISP). In the PIC18 family, only two such directly accessed functions can actually exist in a system because only two interrupt vectors are available. An interrupt vector is the address of an interrupt service procedure. 19

20 Introduction to interrupts (2) In either the low- or high-priority interrupt service procedure, the cause or source of the interrupt is determined by testing the interrupt flag bits, which are located in various interrupt control registers. This testing of the interrupt flags for a particular interrupt is often called polling and is used to prioritize multiple interrupts to either the high or low interrupt vector. When an interrupt is detected by the microcontroller, the corresponding global interrupt enable bit is cleared, blocking an interrupt of equal or lower level. If a high-priority interrupt occurs, no other interrupt is possible until its global interrupt enable bit is set, which may at times be forced from within the interrupt. If a low-priority interrupt occurs, it can be interrupted by a high-priority interrupt. 20

21 Timers The microcontroller contains four or five timers that are used for many tasks. Some of these tasks include: – pre-scaling clock signals, – generating signals of multiple frequencies, – causing interrupts at a specific time. A timer is a counter, which operates from the internal instruction cycle clock or external clock input. For each instruction cycle or external clock, the timer counts and, if it hits its the maximum count and rolls over to zero (called an overflow), an interrupt cycle is initiated. 21

22 ADC The ADC converts an analog input voltage into a digital number. Most PIC18 family members contain a 10-bit converter that converts the analog input to a digital value. The converter also has up to 16 inputs, depending on the family member. These inputs are used to monitor voltages from different sources. Three control registers (ADCONO, ADCONI, and ADCON2) define the operation of the ADC. The ADCONl register determines whether the Port A and B input pins function as either digital or analog inputs. 22

23 V step calculation The converter is a 10-bit converter on most versions of the microcontroller which resolves the input voltage to 1024 levels. V step calculation is as follows: Example: 23

24 Data EEPROM The data EEPROM is available on many versions of the microcontroller and is used to store persistent data. Passwords, setup information, or any other type of data that is stored long term is stored in the data EEPROM. Two sizes of on-chip data EEPROMs are currently available: 256 or 1024 bytes. The 256-byte device is accessed though a single 8-bit address placed in the EEADR register and the 1024-byte device uses two 8-bit address registers for access EEADR and EEADRH. EEADR holds the low order 8-bit of the 10-bit address and EEADRH holds the upper 2 bits of the address. 24

25 Summary The PIC18 is manufactured in various sizes from an 18-pin PDIP to a 128- pin TQFP package The power supply to the PIC18 can be as low as 4.2 V for full-speed operation, with a current of up to 60 uA for a low clock speed to 12 mA for a 40 MHz operation. The output drive current is sufficient for four standard TTL unit loads to 10 MOS unit loads. The microcontroller is reset without any components if the power supply rises to 5.0 V quickly (0.05 ms), otherwise it is often reset using an external resister/capacitor combination and a reset pushbutton. 25

26 Summary The microcontroller is reset by the watchdog timer reset (WDT), a brownout reset (BOR), the RESET instruction (a Reset() in C), a stack full reset, a stack underflow reset, or by the rest circuit. The watchdog timer is a programmable counter that resets the microprocessor if it is allowed to overflow. The amount of overflow time is adjustable and can range as high as 131 seconds. The brownout reset is programmed to reset the micro controller if the power supply voltage drops below a predefined point. 26

27 Summary If the stack is overflowed or under flowed, the microcontroller can be programmed to reset. The clock for the PIC18 can be from an external source, a crystal oscillator or resonator, an RC timing circuit, or an internal oscillator. The #pragma config statement specifies the configuration of the microcontroller in a C program The I/O pins on the PICl8 are grouped into 8-bit ports that vary in number from one family member to another. All versions contain Ports A and B, and other versions contains Poe C to J. 27

28 Summary An I/O port contains a TRIS register for programming the direction of the port pins, a PORT register for reading or writing to a port, and a port LAT register for writing to an internal port latch. An interrupt is a function call caused by either a hardware signal or some internal event. When an interrupt occurs, the microcontroller uses either the high or low priority interrupt vector for calling an interrupt service procedure. The interrupt structure is controlled by several registers that program the priority level, indicate the status, and also enable or disable an interrupt. 28

29 Summary The timers are used to cause an interrupt when they overflow, or count synchronous or asynchronous events. The microcontroller contains a la-bit analog-to-digital converter that has up to 16 channels of input data. The data EEPROM is not memory as are the SRAM data register file or the program memory. The data EEPROM is accessed as if it were an I/O device through an address register and a data register. 29


Download ppt "Lecture – 6 PIC18 Family Hardware Specifications 1."

Similar presentations


Ads by Google