What is this: Unhandled exception in interrupt handler TypeError: 'str' object is not callable



  • It occures when an interrupt is triggered after a Timer.Alarm invoked for the first time.
    The code running inside the ISR handler is something like P += 1.

    Any help is appreciated.
    Constantinos



  • No, the callback handler can be inside a class. But then the handler must have self as first additional argument. Example (ESP8266 one, but principle should work) with ISR fucntion sample.

    class acquire:
    
        def __init__(self):
            self.adc_read = machine.ADC(0).read
            self.data = array.array("L", [0] * _BUFFERSIZE)
            self.index_put = 0
    
        def sample(self, x):
            self.data[self.index_put] = self.adc_read()
            self.index_put = (self.index_put + 1) % _BUFFERSIZE
            self.irq_busy = False
    


  • @robert-hh Maybe I found the problem. I was initializing the callback handler for the Pin inside a class. The call back method was a class method. I realized that callback handlers must be single functions.



  • Do you have more insight to your code, especially the statement where yoe set up the timer alarm and the interrupt handler itself?



Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.