Skip to main content
JMart.13
Associate III
July 27, 2021
Solved

Internal Command Error STM32F303RE

  • July 27, 2021
  • 2 replies
  • 2752 views

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.

This topic has been closed for replies.
Best answer by TDK

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.

2 replies

Technical Moderator
July 27, 2021

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
JMart.13
JMart.13Author
Associate III
July 27, 2021

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
TDKBest answer
Super User
July 27, 2021

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""."
JMart.13
JMart.13Author
Associate III
July 29, 2021

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!