Can’t FIFO ADC Core1 to Core0 but can Core0 to Core1

I found this great Earle Philhower FIFI two core example that runs fine with his Pico RP2040 Board with Arduino IDE on my Win11 (fifoTest below) , but reversing everything didn’t work (fifoTest1 below). When it doesn’t crash the bootloader and require board replacement, it compiles, loads and hangs with, “Port monitor error: Command ‘open’ failed. Serial port busy. Could not connect to COM8.”
I’ve tried everything I can think of to no avail. What am I missing?

fifoTest.ino

// This FIFI ADC Core1 to Core0  works great
// All compliments to https://github.com/earlephilhower/arduino-pico/discussions/83
// Tweeking by Larry Gorham

// Core 1 interrupt Handler
void core1_interrupt_handler() {
  // Receive Raw Value
  while (multicore_fifo_rvalid()){
    uint32_t raw = multicore_fifo_pop_blocking();
    Serial.printf("ADC = %d\n", raw);        
  }
  multicore_fifo_clear_irq(); // Clear interrupt
}

// Core 1 Main Code
void core1_entry() {
  // Configure Core 1 Interrupt
  Serial.begin(115200);
  delay(3000);
  multicore_fifo_clear_irq();
  irq_set_exclusive_handler(SIO_IRQ_PROC1, core1_interrupt_handler);
  irq_set_enabled(SIO_IRQ_PROC1, true);
  // Infinite While Loop to wait for interrupt
  
  while (1){
    //tight_loop_contents(); //noop instruction requires no time
  }
}

// Core 0
void setup() {
  delay(4000);
  multicore_launch_core1(core1_entry); // Start core 1 - Do this before any interrupt configuration
}

void loop() {
  uint32_t raw =   analogRead(A0);
  multicore_fifo_push_blocking(raw);
  sleep_ms(1000);
}

fifoTest1.ino

//  Just trying to FIFO ADC Core1 to Core0
//*************************************
// This code hangs port and/or eats bootloader
//***************************************

void core0_interrupt_handler() {
  // Receive Raw Value, 
  while (multicore_fifo_rvalid()){
    uint32_t raw = multicore_fifo_pop_blocking();
    Serial.printf("ADC = %d\n", raw);        
  }
  multicore_fifo_clear_irq(); // Clear interrupt
}

void setup() {  
}

// Core 0 Main Code
void loop() {
  // Configure Core 1 Interrupt
  Serial.begin(115200);
  delay(3000);
  multicore_fifo_clear_irq();
  irq_set_exclusive_handler(SIO_IRQ_PROC0, core0_interrupt_handler);
  irq_set_enabled(SIO_IRQ_PROC0, true);
    
  // Infinite While Loop to wait for interrupt
  while (1){
    tight_loop_contents(); //noop instruction requires no time
  }
}

// Core 1
void setup1() {
  delay(4000);
  //multicore_launch_core0(core0_entry); //Core0 normally first
}

void loop1() {
  uint32_t raw =   analogRead(A0);
  multicore_fifo_push_blocking(raw);
  sleep_ms(1000);
}


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.