cancel
Showing results for 
Search instead for 
Did you mean: 

Using I2C in x-cube-nfc7 to write a string like this why can't you read anything

Schuyler
Senior

int main(void)

{

 /* USER CODE BEGIN 1 */

uint8_t nfc_data[32] = {0};

  const uint16_t nfc_addr = 0x10; // NFC存储区的起始地�?�

  const uint16_t nfc_size = sizeof(nfc_data); // NFC存储区的大�?

  char* write_data = "Hello, world!"; // 待写入的字符串

  char read_data[32] = {0}; // 读�?�到的字符串

  // 将待写入的字符串�?制到nfc_data数组中

  strncpy((char*)nfc_data, write_data, sizeof(nfc_data));

  // 将nfc_data数组中的字符串写入NFC存储区

  NFC07A1_NFCTAG_WriteData(NFC_INSTANCE, nfc_data, nfc_addr, nfc_size);

  // 从NFC存储区读�?�数�?�到read_data数组中

  NFC07A1_NFCTAG_ReadData(NFC_INSTANCE, (uint8_t*)read_data, nfc_addr, nfc_size);

  // 打�?�读�?�到的字符串

  printf("Read data: %s\n", read_data);

  return 0;

 /* USER CODE END 1 */

/* �?�片机�?置--------------------------------------------------------*/

/* �?置所有外设,�?始化闪存接�?�和 Systick。*/

HAL_Init();

/* 用户代�?开始�?始化 */

/* 用户代�?结�?��?始化 */

/* �?置系统时钟 */

SystemClock_Config();

/* 用户代�?开始 SysInit */

/* 用户代�?结�?� SysInit */

/* �?始化所有已�?置的外设 */

MX_GPIO_Init();

MX_NFC7_Init();

/* 用户代�?开始 2 */

/* 用户代�?结�?� 2 */

/* 无�?循环 */

/* 用户代�?开始于 */

而 (1)

 {

/* 用户代�?结�?�于 */

MX_NFC7_Process();

/* 用户代�?开始 3 */

 }

/* 用户代�?结�?� 3 */

}

/**

* @brief系统时钟�?置

* @retval 无

 */

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi,

see https://community.st.com/s/question/0D53W00002BCNySSAX/code-to-read-and-write-ndef-on-xnucleonfc07a1 for similar question

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Brian TIDAL
ST Employee

Hi,

see https://community.st.com/s/question/0D53W00002BCNySSAX/code-to-read-and-write-ndef-on-xnucleonfc07a1 for similar question

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.