Microchip PIC32 datasheet: 5.0 Flash program memory

Published by Microchip · pages 85–100 of 214 · Original PDF

71 discussions about the Microchip PIC32

All 10 parts of the datasheet

5.0 FLASH PROGRAM MEMORY

Note 1: This data sheet summarizes the features of the PIC32MX3XX/4XX family of devices. It is not intended to be a comprehensive reference source. To complement the information in this data sheet, refer to Section 5. “Flash Program Memory” (DS61121) of the PIC32 Family Reference Manual, which is available from the Microchip web site (www.microchip.com/PIC32).

2: Some registers and associated bits described in this section may not be available on all devices. Refer to Section 4.0 “Memory Organization” in this data sheet for device-specific register and bit information.

PIC32MX3XX/4XX devices contain an internal program Flash memory for executing user code. There are three methods by which the user can program this memory:

• Run-Time Self Programming (RTSP) • In-Circuit Serial Programming™ (ICSP™) • EJTAG Programming

EXAMPLE 5-1:

NVMCON = 0x4004; // Enable and configure for erase operation Wait(delay); // Delay for 6 µs for LVDstartup

NVMKEY = 0xAA996655; NVMKEY = 0x556699AA; NVMCONSET = 0x8000; // Initiate operation

while(NVMCONbits.WR==1); // Wait for current operation to complete

RTSP is performed by software executing from either Flash or RAM memory. EJTAG is performed using the EJTAG port of the device and a EJTAG capable programmer. ICSP is performed using a serial data connection to the device and allows much faster programming times than RTSP. RTSP techniques are described in this chapter. The ICSP and EJTAG methods are described in the "PIC32MX Flash Programming Specification" (DS61145), which can be downloaded from the Microchip web site.

Note: Flash LVD Delay (LVDstartup) must be taken into account between setting up and executing any Flash command operation. See Example 5-1 for a code example to set up and execute a Flash command operation.

NOTES:

6.0 RESETS

Note 1: This data sheet summarizes the features of the PIC32MX3XX/4XX family of devices. It is not intended to be a comprehensive reference source. To complement the information in this data sheet, refer to Section 7. “Resets” (DS61118) of the “PIC32 Family Reference Manual”, which is available from the Microchip web site (www.microchip.com/PIC32).

2: Some registers and associated bits described in this section may not be available on all devices. Refer to Section 4.0 “Memory Organization” in this data sheet for device-specific register and bit information.

The Reset module combines all Reset sources and controls the device Master Reset signal, SYSRST. The following is a list of device Reset sources:

  • POR: Power-on Reset
  • \overlineMCLR: Master Clear Reset Pin
  • SWR: Software Reset
  • WDTR: Watchdog Timer Reset
  • BOR: Brown-out Reset
  • CMR: Configuration Mismatch Reset

A simplified block diagram of the Reset module is illustrated in Figure 6-1.

FIGURE 6-1: SYSTEM RESET BLOCK DIAGRAM

Figure from the manual

NOTES:

DS61143H-page 88 © 2011 Microchip Technology Inc.

7.0 INTERRUPT CONTROLLER

Note 1: This data sheet summarizes the features of the PIC32MX3XX/4XX family of devices. It is not intended to be a comprehensive reference source. To complement the information in this data sheet, refer to Section 8. “Interrupt Controller” (DS61108) of the PIC32 Family Reference Manual, which is available from the Microchip web site (www.microchip.com/PIC32).

2: Some registers and associated bits described in this section may not be available on all devices. Refer to Section 4.0 “Memory Organization” in this data sheet for device-specific register and bit information.

PIC32MX3XX/4XX devices generate interrupt requests in response to interrupt events from peripheral modules. The Interrupt Control module exists externally to the CPU logic and prioritizes the interrupt events before presenting them to the CPU.

The PIC32MX3XX/4XX interrupts module includes the following features:

  • Up to 96 interrupt sources
  • Up to 64 interrupt vectors
  • Single and Multi-Vector mode operations
  • Five external interrupts with edge polarity control
  • Interrupt proximity timer
  • Module Freeze in Debug mode
  • Seven user-selectable priority levels for each vector
  • Four user-selectable subpriority levels within each priority
  • Dedicated shadow set for highest priority level
  • Software can generate any interrupt
  • User-configurable interrupt vector table location
  • User-configurable interrupt vector spacing

FIGURE 7-1: INTERRUPT CONTROLLER MODULE

Figure from the manual

Note: Several of the registers cited in this section are not in the interrupt controller module. These registers (and bits) are associated with the CPU. Details about them are available in Section 3.0 “CPU”.

To avoid confusion, a typographic distinction is made for registers in the CPU. The register names in this section, and all other sections of this manual, are signified by uppercase letters only. The CPU register names are signified by upper and lowercase letters. For example, INTSTAT is an Interrupts register; whereas, IntCtl is a CPU register.

TABLE 7-1: INTERRUPT IRQ AND VECTOR LOCATION

Interrupt Source(1) IRQ Vector Number Interrupt Bit Location
Flag Enable Priority Subpriority
Highest Natural Order Priority
CT – Core Timer Interrupt 0 0 IFS0<0> IEC0<0> IPC0<4:2> IPC0<1:0>
CS0 – Core Software Interrupt 0 1 1 IFS0<1> IEC0<1> IPC0<12:10> IPC0<9:8>
CS1 – Core Software Interrupt 1 2 2 IFS0<2> IEC0<2> IPC0<20:18> IPC0<17:16>
INT0 – External Interrupt 0 3 3 IFS0<3> IEC0<3> IPC0<28:26> IPC0<25:24>
T1 – Timer1 4 4 IFS0<4> IEC0<4> IPC1<4:2> IPC1<1:0>
IC1 – Input Capture 1 5 5 IFS0<5> IEC0<5> IPC1<12:10> IPC1<9:8>
OC1 – Output Compare 1 6 6 IFS0<6> IEC0<6> IPC1<20:18> IPC1<17:16>
INT1 – External Interrupt 1 7 7 IFS0<7> IEC0<7> IPC1<28:26> IPC1<25:24>
T2 – Timer2 8 8 IFS0<8> IEC0<8> IPC2<4:2> IPC2<1:0>
IC2 – Input Capture 2 9 9 IFS0<9> IEC0<9> IPC2<12:10> IPC2<9:8>
OC2 – Output Compare 2 10 10 IFS0<10> IEC0<10> IPC2<20:18> IPC2<17:16>
INT2 – External Interrupt 2 11 11 IFS0<11> IEC0<11> IPC2<28:26> IPC2<25:24>
T3 – Timer3 12 12 IFS0<12> IEC0<12> IPC3<4:2> IPC3<1:0>
IC3 – Input Capture 3 13 13 IFS0<13> IEC0<13> IPC3<12:10> IPC3<9:8>
OC3 – Output Compare 3 14 14 IFS0<14> IEC0<14> IPC3<20:18> IPC3<17:16>
INT3 – External Interrupt 3 15 15 IFS0<15> IEC0<15> IPC3<28:26> IPC3<25:24>
T4 – Timer4 16 16 IFS0<16> IEC0<16> IPC4<4:2> IPC4<1:0>
IC4 – Input Capture 4 17 17 IFS0<17> IEC0<17> IPC4<12:10> IPC4<9:8>
OC4 – Output Compare 4 18 18 IFS0<18> IEC0<18> IPC4<20:18> IPC4<17:16>
INT4 – External Interrupt 4 19 19 IFS0<19> IEC0<19> IPC4<28:26> IPC4<25:24>
T5 – Timer5 20 20 IFS0<20> IEC0<20> IPC5<4:2> IPC5<1:0>
IC5 – Input Capture 5 21 21 IFS0<21> IEC0<21> IPC5<12:10> IPC5<9:8>
OC5 – Output Compare 5 22 22 IFS0<22> IEC0<22> IPC5<20:18> IPC5<17:16>
SPI1E – SPI1 Fault 23 23 IFS0<23> IEC0<23> IPC5<28:26> IPC5<25:24>
SPI1TX – SPI1 Transfer Done 24 23 IFS0<24> IEC0<24> IPC5<28:26> IPC5<25:24>
SPI1RX – SPI1 Receive Done 25 23 IFS0<25> IEC0<25> IPC5<28:26> IPC5<25:24>
U1E – UART1 Error 26 24 IFS0<26> IEC0<26> IPC6<4:2> IPC6<1:0>
U1RX – UART1 Receiver 27 24 IFS0<27> IEC0<27> IPC6<4:2> IPC6<1:0>
U1TX – UART1 Transmitter 28 24 IFS0<28> IEC0<28> IPC6<4:2> IPC6<1:0>
I2C1B – I2C1 Bus Collision Event 29 25 IFS0<29> IEC0<29> IPC6<12:10> IPC6<9:8>
I2C1S – I2C1 Slave Event 30 25 IFS0<30> IEC0<30> IPC6<12:10> IPC6<9:8>
I2C1M – I2C1 Master Event 31 25 IFS0<31> IEC0<31> IPC6<12:10> IPC6<9:8>
CN – Input Change Interrupt 32 26 IFS1<0> IEC1<0> IPC6<20:18> IPC6<17:16>
AD1 – ADC1 Convert Done 33 27 IFS1<1> IEC1<1> IPC6<28:26> IPC6<25:24>
PMP – Parallel Master Port 34 28 IFS1<2> IEC1<2> IPC7<4:2> IPC7<1:0>
CMP1 – Comparator Interrupt 35 29 IFS1<3> IEC1<3> IPC7<12:10> IPC7<9:8>
CMP2 – Comparator Interrupt 36 30 IFS1<4> IEC1<4> IPC7<20:18> IPC7<17:16>

