主题中讨论的其他器件: TM4C1294NCPDT
您好!
我目前在读取 DRV8711步进驱动器 IC 时遇到问题。 自从我的应用程序以来、写入序列似乎工作正常。 我现在尝试从驱动程序读取寄存器、第一次尝试时无法从 DRV8711寄存器读取数据。 每次我只能在第5次尝试时读取数据。
/********* SPI_Initialize ******** /
void SPI_Initialize (void)
{
//必须启用 SSI0外设才能使用。
SysCtlPeripheralEnable (SYSCTL_Periph_SSI2);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOD);
GPIOPinConfigure (GPIO_PD3_SSI2CLK);
//GPIOPinConfigure (GPIO_PD2_SSI2FSS);
GPIOPinConfigure (GPIO_PD1_SSI2XDAT0);
GPIOPinConfigure (GPIO_PD0_SSI2XDAT1);
GPIOPinTypeSSI (GPIO_PORTD_base、GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3);
SSIConfigSetExpClk (SSI2_base、g_ui32SysClkFreq、SSI_FRF_MOTO_MOTO_0、SSI_MODE_MASTER、1000000、8);
SSIEnable (SSI2_base);
}
/********* SPI_DRV8711_Write_Sequnece ******** /
void SPI_DRV8711_Write (unsigned char dataHi、unsigned char dataLo)
{
unsigned int 数据;
G_Write_Data01[0]= dataHi;
G_Write_Data01[1]= dataLo;
SPI_Motor_CS_High;
SSIDataPut (SSI2_base、dataHi);
while (SSIBusy (SSI2_base));
SSIDataPut (SSI2_base、dataLo);
while (SSIBusy (SSI2_base));
SPI_Motor_CS_Low;
/********* SPI_DRV8711_READ_Sequnece ******** /
unsigned int SPI_DRV8711_read (unsigned char dataHi、unsigned char dataLo)
{
SPI_Motor_CS_High;
SSIDataPut (SSI2_base、dataHi);
while (SSIBusy (SSI2_base));
SSIDataGet (SSI2_base、&RxdataHi);
SSIDataPut (SSI2_base、dataLo);
while (SSIBusy (SSI2_base));
SSIDataGet (SSI2_base、&RxdataLo);
G_READ_Data01[0]= 0x80 ^ RxdataLo;
G_READ_Data01[1]= RxdataHi;
SPI_Motor_CS_Low;
}
/********* MOTOR_POWERUP_RESET_Sequnece ******** /
void Motor_Powerup_Reset_Sequnece (void)
{
睡眠模式_输入_低电平;
RESET_INT_High;
SysCtlDelay (10000000);
SysCtlDelay (10000000);
SysCtlDelay (10000000);
SysCtlDelay (10000000);
RESET_INT_LOW;
睡眠模式_输入_高电平;
SysCtlDelay (10000000);
SysCtlDelay (10000000);
睡眠模式_输入_低电平;
}
/********* MOTOR_CURRENT_Write_Sequnece ******** /
void Motor_Current_WriteSequenece (void)
{
unsigned char dataHi = 0x00;
unsigned char dataLo = 0x00;
/
dataHi = RegWrite |(Motor_Torture_Register.Address << 4)|(Motor_Torture_Register.SIMPLTH);
dataLo = Motor_Tornure_Register.Torque;
SPI_DRV8711_Write (dataHi、dataLo);
}
}
/********* 主要方案 /
volatile uint8_t Write=0;
volatile uint8_t read_90=0;
volatile uint8_t curry=0x32;
void main (void)
{
SPI_Initialize();
Motor_Powerup_Reset_Sequnece ();
while (1)
{
if (Write==1)
{
MOTOR_Torque 寄存器.Torque =电流;
MOTOR_CURRENT_WriteSequenece ();
写入= 0;
}
if (read_90=1)
{
SPI_DRV8711_Read (0x90、0x00);
READ_90 = 0;
}
}
主 MCU - TM4C1294NCPDT
从器件1至4 - DRV8711