This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
在使用SPI读取DEVICEID来验证SPI是否通信成功时存在SPI接受到的数据与发送数据一样问题,具体如下:
//Power-on Device
uint8_t ***[3]={DACX1416_SPICONFIG,0x0A,0x84};
SPI1_1_NSS_Enable();
HAL_SPI_Transmit(&hspi1, ***, 3, DACx1416_Timeout_3);
SPI1_1_NSS_Disable();
uint8_t cmd[3] = {0x81,0x00,0x00};
uint8_t ID1[3] = {0x00,0x00,0x00};
uint16_t DACX61416_ID = 0;
//0x81=23-16位,R/W读写位(1x)+DEVICEID Register 01h
SPI1_1_NSS_Enable();
/* Send the read ID command */
HAL_SPI_Transmit(&hspi1, cmd, 3, DACx1416_Timeout_3);
/* Reception of the data */
HAL_SPI_Receive(&hspi1,ID1, 3, DACx1416_Timeout_3);
SPI1_1_NSS_Disable();
printf("%x%x\n",ID1[1],ID1[2]);
DACX61416_ID = ((ID1[1] << 8) | ID1[2]) & 0xFC;
printf("%x\n",DACX61416_ID);