我正在尝试启动从我的 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/