Note 1: Not all interrupt sources are available on all devices. See TABLE 1: “PIC32MX General Purpose – Features” and TABLE 2: “PIC32MX USB – Features” for available peripherals.

TABLE 7-1: INTERRUPT IRQ AND VECTOR LOCATION (CONTINUED)

Interrupt Source(1) IRQ Vector Number Interrupt Bit Location
Flag Enable Priority Subpriority
Highest Natural Order Priority
SPI2E – SPI2 Fault 37 31 IFS1<5> IEC1<5> IPC7<28:26> IPC7<25:24>
SPI2TX – SPI2 Transfer Done 38 31 IFS1<6> IEC1<6> IPC7<28:26> IPC7<25:24>
SPI2RX – SPI2 Receive Done 39 31 IFS1<7> IEC1<7> IPC7<28:26> IPC7<25:24>
U2E – UART2 Error 40 32 IFS1<8> IEC1<8> IPC8<4:2> IPC8<1:0>
U2RX – UART2 Receiver 41 32 IFS1<9> IEC1<9> IPC8<4:2> IPC8<1:0>
U2TX – UART2 Transmitter 42 32 IFS1<10> IEC1<10> IPC8<4:2> IPC8<1:0>
I2C2B – I2C2 Bus Collision Event 43 33 IFS1<11> IEC1<11> IPC8<12:10> IPC8<9:8>
I2C2S – I2C2 Slave Event 44 33 IFS1<12> IEC1<12> IPC8<12:10> IPC8<9:8>
I2C2M – I2C2 Master Event 45 33 IFS1<13> IEC1<13> IPC8<12:10> IPC8<9:8>
FSCM – Fail-Safe Clock Monitor 46 34 IFS1<14> IEC1<14> IPC8<20:18> IPC8<17:16>
RTCC – Real-Time Clock and Calendar 47 35 IFS1<15> IEC1<15> IPC8<28:26> IPC8<25:24>
DMA0 – DMA Channel 0 48 36 IFS1<16> IEC1<16> IPC9<4:2> IPC9<1:0>
DMA1 – DMA Channel 1 49 37 IFS1<17> IEC1<17> IPC9<12:10> IPC9<9:8>
DMA2 – DMA Channel 2 50 38 IFS1<18> IEC1<18> IPC9<20:18> IPC9<17:16>
DMA3 – DMA Channel 3 51 39 IFS1<19> IEC1<19> IPC9<28:26> IPC9<25:24>
FCE – Flash Control Event 56 44 IFS1<24> IEC1<24> IPC11<4:2> IPC11<1:0>
USB 57 45 IFS1<25> IEC1<25> IPC11<12:10> IPC11<9:8>
Lowest Natural Order Priority

