Skip to content

PIO code of 32 instructions compiles but fails to run #272

@GitJer

Description

@GitJer

When I make a PIO program of 32 instructions it compiles just fine, but when I then upload it (with vscode and debugger) it fails to execute with the error message (I changed the path):

assertion "program->length < PIO_INSTRUCTION_COUNT" failed: file "path_to/pico-sdk/src/rp2_common/hardware_pio/pio.c", line 64, function: _pio_find_offset_for_program

Is it due to the debugger?

The PIO code is (I know I could've used nops or something):

.program tester

label0:
    jmp label1
label1:
    jmp label2
label2:
    jmp label3
label3:
    jmp label4
label4:
    jmp label5
label5:
    jmp label6
label6:
    jmp label7
label7:
    jmp label8
label8:
    jmp label9
label9:
    jmp label10
label10:
    jmp label11
label11:
    jmp label12
label12:
    jmp label13
label13:
    jmp label14
label14:
    jmp label15
label15:
    jmp label16
label16:
    jmp label17
label17:
    jmp label18
label18:
    jmp label19
label19:
    jmp label20
label20:
    jmp label21
label21:
    jmp label22
label22:
    jmp label23
label23:
    jmp label24
label24:
    jmp label25
label25:
    jmp label26
label26:
    jmp label27
label27:
    jmp label28
label28:
    jmp label29
label29:
    jmp label30
label30:
    jmp label31
label31:
    jmp label0

The c-code is:

#include <stdio.h>

#include "pico/stdlib.h"
#include "hardware/pio.h"

#include "tester.pio.h"

int main()
{
    // the pio instance
    PIO pio;
    // the state machine
    uint sm;

    // needed for printf
    stdio_init_all();

    // pio 0 is used
    pio = pio0;
    // state machine 0
    sm = 0;
    // load the pio program into the pio memory
    uint offset = pio_add_program(pio, &tester_program);
    // make a sm config
    pio_sm_config c = tester_program_get_default_config(offset);
    // init the pio sm with the config
    pio_sm_init(pio, sm, offset, &c);
    // enable the sm
    pio_sm_set_enabled(pio, sm, true);

    while (true)
    {
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions