1 of 60

2 of 60

Cortex M0+ -

Function

NVIC

MPU

Debug

GPIO

DMA

REQUEST

INTERRUPT

MEMORY

3 of 60

DMA

REQUEST

INTERRUPT

MEMORY

Cortex M0+

NVIC

MPU

Debug

GPIO

CORTEX M0+ & DMA

4 of 60

NVIC

MPU

Debug

GPIO

Cortex M0+

5 of 60

The ARM Cortex-M0+ processor is a very low gate count, highly energy efficient processor that is intended for microcontroller and deeply embedded applications that require an area optimized, low-power processor.

Cortex M0+

6 of 60

Cortex M0+ : Function

Discuss the features of Cortex

Intended Learning Outcome

7 of 60

Features

  • Tight integration
  • Thumb instruction set (16 bit)
  • Single-cycle I/O
  • Power control optimization
  • Integrated sleep modes
  • Fast code execution
  • Optimized code fetching
  • Hardware multiplier
  • Deterministic, high-performance interrupt
  • Deterministic instruction cycle
  • System level debug
  • Serial Wire Debug

8 of 60

Interfaces

  • External AHB-Lite interface to bus fabric
  • Debug Access Port (DAP)
  • Single-cycle I/O Port to SIO peripherals

9 of 60

Configuration

  • Architectural clock gating (disable the parts of the chip when not in use - for power saving)
  • Little Endian bus access Simplifying memory access (LSB to lowest address)

  • Four Breakpoints
  • Debug support (via 2-wire debug pins SWD/SWCLK)
  • IOPORT: This is a dedicated interface for communicating with local peripherals, such as timers, ADC, and DAC.
  • 32-bit instruction fetch (to match 32-bit data bus)

IOPORT:

10 of 60

11 of 60

