v2.0.0
Modules | Macros | Functions
pico_multicore
High Level APIs

Adds support for running code on, and interacting with the second processor core (core 1). More...

## Modules
| fifo
| Functions for the inter-core FIFOs.
| doorbell
| Functions related to doorbells which a core can use to raise IRQs on itself or the other core.
| lockout
| Functions to enable one core to force the other core to pause execution in a known state.

## Macros
#define | SIO_FIFO_IRQ_NUM(core)
| Returns the irq_num_t for the FIFO IRQ on the given core. More...

## Functions
void | multicore_reset_core1 (void)
| Reset core 1. More...
void | multicore_launch_core1 (void(*entry)(void))
| Run code on core 1. More...
void | multicore_launch_core1_with_stack (void(*entry)(void), uint32_t *stack_bottom, size_t stack_size_bytes)
| Launch code on core 1 with stack. More...
void | multicore_launch_core1_raw (void(*entry)(void), uint32_t *sp, uint32_t vector_table)
| Launch code on core 1 with no stack protection. More...

## Detailed Description

Adds support for running code on, and interacting with the second processor core (core 1).

## Example

#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
#define FLAG_VALUE 123
void core1_entry() {
multicore_fifo_push_blocking(FLAG_VALUE);
uint32_t g = multicore_fifo_pop_blocking();
if (g != FLAG_VALUE)
printf("Hmm, that's not right on core 1!\n");
else
printf("Its all gone well on core 1!");
while (1)
tight_loop_contents();
}
int main() {
stdio_init_all();
printf("Hello, multicore!\n");
multicore_launch_core1(core1_entry);
// Wait for it to start up
uint32_t g = multicore_fifo_pop_blocking();
if (g != FLAG_VALUE)
printf("Hmm, that's not right on core 0!\n");
else {
multicore_fifo_push_blocking(FLAG_VALUE);
printf("It's all gone well on core 0!");
}
}
multicore_fifo_push_blocking
void multicore_fifo_push_blocking(uint32_t data)
Push data on to the write FIFO (data to the other core).
Definition: multicore.c:34
multicore_fifo_pop_blocking
uint32_t multicore_fifo_pop_blocking(void)
Pop data from the read FIFO (data from the other core).
Definition: multicore.c:53
multicore_launch_core1
void multicore_launch_core1(void(*entry)(void))
Run code on core 1.
Definition: multicore.c:155
tight_loop_contents
static __force_inline void tight_loop_contents(void)
No-op function for the body of tight loops.
Definition: platform.h:67
stdio_init_all
bool stdio_init_all(void)
Initialize all of the present standard stdio types that are linked into the binary.
Definition: stdio.c:200
multicore.h
stdio.h
stdlib.h

## Macro Definition Documentation

## ◆ SIO_FIFO_IRQ_NUM

#define SIO_FIFO_IRQ_NUM | ( |  | core | ) |

Returns the irq_num_t for the FIFO IRQ on the given core.

On RP2040 each core has a different IRQ number: `SIO_IRQ_PROC0` and `SIO_IRQ_PROC1`. On RP2350 both cores share the same irq number (`SIO_IRQ_PROC`) just with a different SIO interrupt output routed to that IRQ input on each core.

Note this macro is intended to resolve at compile time, and does no parameter checking

## Function Documentation

## ◆ multicore_launch_core1()

void multicore_launch_core1 | ( | void(*)(void) | entry | ) |

Run code on core 1.

Wake up (a previously reset) core 1 and enter the given function on core 1 using the default core 1 stack (below core 0 stack).

core 1 must previously have been reset either as a result of a system reset or by calling multicore_reset_core1

core 1 will use the same vector table as core 0

Parameters

  entry | Function entry point

See also
  multicore_reset_core1

## ◆ multicore_launch_core1_raw()

void multicore_launch_core1_raw | ( | void(*)(void) | entry,
|  | uint32_t * | sp,
|  | uint32_t | vector_table
| ) |  |

Launch code on core 1 with no stack protection.

Wake up (a previously reset) core 1 and start it executing with a specific entry point, stack pointer and vector table.

This is a low level function that does not provide a stack guard even if USE_STACK_GUARDS is defined

core 1 must previously have been reset either as a result of a system reset or by calling multicore_reset_core1

Parameters

  entry | Function entry point
  sp | Pointer to the top of the core 1 stack
  vector_table | address of the vector table to use for core 1

See also
  multicore_reset_core1

## ◆ multicore_launch_core1_with_stack()

void multicore_launch_core1_with_stack | ( | void(*)(void) | entry,
|  | uint32_t * | stack_bottom,
|  | size_t | stack_size_bytes
| ) |  |

Launch code on core 1 with stack.

Wake up (a previously reset) core 1 and enter the given function on core 1 using the passed stack for core 1

core 1 must previously have been reset either as a result of a system reset or by calling multicore_reset_core1

core 1 will use the same vector table as core 0

Parameters

  entry | Function entry point
  stack_bottom | The bottom (lowest address) of the stack
  stack_size_bytes | The size of the stack in bytes (must be a multiple of 4)

See also
  multicore_reset_core1

## ◆ multicore_reset_core1()

void multicore_reset_core1 | ( | void |  | ) |

Reset core 1.

This function can be used to reset core 1 into its initial state (ready for launching code against via multicore_launch_core1 and similar methods)

Note
  this function should only be called from core 0