Skip to main content
Explorer
March 14, 2023
Solved

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

  • March 14, 2023
  • 1 reply
  • 622 views

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 无

 */

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    March 21, 2023