2021-11-24 10:40 AM
Setup:
Hello Guys,
Below you can see my code. The Problem I have is that my configuration data which is 32 Bytes long is not received properly. For test reasons I send it back in the second half of a 64 Byte array.
The 1st byte of the received configuration data is a sent byte from previous received data. To be precicse its the 0x07 sent from the PLD of the start up phase below.
As a consequence the 32 Byte config data looks like this: [0x07, Config. Byte 1, ..., Config. Byte 31]. The 32th Byte is missing.
Can someone tell me what I am doing wrong?
2021-11-24 11:35 AM
You're off by one on your lengths.
Nevermind. Didn't read closely enough. It is a convoluted way of doing things, however.
2021-11-24 11:59 AM
Watch for the hazard of enabling the clock, and then immediately touching the peripheral.
Also be aware the multiple load-stores on the SAME register will not be folded by the compiler and are one of THE LEAST EFFICIENT ways possible of coding this.
The interest in unpacking others broken register level code is LOW, expect to own the burden of debugging it.
2021-11-24 12:39 PM
What do you mean by "enabling the clock, and then immediately touching the peripheral"? Do you mean I should include a delay after this line "RCC->APB2ENR |= (1<<12); //Enable SPI1 Clock"? If yes I don't see how this has any effect on my problem.
How can I make this more efficient?
2021-11-24 02:15 PM
In SPI_Reg_Transmit(), wait for RXNE to be set, before you read DR.
JW