Hi,
I'm trying to use Infineon XMC4500 F100K1024 to drive DRV8711, but it won't start.
This is what I saw on oscilloscope after I wrote 0000 1001 0110 to register 0x3h
(I also sent commands to other registers, this is just an example of writing output)
I also tried to use DRV8711 evm, the outputs on oscilloscope are the same, so I can't figure out why
it doesn't work for XMC4500.
This is my SPI setup:
//set the reset High
DIGITAL_IO_SetOutputHigh(&Reset);
delay(10);
DIGITAL_IO_SetOutputLow(&Reset);
delay(1);
//set sleep high
DIGITAL_IO_SetOutputHigh(&Sleep);
//set chip select low
DIGITAL_IO_SetOutputLow(&ChipSelect);
//set the motor direction
DIGITAL_IO_SetOutputHigh(&MotorDirection);
Here is my code for SPI writing function:
void Write2Bytes(uint8_t start_address, uint16_t* single_short)
{
//concatenate all the data
uint8_t dataToSend[2];
uint8_t lowByteData;
uint8_t highByteData;
//start address is only 3 bits
lowByteData = lowByte(*single_short);
highByteData = highByte(*single_short);
//hex 0 is the command for a write
dataToSend[0] = start_address | highByteData | 0x00;
dataToSend[1] = lowByteData;
//set the CS high
DIGITAL_IO_SetOutputHigh(&ChipSelect);
//write the data
SPI_MASTER_STATUS_t status;
status = SPI_MASTER_Transmit(&SPI_MASTER_0, dataToSend, sizeof(dataToSend));
while(SPI_MASTER_IsTxBusy(&SPI_MASTER_0))
{
}
while (status != SPI_MASTER_STATUS_SUCCESS)
{
status = SPI_MASTER_Transmit(&SPI_MASTER_0, dataToSend, sizeof(dataToSend));
while(SPI_MASTER_IsTxBusy(&SPI_MASTER_0))
{
}
}
//finish_memory_write();
int delay_count = 0;
for(delay_count = 0;delay_count<0x2FF;delay_count++);
DIGITAL_IO_SetOutputLow(&ChipSelect);
}
This is what I sent to the registers:
uint16_t dataToSend = 0b0000000100011000;
uint16_t dataToSend_to_reg_1 = 0b0000000000111100;
uint16_t dataToSend_to_reg_2 = 0b0000000000101000;
uint16_t dataToSend_to_reg_3 = 0b0000000010010110;
uint16_t dataToSend_to_reg_4 = 0b0000010100010100;
uint16_t dataToSend_to_reg_5 = 0b0000100000111100;
uint16_t dataToSend_to_reg_6 = 0b0000000011110000;
Write2Bytes(0x10,&dataToSend_to_reg_1);
Write2Bytes(0x20,&dataToSend_to_reg_2);
Write2Bytes(0x30,&dataToSend_to_reg_3);
Write2Bytes(0x40,&dataToSend_to_reg_4);
Write2Bytes(0x50,&dataToSend_to_reg_5);
Write2Bytes(0x60,&dataToSend_to_reg_6);
Write2Bytes(0x70,&dataToSend_to_reg_7);