Timers with us

  • Hello,

    It seems there is a problem using timers with intervals under 1ms. Taking an example of a pin toggle using interrupts every 0.5ms here is the output based on a logic analyzer:


    code used:

    from machine import Pin
    from machine import Timer
    test_pin = Pin('P11', mode=Pin.OUT)
    class Clock:
        def __init__(self):
            self.loops = 0
            self.__alarm = Timer.Alarm(self._seconds_handler, us=500, periodic=True)
        def _seconds_handler(self, alarm):
            self.loops += 1
            if self.loops == 20:
    clock = Clock()

    this happened also with

    self.__alarm = Timer.Alarm(self._seconds_handler, s=0.0005, periodic=True)

    PWM seems to working fine for the same Pin / Frequency. If a change the period to 1ms and above everything is working fine.


Pycom on Twitter