Arduino Hangs

Discussion in 'The Projects Forum' started by paintlax, May 27, 2014.

  1. paintlax

    Thread Starter New Member

    Jan 10, 2013
    13
    0
    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?

    Code ( (Unknown Language)):
    1.  
    2. #if 0
    3. #include <SPI.h>
    4. #include <PN532_SPI.h>
    5. #include <PN532.h>
    6. #include <NfcAdapter.h>
    7.  
    8. PN532_SPI pn532spi(SPI, 10);
    9. NfcAdapter nfc = NfcAdapter(pn532spi);
    10. #else
    11.  
    12. #include <Wire.h>
    13. #include <PN532_I2C.h>
    14. #include <PN532.h>
    15. #include <NfcAdapter.h>
    16.  
    17. PN532_I2C pn532_i2c(Wire);
    18. NfcAdapter nfc = NfcAdapter(pn532_i2c);
    19. #endif
    20.  
    21. void setup(void)
    22. {
    23.     Serial.begin(9600);
    24.     Serial.println("NDEF Reader");
    25.     nfc.begin();
    26. }
    27.  
    28. void loop(void)
    29. {
    30.     Serial.println("\nScan a NFC tag\n");
    31.     if (nfc.tagPresent())
    32.     {
    33.         NfcTag tag = nfc.read();
    34.         tag.print();
    35.     }
    36.     delay(1000);
    37. }
     
  2. timwhite

    Member

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

    Should be

    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.
     
  3. paintlax

    Thread Starter New Member

    Jan 10, 2013
    13
    0
    I get the following message when uploading:
    avrdude: stk500_getsync(): not in sync: resp=0x00
     
  4. timwhite

    Member

    Apr 10, 2014
    50
    7
    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.
     
  5. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,787
    825
    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.
     
  6. paintlax

    Thread Starter New Member

    Jan 10, 2013
    13
    0
    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...
     
  7. timwhite

    Member

    Apr 10, 2014
    50
    7
    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.
     
  8. paintlax

    Thread Starter New Member

    Jan 10, 2013
    13
    0
    I think I might have fried it :/
     
  9. timwhite

    Member

    Apr 10, 2014
    50
    7
    Sorry buddy, that would stink. Be absolutely positive first though, see if you see anything under device manager when you plug the board in. If there's a COM port for it, there may be hope.
     
  10. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
    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.
     
Loading...