cancel
Showing results for 
Search instead for 
Did you mean: 

How to program STM32C011J6M6 in SO8

ONadr.1
Senior III

Hello.

I would like to know the correct procedure to program mcu in this case. I have four outputs as timer PWM output (1,4,5,8), one as GPIO(6) input and one as GPIO(7) output. I have ST-Link 2 (SWDIO,SWCLK,NRST) for programming. I'm not sure what to do if the NRST, SWD and SWC pins are remapped at the same time and I don't want to destroy the MCU or ST-Link.I couldn't find this information in the manual. Please advise if anyone has experience with such a situation.

1 ACCEPTED SOLUTION

Accepted Solutions
ONadr.1
Senior III

Thanks for your advice. I tried the delay before uploading the GPIO configuration and it works fine. But, since I need the fastest possible start, I experimented a bit. I tried connecting the SWD port to GND (via a small resistor before power on) and that didn't produce any results. In the end, the following procedure proved to be the best way for me.

1. I connected the remapped NRST pin (4) via a small resistor and a switch to GND.

2.I connect SWCLK and SWDIO (NRST not connected)

3.I press the switch, turn on the power, the MCU keeps reset.

4. I activate the connection on the programmer and release the switch almost immediately.

5.MCU connects and I can do any operations.

6.After disconnecting the programmer, the MCU starts to execute the program and the NRST pin acts as a GPIO.

Considering the hardware, it will be better for me to use the MCU in TSSOP20 case for debugging and convert to SO8 after debugging.

View solution in original post

4 REPLIES 4
gbm
Lead III

That should have been planned while preparing the schematic, so that the connections to your external circuitry do not prevent the operation of SWD - for example SWDIO pin pulled down during reset could prevent normal initialization of ports by your software, leaving SWD operational. NRST is not needed for debug connection and may be used freely as GPIO or AF.

Write your program in such a way that it disables SWD and switches to normal operation of these pins some 10 seconds after poweron. This way you will have some time to connect to the MCU for programming and debugging.

10-Seconds might be unrealistic.

Dwelling for several hundred milliseconds might suffice, or a pull up/down strategy that the FW can recognize you want to program/reprogram.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ONadr.1
Senior III

Thanks for your advice. I tried the delay before uploading the GPIO configuration and it works fine. But, since I need the fastest possible start, I experimented a bit. I tried connecting the SWD port to GND (via a small resistor before power on) and that didn't produce any results. In the end, the following procedure proved to be the best way for me.

1. I connected the remapped NRST pin (4) via a small resistor and a switch to GND.

2.I connect SWCLK and SWDIO (NRST not connected)

3.I press the switch, turn on the power, the MCU keeps reset.

4. I activate the connection on the programmer and release the switch almost immediately.

5.MCU connects and I can do any operations.

6.After disconnecting the programmer, the MCU starts to execute the program and the NRST pin acts as a GPIO.

Considering the hardware, it will be better for me to use the MCU in TSSOP20 case for debugging and convert to SO8 after debugging.

You should probably inspect the GPIOA->IDR before reconfiguring to recognize that you should wait to give the debugger an opportunity to connect.

With a UART interface you could perhaps signal to the firmware you wish to erase the part, or initiate a debug connection.

With enough space in a device you could implement IAP over the serial connection.

Yes, I'd probably go with 20 / 28 / 32-pin QFN's for the general smallness as the 8-pin just strikes me as too constricting and frustrating.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..