2020-09-21 03:13 AM
Hello,
I am using a STM32L432KC to control the UART bootloader of a STM32F446RE.
First, I am sending Get and Get ID command to check if I get the recquired answer. It works, but not as I wish.
To begin I Initialize the bootloader sending 0x7F and that works too.
What I don't understand is why do I have to send the command twice to get an answer. It's the case for the 0x7F as well as for the get and Get ID. The first request never works, but all the following does.
Example :
Me : 0x7F
Res : Anything.. (not specially 1F)
Me : 0x7F
Res : 0x79
Me : 0xFD & 0x02
Res : 1F
Me : 0xFD & 0x02
Res : 79 01 04 21 79
Me : 0xFD & 0x02
Res : 79 01 04 21 79
Me : 0xFD & 0x02
Res : 79 01 04 21 79
...
It's exactly the same for the Get command...
I don't know if it's a normal situation or not, but I don't think it is really ergonomic..
Maybe someone could explain me, thus I could improve my program to overcome that.
Thanks in advance for your answer.
Regards
2020-09-21 04:09 AM
Shouldn't you send 0x00+0xFF? until you see ack as start. Have a look ar AN3155.
2020-09-21 05:03 AM
That's what I should send concerning Get command.
Then I don't understand why neither,but if I send 0x00+0xFF it doesn't work, I have to send 0xFF+0x00... Exactly the same thing for the GetID command, I have to send 0xFD+0x02 (not 0x02+0xFD).
As it works this way, I d'ont think that's a pretty big deal.
2020-09-21 06:27 AM
Looks to be an error in your reception. The bootloader is responding correctly to what you're sending, but you're not interpreting the response until a byte late. It's using the second byte of 02 FD and the first byte of the next 02 FD to respond to. Use a different command back to back and it will no longer work.
--> 0x7F
0x79
--> 0x7F 0xFD
0x1F
--> 0x02 0xFD
79 01 04 21 79
etc...
Put a logic analyzer on the line to see exactly what's happening.
2020-09-23 02:03 AM
I don't think so because as I told you, I have to send twice the init command (0x7F) too which is built by only one byte.
The system can't take one byte from the first request and one from the second as it's the same byte in both and the system only need one of them, not both.
2020-09-23 03:14 AM
Look at the Rx/Tx lines using oscilloscope.
Do you have a pullup on mcu's Tx?
JW