Configuration

  • 26 interrupts
  • 8 MPU regions
    • (Memory Protection Unit) regions allow the microcontroller to protect different areas of memory from unauthorized access
  • All registers reset on powerup (to know the status on boot up
  • Fast multiplier (hardware)
  • SysTick timer (precise timekeeping mechanism)
  • Vector Table Offset Register (This register specifies the location of the interrupt vector table)
  • 34 WIC (Wake-up Interrupt Controller)
  • DAP (Debug Access Port, which provides a standardized interface for debugging and programming the microcontroller.)

12 of 60

Functional Description

32-bit RISC processor

13 of 60

• The ARMv6-M Thumb® instruction set.

• Thumb-2 technology.

• An ARMv6-M compliant 24-bit SysTick timer.

• A 32-bit hardware multiplier. This is the standard single-cycle multiplier

• The ability to have deterministic, fixed-latency, interrupt handling.

• Load/store multiple instructions that can be abandoned and restarted to facilitate rapid interrupt handling.

• C Application Binary Interface compliant exception model. This is the ARMv6-M, C Application Binary Interface (CABI) compliant exception model that enables the use of pure C functions as interrupt handlers.

• Low power sleep-mode entry us

Features

14 of 60

The Nested Vectored Interrupt Controller (NVIC) features are:

• 26 external interrupt inputs, each with four levels of priority.

• Dedicated Non-Maskable Interrupt (NMI) input (which can be driven from any standard interrupt source)

• Support for both level-sensitive and pulse-sensitive interrupt lines.

• Wake-up Interrupt Controller (WIC), providing ultra-low power sleep mode support. • Relocatable vector table.

NVIC features

15 of 60

  1. An IR sensor is connected to the RP2040 in GPIO7, find the address and the value to be given at the address to enable the GPIO7 as the input pin.
  2. 30 LEDs are connected across the GPIOs, find the address to turn on all the LED and write the value to be given

SIO

16 of 60

NVIC

Intended Learning Outcome

How and what registers are used in NVIC

17 of 60

NVIC

External interrupt signals connect to the Nested Vectored Interrupt Controller (NVIC), and the NVIC prioritizes the interrupts.

Software can set the priority of each interrupt. The NVIC and the Cortex-M0+ processor core are closely coupled, providing low latency interrupt processing and efficient processing of late arriving interrupts

All NVIC registers are only accessible using word transfers. Any attempt to read or write a halfword or byte individually is unpredictable.

Nested" refers to the fact that interrupts can themselves be interrupted, by higher-priority interrupts. "Vectored" refers to the hardware dispatching each interrupt to a distinct handler routine

18 of 60

SysTick timer

• A 24-bit system timer (SysTick).

• Additional configurable priority SysTick interrupt.

Low power modes

The implementation includes a WIC (Wakeup Interrupt Controller). This enables the processor and NVIC to be put into a very low-power sleep mode leaving the WIC to identify and prioritize interrupts.

The processor fully implements the Wait For Interrupt (WFI), Wait For Event (WFE) and the Send Event (SEV) instructions. In addition, the processor also supports the use of SLEEPONEXIT, that causes the processor core to enter sleep mode when it returns from an exception handler to Thread mode.

19 of 60

NVIC register summary

20 of 60

Lets talk about memory

the "0" in the last position indicates that there is no onboard non-volatile flash memory, but it still includes the 16 KB ROM for essential functions.

21 of 60

Total SRAM: 264 KB

Total ROM: 16 KB.

XIP Flash Memory: Typically up to 16 MB, though dependent on external flash.

SRAM: 264 KB

There are four 16k x 32-bit banks (64kB each) and two 1k x 32-bit banks (4kB each).

  • Striped (interleaved) SRAM0-SRAM3 (higher performance due to faster memory access).
  • Non-striped SRAM4-SRAM5 (sequential access).

Memory

22 of 60

Address Map

23 of 60

MPU

Intended Learning Outcome

How and what registers are used in MPU

24 of 60

• Eight user-configurable memory regions.

• Eight sub-region disables per region.

• Execute never (XN) support.

• Default memory map support.

MPU features

25 of 60

DEBUG

Intended Learning Outcome

Debug How to set different debugging in RP2040 using their registers

26 of 60

• Four hardware breakpoints.

• Two watchpoints.

• Program Counter Sampling Register (PCSR) for non-intrusive code profiling.

• Single step and vector catch capabilities.

• Support for unlimited software breakpoints using BKPT instruction.

• Non-intrusive access to core peripherals and zero-waitstate system slaves through a compact bus matrix. A debugger can access these devices, including memory, even when the processor is running.

• Full access to core registers when the processor is halted.

• Core Sight compliant debug access through a Debug Access Port (DAP) supporting Serial Wire debug connections.

Debug features

27 of 60

The processor is implemented with a low gate count Debug Access Port (DAP). The low gate count Debug Access Port (DAP) provides a Serial Wire debug-port, and connects to the processor slave port to provide full system-level debug access.

Debug Access Port

28 of 60

GPIO

29 of 60

DMA

Direct Memory Access

DMA:

  • Data requests,
  • Interrupts and
  • Memory

30 of 60

31 of 60

The RP2040 Direct Memory Access (DMA) controller has separate read and write master connections to the bus fabric, and performs bulk data transfers on a processor’s behalf. This leaves processors free to attend to other tasks, or enter low-power sleep states.

Direct Memory Access

Intended Learning Outcome

Illustrate Direct Memory Access

32 of 60

Direct Memory Access

32 bits in size, one read access and one write access every clock cycle

33 of 60

Memory-to-peripheral: a peripheral signals the DMA when it needs more data to transmit. The DMA reads data from an array in RAM or flash, and writes to the peripheral’s data FIFO.

Peripheral-to-memory: a peripheral signals the DMA when it has received data. The DMA reads this data from the peripheral’s data FIFO, and writes it to an array in RAM.

• Memory-to-memory: the DMA transfers data between two buffers in RAM, as fast as possible

There are 12 independent channels, each which supervise a sequence of bus transfers, usually in one of the following scenarios:

34 of 60

35 of 60

36 of 60

37 of 60

Direct Memory Access

CONTROL AND STATUS REGISTERS

TRANSFER SIZE CAN BE EITHER 32, 16, OR 8 BITS

CHAIN_TO

Making the DMA more autonomous means that much less processor supervision is required: overall this allows the system to do more at once, or to dissipate less power.

We do all these to :

38 of 60

Configuring Channels

Each channel has four control/status registers

READ_ADDR is a pointer to the next address to be read

WRITE_ADDR is a pointer to the next address to be written to

TRANS_COUNT shows the number of transfers remaining in the current transfer sequence,

CTRL is used to configure all other aspects of the channel’s behaviour, to enable/disable it, and to check for completion.

39 of 60

Configuring Channels

Read and Write Addresses

  • READ_ADDR and WRITE_ADDR contain the address the channel will next read from, and write to, respectively. (update automatically, increment by 1, 2 or 4 bytes at a time)
  • Software should generally program these registers with new start addresses each time a new transfer sequence starts. If READ_ADDR and WRITE_ADDR are not reprogrammed, the DMA will use the current values as start addresses for the next transfer.

For example:

• If the address does not increment (e.g. it is the address of a peripheral FIFO), and the next transfer sequence is to/from that same address, there is no need to write to the register again.

• When transferring to/from a consecutive series of buffers in memory (e.g. scattering and gathering), an address register will already have incremented to the start of the next buffer at the completion of a transfer.

40 of 60

Configuring Channels

Transfer Count

  • Reading from TRANS_COUNT yields the number of transfers remaining in the current transfer sequence
  • Each time the channel starts a new transfer sequence, the most recent value written to TRANS_COUNT
  • For debugging purposes, the last value written can be read from the DBG_TCR
  • If the channel is triggered multiple times without intervening writes to TRANS_COUNT, it performs the same number of transfers each time.

41 of 60

Configuring Channels

Control/Status

  • Configure the size - CTRL.DATA_SIZE
  • Configure if and how read and write - CTRL.INCR_WRITE, CTRL.INCR_READ, CTRL.RING_SEL, CTRL.RING_SIZE
  • Another channel (or none) to be triggered - CTRL.CHAIN_TO
  • Peripheral data request (DREQ) signal - CTRL.TREQ_SEL
  • See when the channel is idle - CTRL.BUSY
  • Channel has encountered a bus error - CTRL.AHB_ERROR, CTRL.READ_ERROR, or CTRL.WRITE_ERROR

42 of 60

Starting Channels

3 ways to start a channel

  • Writing to a channel trigger register
  • A chain trigger from another channel which has just completed, and has its CHAIN_TO field configured
  • The MULTI_CHAN_TRIGGER register, which can start multiple channels at once

Aliases and Triggers

43 of 60

  • The channel is disabled via CTRL.EN
  • The channel is already running
  • The value 0 is written to the trigger register

Starting Channels

Trigger registers do not start the channel if

44 of 60

Starting Channels

Chaining

  • When a channel completes, it can name a different channel to immediately be triggered. This can be used as a callback for the second channel to reconfigure and restart the first.

"ping-pong" configuration

This feature is configured through the CHAIN_TO field in the channel CTRL register.

45 of 60

Starting Channels

Null Triggers and Chain Interrupts

  • writing all-zeroes to a trigger register does not start the channel. This is called a null trigger, and it has two purposes:
    • Cause a halt at the end of an array of control blocks, by appending an all-zeroes block
    • Reduce the number of interrupts generated when control blocks are used

By default, a channel will generate an interrupt each time it finishes a transfer sequence, unless that channel’s IRQ is masked in INTE0 or INTE1

The channel CTRL register has a field called IRQ_QUIET

46 of 60

Data Request (DREQ)

Peripherals produce or consume data at their own pace. If the DMA simply transferred data as fast as possible, loss or corruption of data would ensue. DREQs are a communication channel between peripherals and the DMA, which enables the DMA to pace transfers according to the needs of the peripheral.

47 of 60

Data Request (DREQ)

Use of DREQ in DMA

Intended Learning Outcome

48 of 60

Credit-based DREQ Scheme

The RP2040 DMA is designed for systems where:

The area and power cost of large peripheral data FIFOs is prohibitive

The bandwidth demands of individual peripherals may be high, e.g. >50% bus injection rate for short periods

Bus latency is low, but multiple masters may be competing for bus access

49 of 60

Direct Memory Access

Addressing ‘em

50 of 60

Direct Memory Access

Configure ‘em

51 of 60

52 of 60

53 of 60

54 of 60

Sniff Hardware

Sniff hardware is a generic term used to describe a piece of hardware or a component in a computer system that is capable of observing, monitoring, or interacting with data transfers on specific channels or buses.

A checksum is a mathematical value calculated from the data to check for errors or verify data integrity. The statement suggests that the sniff hardware may be involved in the calculation or monitoring of this checksum as data is transferred

55 of 60

In A DMA device, what value should I write to the control and status register and at which address,

If:

  1. The DMA device is connected to channel 2
  2. There is a write error
  3. The bus is busy
  4. Sniff is enabled
  5. Half word swap is demanded
  6. Interrupt is set to be in quiet mode
  7. Transfer request is from UART0_Tx

56 of 60

In A DMA device, what value should I write to the control and status register and at which address,

If:

  1. Set chain to be in ping pong configuration with channel 4
  2. No ring configuration
  3. The operation is between a i2c and memory device.
  4. 16bit data is transferred
  5. I2c device connected must be given the top priority

57 of 60

In A DMA device, what value should I write to the control and status register and at which address,

If:

  1. The DMA device is connected to channel 4
  2. There is a read error
  3. The bus is not busy
  4. Sniff is enabled
  5. Half word swap is demanded
  6. Interrupt is set to be in quiet mode
  7. Transfer request is from UART0_Tx

58 of 60

In A DMA device, what value should I write to the control and status register and at which address,

If:

  1. Set chain to be in ping pong configuration with channel 1
  2. No ring configuration
  3. The operation is between a i2c and memory device.
  4. 16bit data is transferred
  5. I2c device connected must be given the priority next to the power interrupt

59 of 60

1

0

1

x

x

x

x

1

1

0

0

1

1

1

1

1

0

0

1

0

0

x

x

x

x

x

1

0

1

0

1

1

The DMA registers start at a base address of 0x50000000

CH2_CTRL_TRIG

31

30

29

28

27

26

25

24

23

22

21

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

60 of 60

Register name: CH1_CTRL_TRIG

Base Address: 0x50000000

Offset Address: