Datasheet

Table Of Contents
17 jmp y-- incr
18 mov isr, ~x
19 push
A full 32-bit addition takes only around one minute at 125 MHz. The program pops two numbers from the TX FIFO and
pushes their sum to the RX FIFO, which is perfect for use either with the system DMA, or directly by the processor:
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/pio/addition/addition.c Lines 1 - 35
Ê1 /**
Ê2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
Ê3 *
Ê4 * SPDX-License-Identifier: BSD-3-Clause
Ê5 */
Ê6
Ê7 #include <stdlib.h>
Ê8 #include <stdio.h>
Ê9
10 #include "pico/stdlib.h"
11 #include "hardware/pio.h"
12 #include "addition.pio.h"
13
14 // Pop quiz: how many additions does the processor do when calling this function
15 uint32_t do_addition(PIO pio, uint sm, uint32_t a, uint32_t b) {
16 pio_sm_put_blocking(pio, sm, a);
17 pio_sm_put_blocking(pio, sm, b);
18 return pio_sm_get_blocking(pio, sm);
19 }
20
21 int main() {
22 setup_default_uart();
23
24 PIO pio = pio0;
25 uint sm = 0;
26 uint offset = pio_add_program(pio, &addition_program);
27 addition_program_init(pio, sm, offset);
28
29 printf("Doing some random additions:\n");
30 for (int i = 0; i < 10; ++i) {
31 uint a = rand() % 100;
32 uint b = rand() % 100;
33 printf("%u + %u = %u\n", a, b, do_addition(pio, sm, a, b));
34 }
35 }
3.7. Outdated Examples
RP2040 Datasheet
3.7. Outdated Examples 361