Interrupt signal stucked pulled low after I2C reading
Hello,
I'm facing to an issue that I cannot success to solve.
I have 5 encoders wired on a Nano Every. I success to init the 5 encoders and all the 5 encoders work well, when they are read in loop for test.
The Interrupt signal of encoders is wired on input pull up pin of nano every. an interrupt vector is assigned to this pin. In my main loop, I have a "state machin" where the state is drove by the interrupt subroutine.
So state machin is in IDLE mode until encoder pull down interrupt signal and then jump to ENCODER_EVENT to read all the 5 encoders register (one after one). after reading, state machin come back to IDLE mode until next encoder interrupt.
problem :
it happen that interrupt signal from encoder get stuck pulled low at the end of reading. It generaly happen when I turn rapidly encoder, (it happens too with push bouton when I spam it). The consequence is that my state machin go back to IDLE mode but no more interrupt signal from encoder can be detected because interrupt signal is dead stucked low... and than I cannot read anymore encoders status...
I think it come from an interference between gpio interrupt (high priority) and I2C interrupt (low priority)... so maybe something like encoder never receive ACK or something else and stay stucked in transmission mode. but i'm not really sure of it...
maybe do you have an idea ?
Thanks ! BR Adrien
Hello, If the interrupt get stuck low it means you didn't read the encoder status register. Here the code inside the I2C encoder:
case REG_ESTATUS:
return_value = ESTATUS;
ESTATUS = 0;
INT_SetHigh();
break;
You should try to read the encoders until the interrupt return high. Probably when you rotate the encoder faster your code read the first interrupt, but after that another one might occur because your are still rotating and you miss that.
I have tested with 9 encoders and with multiple type of board but no issue with that point. I even teste with 1MHz I2C clock :)
Thank you!