Quantcast
Channel: Motor drivers forum - Recent Threads
Viewing all articles
Browse latest Browse all 22051

MCT8316Z: SPI communication not working

$
0
0
Part Number: MCT8316Z

Tool/software:

Hi,

We've been pulling our hair out over the SPI comms with this motor controller. We're using a STM32F411 with SPI configured as following:

 

However, if we write like this:

uint8_tCalculateParity(uint16_tvalue){

uint8_tparity=0;

while(value){

parity^=(value&1);// XOR jedes Bits

value>>=1;

}

returnparity;

}

voidMCT8316ZR_WriteRegister(uint8_treg,uint8_tdata){

uint16_tcommand=0;

command=((data)|(0<<15))|((reg&0x3F)<<9);

command|=(CalculateParity(command)&0x01)<<8;

MCT8316ZR_Select();

HAL_SPI_Transmit(&hspi1,(uint8_t*)(&command),1, HAL_MAX_DELAY);

MCT8316ZR_Deselect();

}

or Read like this:

uint16_tMCT8316ZR_ReadRegister(uint8_treg){

uint16_tcommand=0;

uint16_trxData;

command=(1<<15)|((reg&0x3F)<<9);

command|=(CalculateParity(command)&0x01)<<8;

MCT8316ZR_Select();

HAL_SPI_TransmitReceive(&hspi1,(uint8_t*)(&command),(uint8_t*)(&rxData),1, HAL_MAX_DELAY);

MCT8316ZR_Deselect();

returnrxData;

}

We get no answer on the SDO line of the Motor controller. We measure a SPI signal on the according pins with the oscilloscope which should be right if we compare it to the datasheet.

However, the configuration of the controller doesn't change and it also doesn't provide any answer on the SDO line.

That's what we get on the scope:

   

And this is what we send to get this data on the line:

MCT8316ZR_WriteRegister(MCT8316ZR_CONTROL_REGISTER_1,0x03);

MCT8316ZR_WriteRegister(MCT8316ZR_CONTROL_REGISTER_2A,(0x03<<1));

MCT8316ZR_WriteRegister(MCT8316ZR_CONTROL_REGISTER_7,1);

uint16_ttest=MCT8316ZR_ReadRegister(MCT8316ZR_CONTROL_REGISTER_1);

Any idea why this isn't working properly?


Viewing all articles
Browse latest Browse all 22051

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>