cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the wrong status value from HAL Libabry

MDeva.1
Associate II

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);

}

0693W00000Y6pvfQAB.png0693W00000Y6pvaQAB.png

2 REPLIES 2
gbm
Lead III

To kkep it short: use TransmitReceive / send and receive data at the same time. That's how the SPI works.

Perhaps use local variables rather than globals

Use the sizeof() the variable you're referring too rather than another.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..