Hello all
I'm currently trying to write an isr for my spi and have tried to follow advice by seperating my setup from my actual isr to make the isr as short as possible
The problem I'm hitting is that the whenever I call gpio_set_irq_enabled then I hit _assert_func
(I've connected to CSN GPIO to SPI_IRQ_PIN, so they share the same inputs(my spi is a slave, so whatever the master sends, I get). I'm hitting the error shown in the pic(my call stack) and was wondering as to what am I doing wrong in this regard.
Kind regards
I'm currently trying to write an isr for my spi and have tried to follow advice by seperating my setup from my actual isr to make the isr as short as possible
Code:
int main(void) { static volatile bool spi_transfer = FALSE; char conversion[ NUMBER_OF_BYTES + 1 ]; // to convert to string. uint8_t in_buf[ NUMBER_OF_BYTES ]; stdio_init_all(); timer_hw->dbgpause = 0; board_init(); if(spi_transfer == FALSE) // Also nonrentrant functions are done here { uint32_t status = save_and_disable_interrupts(); // this is so that the interrupts don't fire up over here when spi stuff is being set up set_spi_gpio_pins(); prepare_memory_for_spi_transfer( conversion, NUMBER_OF_BYTES, in_buf ); spi_irq_setup_init(); spi_transfer = TRUE; restore_interrupts_from_disabled(status); }The problem I'm hitting is that the whenever I call gpio_set_irq_enabled then I hit _assert_func
Code:
PUBLIC void set_spi_gpio_pins() { spi_init(spi_default, 1000 * 1000); // 1 MHz spi_set_format( spi0, 8, // bits SPI_CPOL_0, SPI_CPHA_0, SPI_MSB_FIRST ); spi_set_slave(spi_default, true); gpio_set_function(PICO_DEFAULT_SPI_RX_PIN, GPIO_FUNC_SPI); gpio_set_function(PICO_DEFAULT_SPI_SCK_PIN, GPIO_FUNC_SPI); gpio_set_function(PICO_DEFAULT_SPI_TX_PIN, GPIO_FUNC_SPI); gpio_set_function(PICO_DEFAULT_SPI_CSN_PIN, GPIO_FUNC_SPI); gpio_set_function(SPI_IRQ_PIN, GPIO_FUNC_SIO); gpio_set_dir(SPI_IRQ_PIN, GPIO_IN); gpio_set_input_enabled(SPI_IRQ_PIN, true); // interrupt line needs to detect input // Enable SPI RX interrupt spi0_hw->imsc = 1 << 2; // RXIM interrupt enable}PUBLIC bool spi_irq_setup_init(void) { // Set the IRQ handler irq_set_exclusive_handler(SPI0_IRQ, hardware_processing); // Enable SPI0 IRQ irq_set_enabled(SPI0_IRQ, true); // Enable GPIO IRQs for the CSN pin gpio_set_irq_enabled(SPI_IRQ_PIN, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true); // Return whether the SPI0 IRQ is enabled return irq_is_enabled(SPI0_IRQ);}Kind regards
Statistics: Posted by Maaz1 — Tue Jan 27, 2026 4:09 pm — Replies 0 — Views 17