I haven't used coocox and am fairly new to the STM32, but from what I've learned so far, most of it looks fine.
The one place where I could imagine something going wrong is with your senddata function:
what happens if your MCU is a little too busy to instantly react to the RXNE ISR?
-> it should be called twice in a row quite quickly, or it'll skip being called once (after all, if there are 2 characters in the RX buffer, it's still "not empty" right?)
in the first case, it'll depend on how the hardware TX is buffered. if it's just the one character, then you might overwrite that one character before it's been transmitted, if it's more, you should be fine
in the second case, it'll depend on how the IDE, or rather the drivers you're using in that IDE: is the "IRQHandler" the actual ISR or is the IRQHandler being called by the ISR? and where is the RXNE interrupt flag being cleared?
The easiest solution might be to add something like
to your IRQ_Handlers.
that way, if one call to the IRQHandler is skipped for some reason you'll be able to catch up. but if you're generally too slow getting that data out again, you'll run into trouble like with long transfers anyway - then you'll have to use a ring-buffer large enough to compensate that, put your tx data in there, and fetch a new character from that buffer in a TXE IRQ_handler
I don't know if a USART_RX_not_empty function exists - you might have to check the RXNE Flag (not the RXNE Interrupt flag)
probably using the USART_GetFlagStatus() function.
Now I'm able to program the chip.
I solved the issue increasing the clock speed of the MCU, so the delay between the commands in tx and rx is lower.
Thanks for reporting your findings back to the thread.