Arduino Hangs

Thread Starter

paintlax

Joined Jan 10, 2013
13
I am using the NFC shield found here (http://www.seeedstudio.com/depot/NFC-Shield-V20-p-1370.html?cPath=19_24) and using the example code below. In the serial monitor "NDEF READER" prints but then the arduino hangs and does print anything else...any suggestions?

Rich (BB code):
#if 0
#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);
#else

#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
#endif

void setup(void)
{
    Serial.begin(9600);
    Serial.println("NDEF Reader");
    nfc.begin();
}

void loop(void)
{
    Serial.println("\nScan a NFC tag\n");
    if (nfc.tagPresent())
    {
        NfcTag tag = nfc.read();
        tag.print();
    }
    delay(1000);
}
 

timwhite

Joined Apr 10, 2014
50
Pretty sure that you need to use interface here

PN532_SPI pn532spi(SPI, 10);
Should be

PN532_SPI interface(SPI, 10);
Also be sure that your serial baud rate is actually 9600 and not something like 115200.


Finally are you sure that you can use that conditional if 0 statement? It sounds a bit illogical from a programming standpoint.
 

timwhite

Joined Apr 10, 2014
50
That error message means you're not connected to the board. That could be for one of two reasons. Try first, checking to make sure you've selected the correct board from the tools -> board menu. Second, make sure you have selected the correct COM port under tools -> serial port. You may have to check your device manager to see which COM port the board is using.
 

djsfantasi

Joined Apr 11, 2010
9,163
Google for that error message. It seems to be a common problem. Did you accidentally change the Arduino board type in the IDE? Do you have the correct comm port selected? This happened to me before, and Windows had reassigned the comm port.

The search results describe these and several other situations that result in this particular error message.
 

Thread Starter

paintlax

Joined Jan 10, 2013
13
That error message means you're not connected to the board. That could be for one of two reasons. Try first, checking to make sure you've selected the correct board from the tools -> board menu. Second, make sure you have selected the correct COM port under tools -> serial port. You may have to check your device manager to see which COM port the board is using.
The code uploads fine when the shield is not connected and I get that error when it is. So there must be a problem with the NFC shield...
 

timwhite

Joined Apr 10, 2014
50
Did you accidentally feed a voltage into a digital port? You may have fried the chip if you did, and (hopefully not) possibly the board.
 

sirch2

Joined Jan 21, 2013
1,037
The code uploads fine when the shield is not connected and I get that error when it is. So there must be a problem with the NFC shield...
Not necessarily a problem. Just form your code it looks like the the shield uses SPI form comms. The ATMega chips (i.e. the MCU in an Arduino) use SPI for programming so some SPI peripherals interfere with the programming process. Unplug the shield, program it, plug the shield and reset.

For example I find I have to do this with SD Cards which also use SPI, but an SPI real time clock is fine. I guess it is to do with the way the SPI lines are implemented inside the chip.
 
Top