This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help! stm32f103c8 SPI1 issues

Hello, i am currently trying to develop a brushless motor controller. I wanted to be able to have position control so i implemented an AS5047P-TS_EK_AB magnetic encoder and am using SPI to get absolute position data from it. 

My problem is that when i try to send and receive data from it i get almost random or non-sensible data from it. The thing is that i got this project working with an arduino nano and it works perfectly. but  im missing the CAN bus functionality and debugging features from an stm32. 

Ive never really got the HAL libraries working and i dont prefer using the peripheral libraries either. so ive stuck with the direct register manipulation method (prefer that level of control anyway) and so far ive got all the registers set (i believe).

ive double triple checked every connection imaginable and i can confirm that every connection is solid. i even thought that the stlink v2 was interfering with the spi communication so i set up leds to see if i could debug it with out the st link. no luck.

in the code below, im trying to read the error register (0x4001) of the encoder to see if i could even correctly send data (because the angle data register is all ones 0xFFFF)

so since the connections are correct and the encoder works (because it works eminently when i use the arduino), my only other logical conclusion is that my code is not correct. 

so i wanted to know if there were any errors or problems that could be causing this issue in my code? (perhaps even some help using DMA if i can get it working)

im using SPI1 bus.

all of the includes are just for future code.

0