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.

TMS320F28069M+drv8305

Other Parts Discussed in Thread: DRV8305

在运行过程中,想把ADC增益调大,具体代码找到了DEV8305.C

drvRegAddr = Address_Control_A;
drvDataNew = (Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS1) | \
(Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS2) | \
(Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS3) | \
(Spi_8305_Vars->Ctrl_Reg_0A.CS_BLANK) | \
(Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH1 << 8) | \
(Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH2 << 9) | \
(Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH3 << 10);
DRV8305_writeSpi(handle,drvRegAddr,drvDataNew);

void DRV8305_setCSGain1(DRV8305_Handle handle,const DRV8305_CTRL0A_CSGain1_e gain)
{
uint16_t data;

// read data
data = DRV8305_readSpi(handle,Address_Control_A);

// clear the bits
data &= (~DRV8305_CTRL0A_GAIN_CS1_BITS);

// set the bits
data |= gain;

// write the data
DRV8305_writeSpi(handle,Address_Control_A,data);

return;
} // end of DRV8305_setCSGain1() function


void DRV8305_setCSGain2(DRV8305_Handle handle,const DRV8305_CTRL0A_CSGain2_e gain)
{
uint16_t data;

// read data
data = DRV8305_readSpi(handle,Address_Control_A);

// clear the bits
data &= (~DRV8305_CTRL0A_GAIN_CS2_BITS);

// set the bits
data |= gain;

// write the data
DRV8305_writeSpi(handle,Address_Control_A,data);

return;
} // end of DRV8305_setCSGain2() function


void DRV8305_setCSGain3(DRV8305_Handle handle,const DRV8305_CTRL0A_CSGain3_e gain)
{
uint16_t data;

// read data
data = DRV8305_readSpi(handle,Address_Control_A);

// clear the bits
data &= (~DRV8305_CTRL0A_GAIN_CS3_BITS);

// set the bits
data |= gain;

// write the data
DRV8305_writeSpi(handle,Address_Control_A,data);

return;
} // end of DRV8305_setCSGain3() 

无奈嵌入式学的也不怎么样,三个增益代码是在哪里调用的?我想更改增益的话具体是在哪个位置更改的?

  • // Read Control Register A
    drvRegAddr = Address_Control_A;
    drvDataNew = DRV8305_readSpi(handle,drvRegAddr);
    Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS1 = (DRV8305_CTRL0A_CSGain1_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_GAIN_CS1_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS2 = (DRV8305_CTRL0A_CSGain2_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_GAIN_CS2_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS3 = (DRV8305_CTRL0A_CSGain3_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_GAIN_CS3_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.CS_BLANK = (DRV8305_CTRL0A_CSBlank_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_CS_BLANK_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH1 = (bool)(drvDataNew & (uint16_t)DRV8305_CTRL0A_DC_CAL_CH1_BITS)?1:0;
    Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH2 = (bool)(drvDataNew & (uint16_t)DRV8305_CTRL0A_DC_CAL_CH2_BITS)?1:0;
    Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH3 = (bool)(drvDataNew & (uint16_t)DRV8305_CTRL0A_DC_CAL_CH3_BITS)?1:0;
    还有这个 read是指单片机读取这个数据发送给8305吗?
  • // Read Control Register A
    drvRegAddr = Address_Control_A;
    drvDataNew = DRV8305_readSpi(handle,drvRegAddr);
    Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS1 = (DRV8305_CTRL0A_CSGain1_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_GAIN_CS1_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS2 = (DRV8305_CTRL0A_CSGain2_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_GAIN_CS2_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.GAIN_CS3 = (DRV8305_CTRL0A_CSGain3_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_GAIN_CS3_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.CS_BLANK = (DRV8305_CTRL0A_CSBlank_e)(drvDataNew & (uint16_t)DRV8305_CTRL0A_CS_BLANK_BITS);
    Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH1 = (bool)(drvDataNew & (uint16_t)DRV8305_CTRL0A_DC_CAL_CH1_BITS)?1:0;
    Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH2 = (bool)(drvDataNew & (uint16_t)DRV8305_CTRL0A_DC_CAL_CH2_BITS)?1:0;
    Spi_8305_Vars->Ctrl_Reg_0A.DC_CAL_CH3 = (bool)(drvDataNew & (uint16_t)DRV8305_CTRL0A_DC_CAL_CH3_BITS)?1:0;
    还有这个 read是指单片机读取这个数据发送给8305吗?
  • 你好,不知道这个帖子我同事的回复能否帮助你解决问题?
    e2echina.ti.com/.../191724