Chapter 2
PIC32 Microcontroller Series
Abstract
This chapter is an introduction to the hardware of the PIC32 family of microcontrollers. The architecture of the popular PIC32MX360F512L microcontroller is taken as an example in this chapter. The program and data memory structure, reset circuitry, clock sources, I/O port characteristics, real-time clock module, and various timer modules offered by the chip are described in detail. In addition, the important topic of interrupts is covered and the interrupt mechanisms and interrupt sources of the PIC32 family of microcontrollers are described. Finally, the analogue input structure and the ADC module of the PIC32MX360F512L microcontroller are given with examples to show how this microcontroller can be used in analogue input applications.
Keywords
32-Bit microcontrollers
Architecture of the PIC32 family
Program memory
Data memory
The power supply
Reset mechanisms
Clock modules
I/O ports
Timer modules
Interrupts
Priorities
ADC converter
Chapter Outline
PIC32 is a 32-bit family of general-purpose, high-performance microcontrollers manufactured by Microchip Technology Inc. Looking at the PIC microcontroller development history, based on their performance, we can divide the PIC microcontroller families into low-performance, low-to-medium–performance, medium-performance, and high-performance devices.
Low-performance PIC microcontrollers consist of the basic 8-bit PIC10 and PIC16 series of devices that have been around for over a decade. These devices are excellent general-purpose low-speed microcontrollers that have been used successfully in thousands of applications worldwide.
The PIC18 series of microcontrollers were then introduced by Microchip Technology Inc. as low-to-medium–performance devices for use in high–pin count, high-density, complex applications requiring large number of I/O ports, large program and data memories, and supporting complex communication protocols such as CAN, USB, TCP/IP, or ZigBee. Although these devices are also based on 8-bit architecture, they offer higher speeds, from DC to 40 MHz, with a performance rating of up to 10 MIPS.
The PIC24 series of microcontrollers are based on 16-bit architecture and have been introduced as medium-performance devices to be used in applications requiring high compatibility with lower-performance PIC microcontroller families, and at the same time offering higher throughput and complex instruction sets. These microcontrollers have been used in many real-time applications such as digital signal processing, automatic control, speech and image processing, and so on, where higher accuracy than 8 bits is required, and at the same time higher speed is the main requirement.
PIC32 microcontroller family has been developed for high-performance, general-purpose microcontroller applications. The family offers 80 MIPS performance with a wide range of on-chip peripherals, large data and program memories, large number of I/O ports, and an architecture designed for high-speed real-time applications. PIC32 microcontrollers can be used in real-time applications requiring high throughput. Some of the application areas are digital signal processing, digital automatic control, real-time games, and fast communication. The chip employs the industry standard M4K MIPS32 core from MIPS Technologies Inc. PIC32 family offers programming interface similar to other PIC microcontroller families, thus making the programming an easy task if the programmer is already familiar with the basic PIC microcontroller architecture. PIC32 microcontrollers are pin-to-pin compatible with most members of the PIC24 family of 16-bit microcontrollers; thus, the migration from 16- to 32-bit operation should be relatively easy.
Figure 2.1 shows a simplified architectural overview of the PIC32 microcontrollers. At the heart of the microcontroller is a 32-bit M4K MIPS32 core processor that connects to the rest of the chip via a
bus matrix and a
peripheral bus. The bus matrix runs at the same speed as the core processor and connects various high-speed modules such as the USB, DMA, memory, ports, and so on. The peripheral bus can be programmed to run at slower speeds, and it connects to slower modules such as A/D converter, UART, SPI, Real-Time Clock and Calendar (RTCC), and so on.
Figure 2.1Simplified Architecture of the PIC32 Microcontroller Family
The core processor has the following features:
• 80 MHz clock speed
• 32-Bit address bus and 32-bit data bus
• Five-stage pipelining
• Single-cycle ALU
• Single-cycle multiply and high-speed divide module
• 2 × 32 register files
Other important features of the chip are the following:
• 2.3–3.6 V operation
• Up to 512k flash program memory
• Up to 32k SRAM data memory
• Internal oscillators
• Multiple interrupt vectors
• UART, SPI, and I2C modules
• Configurable watchdog timer and real-time clock
• High-speed I/O with 18 mA current sink/source capability
• Configurable open-drain output on I/O pins
• External interrupt pins
• PWM, capture, and compare modules
• JTAG debug interface
• Fast A/D converter and analogue comparator modules
• Timers and counters
• Hardware DMA channels
• USB support
• Large pin count for a wide range of peripherals and I/O ports
• Wide operating temperature (-40 to +105°C)
Different chips in the family may have additional features, such as Ethernet support, CAN bus support, and so on.
Perhaps the best way of learning the PIC32 microcontroller family architecture is to look at a typical processor in the family in greater detail. In this book, the Digilent Cerebot MX3cK Development Board (has been renamed to chipKIT MX3) will be used. This board is equipped with the PIC32MX320F128H microcontroller (from the PIC32MX3XX/4XX family). In this chapter, we shall be looking at the architecture of the PIC32MX360F512L microcontroller from the same family. The architectures of other members of the PIC32 microcontroller family are very similar to the chosen one and should not be too difficult to learn them.
2.1. The PIC32MX360F512L Architecture
The PIC32MX360F512L is a typical PIC32 microcontroller, belonging to the family PIC32MX3XX/4XX. This microcontroller has the following features:
• A 100-pin (TQFP) package
• Up to 80 MHz clock speed
• 512k flash program memory (+12k boot flash memory)
• 32k data memory
• 5 × 16-bit timers/counters
• 5 × capture inputs
• 5 × compare/PWM outputs
• Four programmable DMA channels
• 2 × UARTs (supporting RS232,...