cancel
Showing results for 
Search instead for 
Did you mean: 

Internal Command Error STM32F303RE

JMart.13
Senior

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.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

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.

TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".

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!

Hi Imen, as TDK mentioned, PA14 was for the SW debugger, I changed the pin configuration by now, thanks to you for the answer!

Hi @Juan Martín Castillo​ and thanks for your update.

Glad to know you overcame this problem 🙂

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen