Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
;
; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
;
; SPDX-License-Identifier: BSD-3-Clause
;
; SET pin 0 should be mapped to your LED GPIO
.program blink
;.origin 0
.define public SM_CYCLE 1000000
.define public Out_PIN 25
pull block
out y, 32
pull block
out ISR, 32
.wrap_target
mov x, ISR
set pins, 1 ; Turn LED on
lp1:
jmp x-- lp1 ; Delay for (x + 1) cycles, x is a 32 bit number
mov x, Y
set pins, 0 ; Turn LED off
lp2:
jmp x-- lp2 ; Delay for the same number of cycles again
.wrap ; Blink forever!
% c-sdk {
// this is a raw helper function for use by the user which sets up the GPIO output, and configures the SM to output on a particular pin
#include "hardware/clocks.h"
void static inline blink_program_init(PIO pio, uint sm, uint offset, uint pin, uint freq) // frequency in kHz
{
// Initialise pin clear output enable and output valúe
pio_gpio_init(pio, pin);
//set consecutive pin direction
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
// get pio_sm_config
pio_sm_config c = blink_program_get_default_config(offset);
//calculate divisor to reduce state machine cycle
float div = (float)clock_get_hz(clk_sys) / (freq*1000);
sm_config_set_clkdiv(&c, div);
sm_config_set_set_pins(&c, pin, 1);
pio_sm_init(pio, sm, offset, &c);
}
%}
f5f7d1f75This file is pinned to the selected release. Download the original to open it in your design tool.