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

将 USB_Host_Shield_2.0 库与 Arduino Mega ADK 一起使用。

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 无法断言”通常发生在板子内部的 Max IC 工作不正常时。这可能在两种情况下发生

  • 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 回答