Pages: [1]   Go Down
Author Topic: Arduino Mega 2560 ADK - OSCOKIRQ  (Read 8673 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HI everyone, I've done a search on the forums for this with mixed results, nothing seems to apply to my issue so here is the issue:

I've gota a Mega ADK, made sure it worked with a few programs like the blink test and such and all seems well.  Started getting USB to work so I have the USB Host Shield library downloaded (OLEG and Googles) and I always get:

Quote
OSCOKIRQ failed to assert
However the rest "SEEMS" fine (I dont have a loop back adapter).

Quote
Circuits At Home 2010
USB Host Shield QC test routine

Press any key to continue...
Reading REVISION register...Die revision 03
Test PASSED
Checking GPIO lines. Install GPIO loopback adapter and press any key to continue...GPIO read/write mismatch. Write: 0 Read: FF

GPIO check failed. Make sure GPIO loopback adapter is installed
SPI test. Each  '.' indicates 64K transferred. Stops after transferring 1MB (16 dots)
................
Test PASSED
Oscillator start/stop test. Oscillator state is ON
Setting CHIP RESET. Oscillator state is OFF
Clearing CHIP RESET. PLL is stable. Time to stabilize - 191 cycles
Test PASSED
USB Connectivity test. Waiting for device connection...
Device connected. Resetting
Reset complete. Waiting for the first SOF...
SOF generation started. Enumerating device.
Setting device address
Getting device descriptor
Device descriptor:
Descriptor Length:   12
Descriptor type:   01
USB version:   0200
Device class:   00
Device Subclass:   00
Device Protocol:   00
Max.packet size:   40
Vendor ID:   04B0
Product ID:   0427
Revision ID:   0101
Mfg.string index:   01
Prod.string index:   02
Serial number index:   03
Number of conf.:   01

All tests passed. Press RESET to restart test

Anyone know if this is something I need to worry about?  I checked my max3421e_constants.h file and it seems fine:

Quote
#if defined(__AVR_ATmega1280__) || (__AVR_ATmega2560__)

  #define SCK_PIN   52

  #define MISO_PIN  50

  #define MOSI_PIN  51

  #define SS_PIN    53

#endif

and

Quote
#define MAX_SS    53

#define MAX_INT   9

#define MAX_GPX   8

#define MAX_RESET 7

I've also tried using a 9V battery for power (incase there is an issue with USB power) but same dice.
Thanks, SK
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was a bit worried its an issue with the crystal/oscilator so I used my AVR MKII to check the fuses to see how this thing is set (also reburned the bootloader just incase) and here is how its set.  I thought it was 16mhz?

These are the fuses:


And just for good measure a shot of the clock:


Any thoughts?
-SK
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13083
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


You're barking up the wrong tree.  The fuse settings look fine.  (other than I would add "Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0])
Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 646
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

follow this tutorial http://labs.arduino.cc/ADK/Index

consider that in order to use the usb host with a phone you need to power the board with an external power supply capable of providing 1A of current, this is because when you plug in the phone it will start to charge.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome!  I'll give it a try with a larger power supply then my 9V Battery.

Does this also apply if you are not using it on an Android device?  (More like a regular USB Host Controller?)
Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 646
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

if you're not powering a phone you can probably use the USB power from your computer or a less "beefy" power supply
(the 9v battery is usually not a good idea)

m
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hum... Odd I've been using it on both (9V and USB power) and keep getting that error, I'll try a bigger PSU and see if that fixes it but I've only been connecting it to a camera which has its own power so I dont think its draining power via USB since it cant charge that way (Nikon SLR).  I checked on my AVR MKII and the power voltages are a contant 5/5.1v on the board.

Very odd...

-SK
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay so I tried a 9V 2A power brick and ran the USB Host Shield "examples" with nothing connected to USB.  Same deal.  OSCOKIRQ failed to assert.

Any other ideas?

EDIT: Also just tried a 12V 2.5A brick, same thing.
« Last Edit: August 02, 2011, 05:38:45 pm by SKNight » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I was just stepping through the reset function in Max3421e.cpp. 

What does "regRD()" Do in the code snippet below?  I added some lines for debugging and my output is:

rUSBIRQ: 68
bmOSCOKIRQ: 1
tmp: 1
rUSBIRQ: 68
bmOSCOKIRQ: 1
tmp: 2
rUSBIRQ: 68
bmOSCOKIRQ: 1
tmp: 3
...
rUSBIRQ: 68
bmOSCOKIRQ: 1
tmp: 0
Error: OSCOKIRQ failed to assert

So thats obvious, its counting to 255 as the code says and then failing causing the message.

So what is this line doing?
while(!(regRd( rUSBIRQ ) & bmOSCOKIRQ )) {          //wait until the PLL is stable

Other then the comment of course.

Quote
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 );
}

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay so for those who are interested I think I found the answer after about 10 hours.

