2
\$\begingroup\$

I have an Arduino Mega2560 ref3 ADK which is connect to Android. I also have a seeed studio NFC shield connected to it.

The problem is that if I try to initialise the AndroidAccessory library and the PN532 library in the same sketch, it doesn't work. If I try to run my sketches separately it does work.

I believe that these two libraries are not compatible.

Does anyone have an idea what the problem may be?

\$\endgroup\$
1
  • \$\begingroup\$ What is the electronics question? \$\endgroup\$ Nov 14, 2012 at 18:21

1 Answer 1

2
\$\begingroup\$

The SeeedStudio NFC shield uses SPI to communicate with the Arduino. One simple option is to take the shield off the Arduino, wire up an alternative set of pins on the Arduino Mega for bit-banging SPI through, and verify whether conflicts still remain.

I am not familiar with the AndroidAccessory library, but if this library initializes or uses the pins used for SPI by the PN532 library for any reason, or is using SPI for some purpose, the library may conflict with the NFC Shield.

One might attempt to change the sequence of initialization calls of the two libraries, in case one or the other library is doing some blanket initialization that overrides some pin settings and impacts the other.

To investigate this further, one would have to examine the code or documentation of the Android Accessory library. The PN532 library is relatively simple, so checking through its code is not too messy.

Another potential issue might be insufficient memory for both libraries to operate simultaneously - less likely on the Mega 2560 than on the smaller microcontroller of the Arduino Uno for instance.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.