Note 1: Not all interrupt sources are available on all devices. See TABLE 1: “PIC32MX General Purpose – Features” and TABLE 2: “PIC32MX USB – Features” for available peripherals.

NOTES:

8.0 OSCILLATOR CONFIGURATION

Note 1: This data sheet summarizes the features of the PIC32MX3XX/4XX family of devices. It is not intended to be a comprehensive reference source. To complement the information in this data sheet, refer to the "PIC32 Family Reference Manual" Section 6. "Oscillator Configuration" (DS61112), which is available from the Microchip web site (www.microchip.com/PIC32).

2: Some registers and associated bits described in this section may not be available on all devices. Refer to Section 4.0 "Memory Organization" in this data sheet for device-specific register and bit information.

The PIC32MX oscillator system has the following modules and features:

  • A total of four external and internal oscillator options as clock sources
  • On-chip PLL (phase-locked loop) with user-selectable input divider, multiplier and output divider to boost operating frequency on select internal and external oscillator sources
  • On-chip user-selectable divisor postscaler on select oscillator sources
  • Software-controllable switching between various clock sources
  • A Fail-Safe Clock Monitor (FSCM) that detects clock failure and permits safe application recovery or shut down
  • Dedicated on-chip PLL for USB peripheral

FIGURE 8-1: PIC32MX3XX/4XX FAMILY CLOCK DIAGRAM

Figure from the manual

Notes:

  1. A series resistor, Rs, may be required for AT strip-cut crystals.
  2. The internal feedback resistor, Rf, is typically in the range of 2 to 10 MΩ.
  3. Refer to the "PIC32 Family Reference Manual" Section 6. "Oscillator Configuration" (DS61112) for help determining the best oscillator components.
  4. PBCLK out is available on the OSC2 pin in certain clock modes.

NOTES:

9.0 PREFETCH CACHE

Note 1: This data sheet summarizes the features of the PIC32MX3XX/4XX family of devices. It is not intended to be a comprehensive reference source. To complement the information in this data sheet, refer to Section 4. “Prefetch Cache” (DS61119) of the PIC32 Family Reference Manual, which is available from the Microchip web site (www.microchip.com/PIC32).

2: Some registers and associated bits described in this section may not be available on all devices. Refer to Section 4.0 “Memory Organization” in this data sheet for device-specific register and bit information.

Prefetch cache increases performance for applications executing out of the cacheable program Flash memory regions by implementing instruction caching, constant data caching and instruction prefetching.

9.1 Features

  • 16 Fully Associative Lockable Cache Lines
  • 16-byte Cache Lines
  • Up to four Cache Lines Allocated to Data
  • Two Cache Lines with Address Mask to hold repeated instructions
  • Pseudo LRU replacement policy
  • All Cache Lines are software writable
  • 16-byte parallel memory fetch
  • Predictive Instruction Prefetch

FIGURE 9-1: PREFETCH MODULE BLOCK DIAGRAM

Figure from the manual

NOTES:

10.0 DIRECT MEMORY ACCESS (DMA) CONTROLLER

Note 1: This data sheet summarizes the features of the PIC32MX3XX/4XX family of devices. It is not intended to be a comprehensive reference source. To complement the information in this data sheet, refer to Section 31. “Direct Memory Access (DMA) Controller” (DS61117) of the “PIC32 Family Reference Manual”, which is available from the Microchip web site (www.microchip.com/PIC32).

2: Some registers and associated bits described in this section may not be available on all devices. Refer to Section 4.0 “Memory Organization” in this data sheet for device-specific register and bit information.

The PIC32MX Direct Memory Access (DMA) controller is a bus master module useful for data transfers between different devices without CPU intervention. The source and destination of a DMA transfer can be any of the memory mapped modules existent in the PIC32MX (such as Peripheral Bus (PBUS) devices: SPI, UART, PMP, and so on) or memory itself.

