2021-07-26 06:47 PM
I'm having this problem when I'm trying to upload my code to the microcontroller.
I'm using the STM32F303RE Nucleo board, and whenever I try to upload the code it happens this error:
Internal command error
And after that, it doesn't let me upload any code. I searched for the solution and it was to erase the code putting BOOT0 in high, but I tried again and failed.
I have this initialization (before the while loop) function for the I2C protocol:
void Initializate_I2C(){
//using AF4
periph::GPIO::set_pin(GPIOA, 14, ALTERNATE); //SDA
periph::GPIO::set_pin(GPIOA, 15, ALTERNATE); //SCL
GPIOA->OTYPER |= ((1U << 14U) | (1U << 15U));
GPIOA->AFR[1] |= (4U << 28U);
GPIOA->AFR[1] |= (4U << 24U);
//periph::GPIO::set_afrh(GPIOA, 4U, 24U);
//periph::GPIO::set_afrh(GPIOA, 4U, 28U);
periph::I2C::Init(I2C1, 0x00201D2BU, FILTER_COF_1);
}
I noticed that the code only uploads successfully if I delete lines 8 and 9 (configuring the afrh for I2C). Otherwise, the Internal command error happens.
I updated the st-link since that's the only solution I could find on the internet, but it didn't work.
Thanks for your answer.
Solved! Go to Solution.
2021-07-27 07:20 AM
PA14 is used by the SWD debugger/programmer. Assigning different functions to them will cause the debugging connection to be broken.
You can still recover the chip by using "connect under reset" in STM32CubeProgrammer and erasing the chip.
You can still upload code if your IDE has a "connect under reset" option, but you won't be able to debug.
2021-07-27 02:38 AM
Hello @Juan Martín Castillo ,
Have you tried to "connect under reset"?
Check your configuration of GPIO/SWD pins?
Make sure to update and use the latest drivers and Cube MCU package.
I'm waiting for your update.
Imen
2021-07-27 05:24 AM
Hi Imen, I have selected the connect under reset option, but it still fails. I'm working on Keil uvision, but I will try in STMCube later I get home.
Thanks for the answer.
2021-07-27 07:20 AM
PA14 is used by the SWD debugger/programmer. Assigning different functions to them will cause the debugging connection to be broken.
You can still recover the chip by using "connect under reset" in STM32CubeProgrammer and erasing the chip.
You can still upload code if your IDE has a "connect under reset" option, but you won't be able to debug.
2021-07-28 07:58 PM
Hi TDK, thanks for the reply!
Yes, that was the problem! thank you so much, I didn't notice that, and sorry for the late answer.
Have a great day!
2021-07-28 07:58 PM
Hi Imen, as TDK mentioned, PA14 was for the SW debugger, I changed the pin configuration by now, thanks to you for the answer!
2021-07-28 11:37 PM
Hi @Juan Martín Castillo and thanks for your update.
Glad to know you overcame this problem :)
Imen