android - 错误 : OSCOKIRQ failed to assert

标签 android c arduino adk

我正在尝试启动从我的 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 闪烁的代码,它工作得很好。

最佳答案

花了整整 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)

关于android - 错误 : OSCOKIRQ failed to assert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11213536/

相关文章:

android - 在 Android 中创建后台服务

c - C 中的静态函数线程安全吗?

arduino - 创建网络适配器 - 有多难?

android - 播放动画时禁用屏幕上的触摸事件

android - 如何在 ListView 中添加顶部项目?

android - 使用按钮单击控制 ImageView

c - 将字符串指针传递给 lua

c - 为什么我将环境设置为 UTF8 却没有打印出这些 Unicode 字符?

c++ - 将一个对象的函数设置为由arduino库中的另一个对象调用

c++ - Arduino 库包括 Sketch 目录中的文件