2022-12-24 01:27 AM
Hello,
I configure the DAC using SPI configuration. I am reading the DAC registers value , when register is read back i got wrong status value from HAL Library why these happened?
for(i=0,j=0,k=0;i<=46;i++,j++,k++)
{
Read( SAW_ADD[i],SAW_Val[j],SAW_RDD[k]);
}
void Read( uint16_t add, uint16_t data,uint16_t Read_add)
{
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);
status2=HAL_SPI_Transmit(&hspi4, (uint8_t*)&Read_add, sizeof(add),100);
status3=HAL_SPI_Receive(&hspi4, (uint8_t*)&Read_value, sizeof(add),100);
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
printf("s=%ds=%dAdd=%xValue=%x\n\n\r",status2,status3,Read_add,Read_value);
HAL_Delay(100);
}
2022-12-24 05:40 AM
To kkep it short: use TransmitReceive / send and receive data at the same time. That's how the SPI works.
2022-12-24 06:10 AM
Perhaps use local variables rather than globals
Use the sizeof() the variable you're referring too rather than another.