Following are some of the key features of the DMA controller module:

  • Four Identical Channels, each featuring:
    • Auto-Increment Source and Destination Address Registers
    • Source and Destination Pointers
    • Memory to Memory and Memory to Peripheral Transfers
  • Automatic Word-Size Detection:
    • Transfer Granularity, down to byte level
    • Bytes need not be word-aligned at source and destination
  • Fixed Priority Channel Arbitration
  • Flexible DMA Channel Operating Modes:
    • Manual (software) or automatic (interrupt) DMA requests
    • One-Shot or Auto-Repeat Block Transfer modes
    • Channel-to-channel chaining
  • Flexible DMA Requests:
    • A DMA request can be selected from any of the peripheral interrupt sources
    • Each channel can select any (appropriate) observable interrupt as its DMA request source
    • A DMA transfer abort can be selected from any of the peripheral interrupt sources
    • Pattern (data) match transfer termination
  • Multiple DMA Channel Status Interrupts:
    • DMA channel block transfer complete
    • Source empty or half empty
    • Destination full or half-full
    • DMA transfer aborted due to an external event
    • Invalid DMA address generated
  • DMA Debug Support Features:
    • Most recent address accessed by a DMA channel
    • Most recent DMA channel to transfer data
  • CRC Generation Module:
    • CRC module can be assigned to any of the available channels
    • CRC module is highly configurable

FIGURE 10-1: DMA BLOCK DIAGRAM

Figure from the manual

NOTES:

DS61143H-page 98 © 2011 Microchip Technology Inc.

11.0 USB ON-THE-GO (OTG)

Note 1: This data sheet summarizes the features of the PIC32MX3XX/4XX family of devices. It is not intended to be a comprehensive reference source. To complement the information in this data sheet, refer to Section 27. “USB On-The-Go (OTG)” (DS61126) of the PIC32 Family Reference Manual, which is available from the Microchip web site (www.microchip.com/PIC32).

2: Some registers and associated bits described in this section may not be available on all devices. Refer to Section 4.0 “Memory Organization” in this data sheet for device-specific register and bit information.

The Universal Serial Bus (USB) module contains analog and digital components to provide a USB 2.0 full-speed and low-speed embedded host, full-speed device, or OTG implementation with a minimum of external components. This module in Host mode is intended for use as an embedded host and therefore does not implement a UHCI or OHCI controller.

The USB module consists of the clock generator, the USB voltage comparators, the transceiver, the Serial Interface Engine (SIE), a dedicated USB DMA controller, pull-up and pull-down resistors, and the register interface. A block diagram of the PIC32MX USB OTG module is presented in Figure 11-1.

The clock generator provides the 48 MHz clock required for USB full-speed and low-speed communication. The voltage comparators monitor the voltage on the VBUS pin to determine the state of the bus. The transceiver provides the analog translation between the USB bus and the digital logic. The SIE is a state machine that transfers data to and from the endpoint buffers, and generates the hardware protocol for data transfers. The USB DMA controller transfers data between the data buffers in RAM and the SIE. The integrated pull-up and pull-down resistors eliminate the need for external signaling components. The register interface allows the CPU to configure and communicate with the module.

The PIC32MX USB module includes the following features:

  • USB Full-Speed Support for Host and Device
  • Low-Speed Host Support
  • USB OTG Support
  • Integrated Signaling Resistors
  • Integrated Analog Comparators for VBUS Monitoring
  • Integrated USB Transceiver
  • Transaction Handshaking Performed by Hardware
  • Endpoint Buffering Anywhere in System RAM
  • Integrated DMA to Access System RAM and Flash

Note: The implementation and use of the USB specifications, as well as other third-party specifications or technologies, may require licensing; including, but not limited to, USB Implementers Forum, Inc. (also referred to as USB-IF). The user is fully responsible for investigating and satisfying any applicable licensing obligations.

FIGURE 11-1: PIC32MX3XX/4XX FAMILY USB INTERFACE DIAGRAM

Figure from the manual

Note 1: PB clock is only available on this pin for select EC modes. 2: Pins can be used as digital inputs when USB is not enabled. 3: This bit field is contained in the OSCCON register. 4: This bit field is contained in the OSCTRM register. 5: USB PLL UFIN requirements: 4 MHz. 6: This bit field is contained in the DEVCFG2 register. 7: A 48 MHz clock is required for proper USB operation. 8: Pins can be used as GPIO when the USB module is disabled.

Text converted from the manufacturer's document. A □ marks a character that could not be read in the original. Back to the Microchip PIC32 discussions