avr: SPI Mode2 runs as mode 1

オープン 初心者向け
#6,727 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
embedded-iot

調査の方向性

src/machine/machine_atmega.goを読み、SPI.ConfigureがAVRモードのクロック極性と位相をどのように設定しているか確認してください。Mode2がモード定義や、リポジトリで言及されている既存のSPIテストまたはハードウェア検証に対してどのように対応付けられているか調べてください。完了条件は、SPI搭載AVRチップ全体でMode2がアイドル時にSCKをHighに保ち、期待されるエッジでサンプリングすることです。

索引モデルが issue の本文から書いたものです。

説明

bug

SPI.Configure in src/machine/machine_atmega.go sets CPHA for Mode2. SPI mode 2 is CPOL=1, CPHA=0, so it needs CPOL and not CPHA. A Mode2 configuration therefore runs as mode 1: SCK is low when idle and the data is sampled on the falling edge.

I tested this on a Freetronics EtherMega (ATmega2560) with a logic analyser on SCK and CS. The program configures SPI0 at 1 MHz and sends one byte between CS low and CS high:

Mode SCK before CS goes low First SCK edge
Mode2 low rising
Mode3 high falling

With Mode3, SCK is high when idle, as expected. With Mode2 it should also be high, but it is low.

dev has no working SPI0 on the ATmega2560 (#6726), so I declared the missing bit masks locally for this test. Configure is shared by all AVR chips with an SPI peripheral, so the ATmega328P and the others have the same problem. I tested only the ATmega2560.

LLM Agents, read AGENTS.md in the repository root before proceeding.

主要言語
Go
スター
17.8k
フォーク
1.1k
平均マージ
1日 4時間
マージ済み PR(30日)
380

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tinygo-org/tinygo のほかの issue

tinygo-org/tinygo の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。