Hello
Because LED of Drv8305 often turns red to indicate fatal error occur in Drv8305 when i do the Sim2Real, i try to read the 8305 status and send back to PC.
I found that there already exists code for 8305 reading and wriing in udriver_firmware:
HAL_writeDrvData(
halHandleMtr[mtrNum], &gDrvSpi8305Vars[mtrNum]);
HAL_readDrvData(
halHandleMtr[mtrNum], &gDrvSpi8305Vars[mtrNum]);
But the flag for reading and writing is false default,so actually the reading and writing job do nothing.
Here is the flag setting in drv8305.c:
void DRV8305_setupSpi(DRV8305_Handle handle, DRV_SPI_8305_Vars_t *Spi_8305_Vars)
{
DRV8305_Address_e drvRegAddr;
uint16_t drvDataNew;
// Set Default Values
// Manual Read/Write
Spi_8305_Vars->ManReadAddr = 0;
Spi_8305_Vars->ManReadData = 0;
Spi_8305_Vars->ManReadCmd = false;
Spi_8305_Vars->ManWriteAddr = 0;
Spi_8305_Vars->ManWriteData = 0;
Spi_8305_Vars->ManWriteCmd = false;
and the code about reading,also in drv8305.c:
void DRV8305_readData(DRV8305_Handle handle, DRV_SPI_8305_Vars_t *Spi_8305_Vars)
{
DRV8305_Address_e drvRegAddr;
uint16_t drvDataNew;
if(Spi_8305_Vars->ReadCmd)
You can see that if ReadCmd is false,the reading job do nothing.
I set the flag ReadCmd true to make reading can work:
void DRV8305_readData(DRV8305_Handle handle, DRV_SPI_8305_Vars_t *Spi_8305_Vars)
{
DRV8305_Address_e drvRegAddr;
uint16_t drvDataNew;
Spi_8305_Vars->ReadCmd = true;//this is what i add
if(Spi_8305_Vars->ReadCmd)
And then i put all value of register 0x02 and 0x03 into two unsigned short,send back to PC using the coils fied of the protocol:
uint16_t val1 = get_first_words_for_8305();
uint16_t val2 =get_second_words_for_8305();
// val1=2345;
// val2=9876;
SPI_REG_u16(to_write, SPI_SENSOR_CR_1) = val1;
SPI_REG_u16(to_write, SPI_SENSOR_CR_2) = val2;
Before really send back the status value,i use const value for test to make sure that the transmitting and decoding on PC side is ok.
Later when i really send back the status value of drv8305,i found that even the micro dirver is ok and LED of 8305 doesn’t turn red, FAULT field of register 0x1 may turn true or turn false time to time.
According the drv8305 data sheet,FAULT field of register 0x1 should always be false if there is no fatal error.
Does anyone have suggestions?
Thank you very much.