I changed Max3421e.cpp from the following:


Quote

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 );
}

To this:
Quote

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

So basically it stays in the loop until it stabilizes and then exists, also to ensure it does turn on and stabilize I stole this function from board_test.pde to ensure it works and the oscillator turns on and stabilizes:

Quote

void setup()
{
  Serial.begin( 115200 );
  //Serial.println("Start");
  //Serial.println( SCK_PIN, DEC );
  Max.powerOn();
  check_OSCOKIRQ();
  osctest();
  printProgStr( startBanner );
  printProgStr( anykey_msg );
  //Serial.print( Max.getvar(), DEC);
}

void check_OSCOKIRQ()
{
  if( Max.regRd( rUSBIRQ ) & bmOSCOKIRQ ) {  //checking oscillator state
    printProgStr(PSTR("ON"));
  }
  else {
    printProgStr(PSTR("OFF"));
  }
}

/* Oscillator test */
bool osctest()
{
  printProgStr(PSTR("\r\nOscillator start/stop test."));
  printProgStr( osctest_oscstate_msg );
  check_OSCOKIRQ();                          //print OSCOK state
  printProgStr(PSTR("\r\nSetting CHIP RESET."));
  Max.regWr( rUSBCTL, bmCHIPRES );              //Chip reset. This stops the oscillator
  printProgStr( osctest_oscstate_msg );
  check_OSCOKIRQ();  //print OSCOK state
  printProgStr(PSTR("\r\nClearing CHIP RESET. "));
  Max.regWr( rUSBCTL, 0x00 );                //Chip reset release
  for( word i = 0; i < 65535; i++) {
    if( Max.regRd( rUSBIRQ ) & bmOSCOKIRQ ) {
      printProgStr(PSTR("PLL is stable. Time to stabilize - "));
      Serial.print( i, DEC );
      printProgStr(PSTR(" cycles"));
      printProgStr( testpassed_msg );
      return( true );
    }
  }//for i =
  return(false);
}

So in the end this is my output:
Quote

ON
Oscillator start/stop test. Oscillator state is ON
Setting CHIP RESET. Oscillator state is OFF
Clearing CHIP RESET. PLL is stable. Time to stabilize - 191 cycles
Test PASSED
Circuits At Home 2010
USB Host Shield QC test routine

Press any key to continue...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What version of the library are you using?
I ask this because I cannot find this "boolean MAX3421E::reset()"-routine in the version 2
of the usb-lib...
« Last Edit: September 15, 2011, 03:34:47 am by bob1810 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you SKNight! I have scoured the internet and your solution fixed the problem.

Cheers.
Logged

Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What version of the library are you using?
I ask this because I cannot find this "boolean MAX3421E::reset()"-routine in the version 2
of the usb-lib...

The is in v1.0 of the library. I guess this is fixed in v2.0 of the library.
Logged

Checkout some of my Arduino projects and tutorials

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried all these solutions - increased voltage to 12 volts(8 pack of AA batteries) and removed the polling counter. Later, ordered a replacement board. Still get "Error: OSCOKIRQ failed to assert". I wonder if there is some other problem in the code or if there is a whole batch of bad boards being sold. I'm testing with a application called "Droid Range Finder".  I am currently using libraries having folders "AndroidAccessories" and "USB_Host_Shield". Could these maybe older libs be a problem?
« Last Edit: September 14, 2012, 09:14:54 am by rbjork » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Problem solved by rolling back to Arduino IDE 0022
Logged

Pages: [1]   Go Up
Jump to: