Hello,
I am developping an application using an NFC chip and a reader.
And I want to turn on a LED on the NFC chip when the reader is writing on the shared memory.
I am using the NHS3152 chip and the RC522 as a reader.
I am aware that you do not recommande the use of the RC522 reader,
But it works for now, I can write into a specific page of the shared memory using the RC522 reader.
Later, we will use the PN7642.
What works?
Writing / Reading using NFC,
The NHS3152 detects if an NFC is available
I can turn on the LED if an NFC is available
What does not work?
I want to turn one the LED only when the reader is writing on the shared memory
I want to access the value inserted into the shared memory
The code on arduino I use for writing into a specific page using the RC522 is here:
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_PIN 10 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
Serial.println(F("Write personal data NHS3152"));
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {return;}
if ( ! mfrc522.PICC_ReadCardSerial()) {return;}
Serial.setTimeout(20000L);
byte pageNumber = 4;
byte buffr[] = {0x6,0x6,0x6,0x6};
mfrc522.MIFARE_Write(pageNumber, buffr, 16);
Serial.println(" ");
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
}
I found the code for the NHS3152 I use for detecting if a reader is writing is here:
.../release_mra2_12_5_nhs3152/docs/firmware/a00450.html
/NHS31xx SW API/Modules/Drivers/NFC: Near field communication driver
#include "board.h"
int main(void){
Chip_NFC_Init(NSS_NFC);
NVIC_EnableIRQ(NFC_IRQn);
Chip_NFC_SetTargetAddress(NSS_NFC, 4); /* 32 bit aligned offset of location to be monitored. I changed it with 0, 3 and 4 */
Chip_NFC_Int_SetEnabledMask(NSS_NFC, NFC_INT_TARGETWRITE | NFC_INT_TARGETREAD);
while (true){
NFC_INT_T status = Chip_NFC_Int_GetRawStatus(NSS_NFC);
if (status & NFC_INT_TARGETWRITE) {
LED_Toggle(LED_RED);
Chip_Clock_System_BusyWait_ms(500);
}
Chip_NFC_Int_ClearRawStatus(NSS_NFC, status);
}
return 0;
}
I wrote on the 4th page using the reader,
And I test on the NSH3152 to initiate the Chip_NFC_SetTargetAddress by 0, 3 and by 4
The three values do not work.
In the condition statement of the code on the NSH3152: if (status & NFC_INT_TARGETWRITE) {...},
If I only use the status, I can detect the presence of an NFC
These are my questions:
1) Should I initiate the Chip_NFC_SetTargetAddress by 0, 3 or 4,
If I wrote on the 4th page of the shared memory?
2) Do I need to initiate the Chip_NFC_SetTargetAddress, if I want only to detect a reader wanted to read?
If yes, by what value?
3) If the problems is resolved, how can I get access to the memory on the NSH3152, after a reader wrote on it?
I really appreciate your help
Nobby