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

Đang mở
#11,778 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
56/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
embedded-iot

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
C
Star
4.6k
Fork
1.4k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
186

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của adafruit/circuitpython

Tất cả issue của adafruit/circuitpython

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.