Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    'Timer' has no attribute 'PERIODIC'

    Scheduled Pinned Locked Moved WiPy 2&3
    wipy2.0timerirqinterruptperiodic
    5 Posts 2 Posters 2.0k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Arkaik
      last edited by

      Hi everyone,
      I'm just getting started with timers and irq and I was trying the example code.
      However I have an issue with the initialisation of the timer.
      Here is my code:

      tim1 = Timer(1, mode=Timer.PERIODIC)
      tim1_ch = tim1.channel(Timer.A, freq=100)
      tim1_ch.irq(priority=7, trigger=Timer.TIMEOUT, handler=acquireData_cb)
      

      And the return

      PYB: soft reboot
      Traceback (most recent call last):
        File "main.py", line 42, in <module>
      AttributeError: type object 'Timer' has no attribute 'PERIODIC'
      MicroPython v1.8.6-607-g9c8a0e9e on 2017-05-01; WiPy with ESP32
      Type "help()" for more information.
      

      I was basically running with a custom firmware so I reflashed the last one but still gets the error

      >>> import os
      >>> os.uname()
      (sysname='WiPy', nodename='WiPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='WiPy with ESP32')
      

      I already had a similar issue on pyBoard with the time module where ticks_ms was not available.

      Did someone already had the same problem?

      1 Reply Last reply Reply Quote 0
      • B Offline
        bucknall
        last edited by

        Hi @Arkaik,

        Where are you getting your example code from? Please see https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/timers.html for our example code within our documentation.

        It's important to note that our timers do not work the same as on the Pyboard.

        Thanks!

        Alex

        Developer Evangelist - Pycom

        A 3 Replies Last reply Reply Quote 1
        • A Offline
          Arkaik @bucknall
          last edited by

          Hi @bucknall,

          I was using this documentation : https://docs.pycom.io/wipy/library/machine.Timer.html

          I had not realized yet that wipy documentation and wipy 2.0 was not the same...

          Thank you very much, everything is working fine now.

          1 Reply Last reply Reply Quote 1
          • A Offline
            Arkaik @bucknall
            last edited by Arkaik

            @bucknall

            As there is not so much documentation about multithreading and interrupts, how could two threads communicate?
            I'm looking for a queue-like mecanism but I can't find anything about it neither in Threading or Timers.

            Thanks

            1 Reply Last reply Reply Quote 0
            • A Offline
              Arkaik @bucknall
              last edited by

              Hi @bucknall, I finally found this library for using queues on micropython.

              However, this library need collections.deque and uasynio.core.

              1 from collections.deque import deque
              2 from uasyncio.core import sleep
              

              I went to the github repository, I downloaded collection.deque but I couldn't find uasynio.core anywhere.

              I think I'm not importing libraries correctly because I need to modify the line from collections.deque import deque to from collections import deque

              So now I would like to find the uasyncio.core module to be able to use the queue library ^^

              I hope I do not need to open a new thread for this question.
              If so, I'm sorry ;)

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • 1 / 1
              • First post
                Last post

              Pycom on Twitter

              Pycom