PN532 i2c communication issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PN532 i2c communication issue

4,343 次查看
jackywu_t
Contributor II

I had bought a PN532 module to try on a lock design. I used STM32 as my host controller and set the PN532 module in i2c mode. First at all, i try to read firmware version. i send a command packet as below.

      buffer = {0x00,0x00,0xff,0x02,0xfe,0xd4,0x02,0x2a,0x00}                  

First sending slave address with write command was okay, host controller can get ack correctly. But following byte 0x00 can't get ack, always is nack. Is someone have same question? Did i missing boot up sequence? I can't find it in user manual. HELP!!

PN532‌

#nxp_pn532

#stm32

标记 (4)
5 回复数

2,175 次查看
hongfengjiang
Contributor I

Hi,jacky

I also use STM32 +PN532 with i2c, but i can't get the connection. So i want to ask for you .

i want to discuss with you whether you use the follow register in your code. Thank you !

pastedImage_1.png

0 项奖励

2,175 次查看
testbed
Contributor III

Hello Jacky,

Can you please tell us

1. Which PN532 module are you using?

2. Paste the code snippet for the firmware version command.

3. Are you using the IRQ pin on the PN532 ?

0 项奖励

2,175 次查看
jackywu_t
Contributor II

Hi: 

Thanks for your support:

 

1. Which PN532 module are you using?

The following url, I don't know manufacturer.

http://www.playrobot.com/rfid/743-pn532-nfc-rfid.html

2. Paste the code snippet for the firmware version command.

u_int32_t getFirmwareVersion(void)

{

u_int8_t commandBuff[] = {0x00,0x00,0xff,0x02,0xfe,0xd4,0x02,0x2a,0x00};

u_int8_t rxBuf[4] = {0x00};

u_int32_t response = 0;

response = HAL_I2C_Master_Transmit(&hi2c3,PN532_I2C_ADDR,commandBuff,9,1000);

/*

HAL_I2C_Master_Receive(&hi2c3,PN532_I2C_ADDR,rxBuf,sizeof(rxBuf),100); r

esponse |= rxBuf[0];

response <<= 1;

response |= rxBuf[1];

response <<= 1;

response |= rxBuf[2];

response <<= 1;

response |= rxBuf[3];

*/

return response;

}

3. Are you using the IRQ pin on the PN532 ?

No, I didn't use it. Did i need to take care of it?

0 项奖励

2,175 次查看
testbed
Contributor III

Hi Jacky,

I have used this module earlier, though with a NXP host controller. The company that makes this board is Elechouse in china and they have stated on their site that there are many counterfeit versions of their designs available and it is recommended to buy directly from them. I had same problems earlier, no response from chip, IC getting hot after sometime etc. I would therefore suggest to buy the nfc board directly from their site. This is the bottom silk screen of the board that i have. This is the original...

WP_20170807_19_19_12_Pro.jpg

I would also suggest to use the IRQ mechanism of PN532 to read the ack and response together with a timeout. In my case i had written a state machine to handle data from pn532.

2,175 次查看
jackywu_t
Contributor II

Hi testbed:

Thanks for your help. I will try to connect IRQ, and add ack and response frame.

Jacky

0 项奖励