atmel-samd: turn off timer clocks after both timers sharing a GCLK channel are free

Ouverte
#11,778 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
56/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
c
Domaine
embedded-iot

Piste de recherche

Start with timer_handler.c and inspect tc_gclk_ids[], tcc_gclk_ids[], and the timer allocation and release paths. Read the linked issue #11776 for why disabling a shared GCLK channel caused hangs. Track whether each timer pair is in use, then test the leak and partner-timer scenarios described here; done means reload no longer hangs and a partner PWMOut keeps running.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

atmel-samd enhancement

Drafted by Claude, reviewed by @dhalbert.

Background

@tannewt's atmel-samd finalizer-cleanup commit added turn_off_clocks() in timer_handler.c. PWMOut, PulseIn, PulseOut, AudioOut, RGBMatrix and PewPew called it when they released a timer. It disabled the timer's GCLK peripheral channel and its APB clock.

However, #11776 removes it, because timers share GCLK peripheral channels in pairs, and it caused a hang. Releasing one timer stopped its partner's clock:

  • A PWMOut on the partner timer stopped running.
  • Deinitializing the partner then waited forever for its software reset to sync. Boards hung at the end of the VM, with USB gone.
Timers sharing a channel
SAMD21 TCC0/TCC1, TCC2/TC3, TC4/TC5, TC6/TC7
SAMD51 TC0/TC1, TCC0/TCC1, TC2/TC3, TCC2/TCC3, TC4/TC5, TC6/TC7 (TCC4 has its own)
Proposal

Bring back turn_off_clocks(), but disable a shared GCLK peripheral channel only when neither timer in its pair is in use. The APB clock is per timer, so it can still be turned off on its own.

This needs a record of which timers are in use, for example a bitmask set when a timer is allocated and cleared in turn_off_clocks(). Each timer's peripheral channel ID from tc_gclk_ids[] and tcc_gclk_ids[] finds its partner.

How to test
  • Leak one of each pin-owning object, including PWMOut and PulseOut on both timers of a pair, then reload. The board shouldn't hang.
  • A PWMOut keeps running after an object on its partner timer is deinited.
Langage dominant
C
Étoiles
4.6k
Forks
1.4k
Merge moyen
1 j 3 h
PR mergées (30 j)
186

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de adafruit/circuitpython

Toutes les issues de adafruit/circuitpython

Issues similaires

Plus d'issues C

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.