1

Arduino Mega ADK から Android への接続を開始しようとしていますが、acc.powerOn() を試行するたびに以下のエラーが発生し続けます。

エラー: OSCOKIRQ のアサートに失敗しました

これは私が実行しようとしているファームウェアです:

#include <Wire.h>
#include <Servo.h>

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

int led = 13;

int EnableMotors = 22;

int Motor1FW = 24;
int Motor1RW = 26;

int Motor2FW = 28;
int Motor2RW = 30;


AndroidAccessory acc("FRBB",
             "UgvBr",
             "DemoKit Arduino Board",
             "1.0",
             "http://www.android.com",
             "0000000012345678");



// the setup routine runs once when you press reset:
void setup() {

  // Setting Serial at 115200 bps
  Serial.begin(115200);

  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);

  // Set up motor configs
  pinMode(EnableMotors, OUTPUT);
  pinMode(Motor1FW, OUTPUT);
  pinMode(Motor1RW, OUTPUT);
  pinMode(Motor2FW, OUTPUT);
  pinMode(Motor2RW, OUTPUT);

  // Powering the accessory
  acc.powerOn();             ///// <<<<<<<<<<< ERROR

}

// the loop routine runs over and over again forever:
void loop() {

  if(acc.isConnected()){

    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
    digitalWrite(EnableMotors, HIGH);
    digitalWrite(Motor1FW, HIGH);
    digitalWrite(Motor2FW, HIGH);

    delay(2000);

    digitalWrite(led, LOW);   // turn the LED on (HIGH is the voltage level)
    digitalWrite(EnableMotors, LOW);
    digitalWrite(Motor1FW, LOW);
    digitalWrite(Motor2FW, LOW);

    delay(2000);
  }

}

私はいたるところを見てきましたが、この問題の解決策はまだ見つかりませんでした。1.0.1 で Arduino.app を使用して DemoKit も試しましたが、それでも同じ問題が発生します。Macで開発していますが、問題ないと思います。

テスト目的で、LED を点滅させるコードをアップロードしたところ、問題なく動作しました。

4

4 に答える 4

9

まったく同じ問題で 8 時間を費やしました。Max3421e.cpp に問題があるようです。置き換えてみてください:

boolean MAX3421E::reset()
{
  byte tmp = 0;
    regWr( rUSBCTL, bmCHIPRES );                        //Chip reset. This stops the oscillator
    regWr( rUSBCTL, 0x00 );                             //Remove the reset
    while(!(regRd( rUSBIRQ ) & bmOSCOKIRQ )) {          //wait until the PLL is stable
        tmp++;                                          //timeout after 256 attempts
        if( tmp == 0 ) {
            return( false );
        }
    }
    return( true );
}

boolean MAX3421E::reset()
{
    regWr( rUSBCTL, bmCHIPRES );                        //Chip reset. This stops the   oscillator
    regWr( rUSBCTL, 0x00 );                             //Remove the reset
    while(!(regRd(rUSBIRQ) & bmOSCOKIRQ)) ;
}

USB_Host_Shield ライブラリ (Arduino IDE ライブラリ フォルダ内) にある Max3421e.cpp にあります。基本的に、この変更は PLL が本当に安定するまで終了できません。

少なくとも私にとってはうまくいきました。幸運を祈ります(元のヒントと修正に関する詳細はこちら: http://arduino.cc/forum/index.php?topic=68205.0 )

于 2012-06-28T07:13:53.163 に答える
4

Arduino Mega ADK で USB_Host_Shield_2.0 ライブラリを使用します。

https://github.com/felis/USB_Host_Shield_2.0

重要!!!

このライブラリを公式の Arduino ADK で使用するには、avrpins.h の次の行のコメントを外します。

#define BOARD_MEGA_ADK
于 2013-02-10T16:42:16.450 に答える
2

「OSCOKIRQ failed to assert」は通常、ボード内の Max IC が正常に動作していない場合に発生します。これは 2 つのシナリオで発生する可能性があります

  • Maxim IC に十分な電力が供給されていません。(この場合、ボードに外部電源を接続してみてください)
  • Maxim IC周辺の回路に問題があります。このような場合は、ボードを交換する必要があるかもしれません。

そのため、まず外部電源を接続してみて、これで問題が解決するかどうかを確認してください。そうしないと、ボードを交換する必要がある場合があります。

于 2012-06-28T05:45:13.627 に答える
1

私にとっては非常に簡単です(同じ問題で)、前に遅延を追加するだけですacc.powerOn()

私が見た例では 100 を追加しましたが、起動は 500 で十分速いと判断しました。

void setup()
{
  // set communiation speed
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  delay(500);
  acc.powerOn();
}
于 2012-10-05T03:57:35.527 に答える