Double trig with external interrupt and timer

Mikael Hansson
Posts: 3
Joined: Thu Nov 11, 2021 10:33 am

Double trig with external interrupt and timer

Postby Mikael Hansson » Thu Nov 11, 2021 11:03 am

Hi,
I'm quite new to ESP32 and also not a pro programmer.
Want to flip two pins due to an external interrupt, this works fine and have about 2µS reaction time from signal in to signal out.

On the second I need that a timer have passed a certain level before action is done when entering the
interrupt routine.
I read the timer and when reached the level I reset it an this works, but not every time.
About a third of the times I get a signal out on the next edge.
I'm going nuts on this, I can't see what I'm doing wrong.

static void IRAM_ATTR gpio33_isr_handler(void* arg)
{
static uint32_t SyncInput;
static uint32_t LenghtCtr;

*((volatile uint32_t *) (0x3FF5F00C)) = 1; //Copy Timer to register
LockOutTimer = *((volatile uint32_t *) (0x3FF5F004));


if(LockOutTimer < 6400)
{
SyncInput = 8; //A value that not trig the outputs
}
else
{
*((volatile uint32_t *) (0x3FF5F018)) = 1; //Load Lo reg
*((volatile uint32_t *) (0x3FF5F01C)) = 0; //Load Hi reg
*((volatile uint32_t *) (0x3FF5F020)) = 1; //Trig reload
SyncInput = gpio_get_level(GPIO_INPUT_SYNC);
LockOutTimer = 0;
}

if(SyncInput == 1)
{
for(LenghtCtr=0; LenghtCtr < PulseWidth; LenghtCtr++)
{
GPIO.out_w1ts = (1 << 26);
}
GPIO.out_w1tc = (1 << 26);
}
if(SyncInput == 0)
{
for(LenghtCtr=0; LenghtCtr < PulseWidth; LenghtCtr++)
{
GPIO.out_w1ts = (1 << 25);
}
GPIO.out_w1tc = (1 << 25);
}

}

Attach Oscilloscope picture.

Is there any interrupt queue that goes in parallel?
Isn't the timer reseted every time?
If I just make a counter that count up every time when entering the interrupt this is not happening.

Thanks in advance
/Mike

Mikael Hansson
Posts: 3
Joined: Thu Nov 11, 2021 10:33 am

Re: Double trig with external interrupt and timer

Postby Mikael Hansson » Thu Nov 11, 2021 12:20 pm

Seems like the scope picture didn't got attached
Attachments
Triggers.png
Triggers.png (805.9 KiB) Viewed 1904 times

Who is online

Users browsing this forum: Google [Bot] and 157 guests