I am new to ESP32 and did some modifications to this ESP32-Radio project https://github.com/Edzelf/ESP32-Radio
What I am trying now is to add some functionality to the IR code interpretation which lacks some functionality. As it is Interrupt driven I found it quite hard to debug. So i added a function morseDebug to allow me to see what's going on on my oscilloscope.
However it seems that this function doesn't get executed when called from inside the ISR. I don't understand why? I stripped the code down to a minimal example:
Code: Select all
#define sv DRAM_ATTR static volatile
#define PIN_IR_DEBUG 21
#define IR_PIN 13
portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; // DOESN'T SEEM TO MAKE ANY DIFFERENCE
void IRAM_ATTR morseDebug( int n )
{
for (int i; i < n; i++)
{
(*((volatile uint32_t *) (0x3ff44000 + 0x8 ))) ^= 1 << PIN_IR_DEBUG ; // USED THIS AS A FASTER ALTERNATIVE TO
(*((volatile uint32_t *) (0x3ff44000 + 0xC))) ^= 1 << PIN_IR_DEBUG ; // digitalWrite ( PIN_IR_DEBUG, HIGH/LOW )
}
}
//**************************************************************************************************
// I S R _ I R *
//**************************************************************************************************
// Interrupts received from VS1838B on every change of the signal. *
// Intervals are 640 or 1640 microseconds for data. syncpulses are 3400 micros or longer. *
// Input is complete after 65 level changes. *
// Only the last 32 level changes are significant and will be handed over to common data. *
//**************************************************************************************************
void IRAM_ATTR isr_IR()
{
portENTER_CRITICAL(&mux);
(*((volatile uint32_t *) (0x3ff44000 + 0x8 ))) ^= 1 << PIN_IR_DEBUG ; // THIS GETS EXECUTED
(*((volatile uint32_t *) (0x3ff44000 + 0xC))) ^= 1 << PIN_IR_DEBUG ; // THIS GETS EXECUTED
morseDebug ( 5 ); // THIS DOESNT GET EXECUTED
portEXIT_CRITICAL(&mux);
}
//**************************************************************************************************
// S E T U P *
//**************************************************************************************************
// Setup for the program. *
//**************************************************************************************************
void setup()
{
pinMode ( PIN_IR_DEBUG, OUTPUT ); // FOR IR TESTING
(*((volatile uint32_t *) (0x3ff44000 + 0x8 ))) ^= 1 << PIN_IR_DEBUG ; // THIS GETS EXECUTED
(*((volatile uint32_t *) (0x3ff44000 + 0xC))) ^= 1 << PIN_IR_DEBUG ; // THIS GETS EXECUTED
morseDebug ( 20 ); // THIS GETS EXECUTED
if ( IR_PIN >= 0 )
{
pinMode ( IR_PIN, INPUT ) ; // Pin for IR receiver VS1838B
attachInterrupt ( IR_PIN, // Interrupts will be handle by isr_IR
isr_IR, CHANGE ) ;
}
}
void loop()
{
delay(100);
}