Inverter firmware and putchar
Posted: Thu May 18, 2023 5:00 pm
A question on the inverter firmware. I'm just trying to get the binary logging working on my F405 port but have been having problems in that the last few bytes of a string sent to the UART using printf() are missing. Having debugged this what I found was that printf calls putchar() which then fills a ping pong buffer and then calls SendCurrentBuffer() to transmit whenever one of the buffers is full. This then triggers a DMA to actually transmit the data.
The problem I have is that Putchar() only triggers the DMA when the outgoing DMA buffer is full. The last bit of the string is correctly written to the ping pong output buffer but because it never fills the last few bytes are never sent.
I've fixed it by adding a FlushOutput() function which forces the buffer to be sent but I can't help but think that this effect should cause problems elsewhere but can't see why it hasn't been??
What am I missing?
Edit - I'm being dim again, it's because my string doesn't end with a '\n' (newline) - flush removed and newline added!
The problem I have is that Putchar() only triggers the DMA when the outgoing DMA buffer is full. The last bit of the string is correctly written to the ping pong output buffer but because it never fills the last few bytes are never sent.
I've fixed it by adding a FlushOutput() function which forces the buffer to be sent but I can't help but think that this effect should cause problems elsewhere but can't see why it hasn't been??
What am I missing?

Edit - I'm being dim again, it's because my string doesn't end with a '\n' (newline) - flush removed and newline added!