System and Application Architecture

Functional Requirements

Mapping the System to Scade One and RP2040 

What runs in the Scade One Model

Scade One handles the entire application logic: 

  • 3-state state machine (LowFreq: 262 Hz, MidFreq: 523 Hz, HighFreq: 1047 Hz) that advances on each falling edge of the button 
  • FED operator (Falling Edge Detection): detects when the button is released 
  • Output: 32-bit unsigned integer (swan_uint32) representing the frequency in Hz 
  • Types used: swan_bool (boolean), swan_uint32 (uint32_t) 
What remains specific to the Platform 

In addition to the Scade One logic, we must read the BOOTSEL button (with the get_bootsel_button function) to have direct access to QSPI registers. 

The Pico SDK allows use to use functions (init_pwmapply_freq) to initialize and control the PWM device. 

Then, we must calculate the WRAP register value based on the frequency: wrap = 125 000 000/ (clkdiv × freq) -1. The wrap refers to the moment when a counter resets to zero after reaching its maximum value. We will detail the calculation later in the document. 

Also, we must manage the execution cycle with sleep_ms(10), and the stdio initialization. 

Finally, we need the swan_config.h file to map Swan types to stdint/stdbool types (refer to the first tutorial).