I'm designing some data acquisition modules and I want to use an external 5v signal to trigger a DMA chain on multiple picos simultaneously. Synchronization is what I'm going for, with less latency being preferable. From some quick investigation, ISRs are very slow to respond and have quite a large variance in response time.
I switched my efforts to using a PIO with WAIT instructions to trigger a DMA with a TX DREQ. My first attempts pointed me at something puzzling - there's a long delay (120-130ns) after WAITing on 1, but a short delay (0-10ns) after WAITing on 0. I tried swapping the order of instructions around, but that doesn't seem to affect anything.
Code below:Setup/loop below:Has anyone else experienced this asymmetry?
Any help is much appreciated!
I switched my efforts to using a PIO with WAIT instructions to trigger a DMA with a TX DREQ. My first attempts pointed me at something puzzling - there's a long delay (120-130ns) after WAITing on 1, but a short delay (0-10ns) after WAITing on 0. I tried swapping the order of instructions around, but that doesn't seem to affect anything.
Code below:
Code:
// -------------------------------------------------- //// This file is autogenerated by pioasm; do not edit! //// -------------------------------------------------- //#pragma once#if !PICO_NO_HARDWARE#include "hardware/pio.h"#endif// ----- //// fiber //// ----- //#define fiber_wrap_target 0#define fiber_wrap 3static const uint16_t fiber_program_instructions[] = { // .wrap_target 0x201b, // 1: wait 1 gpio, 27 0xe001, // 2: set pins, 1 0x209b, // 3: wait 0 gpio, 27 0xe000, // 0: set pins, 0 // .wrap};#if !PICO_NO_HARDWAREstatic const struct pio_program fiber_program = { .instructions = fiber_program_instructions, .length = 4, .origin = -1,};static inline pio_sm_config fiber_program_get_default_config(uint offset) { pio_sm_config c = pio_get_default_sm_config(); sm_config_set_wrap(&c, offset + fiber_wrap_target, offset + fiber_wrap); return c;}static inline void fiber_program_init(PIO pio, uint sm, uint offset) { pio_sm_config c = fiber_program_get_default_config(offset); sm_config_set_set_pins(&c, 2, 1); // Set this pin's GPIO function (connect PIO to the pad) pio_gpio_init(pio, 2); // Set the pin direction to output at the PIO pio_sm_set_consecutive_pindirs(pio, sm, 2, 1, true); // Load our configuration, and jump to the start of the program pio_sm_init(pio, sm, offset, &c); // Set the state machine running pio_sm_set_enabled(pio, sm, true);}#endif
Code:
#include "hardware/rtc.h"#include "hardware/gpio.h"#include "hardware/pio.h"#include "hardware/rtc.h"#include "pico/stdlib.h"#include "trig.pio.h"PIO pio = pio0;uint offset = pio_add_program(pio, &fiber_program);uint sm = pio_claim_unused_sm(pio, true); void setup(){gpio_init(2);gpio_set_dir(2, GPIO_OUT);gpio_init(27);gpio_set_dir(27, GPIO_IN);fiber_program_init(pio, sm, offset);pio_sm_set_enabled(pio, sm, false);pio_sm_clear_fifos(pio, sm);pio_sm_restart(pio, sm);Serial.begin();Serial.println(pio_sm_is_claimed(pio, 0));pio_sm_set_enabled(pio, sm, true);}void loop(){}
Any help is much appreciated!
Statistics: Posted by jomg — Sat Oct 26, 2024 12:25 am