cancel
Showing results for 
Search instead for 
Did you mean: 

How to Initialize STM32C011J6

Sourabh15
Visitor

Hi There,

So, I got some of the STM32C011J6 MCUs for my simple project of reading sensors data and generating an interrupt.

But I am in a dilemma, that the MCU's has I2C Pins, SWD Pins for programming, GPIO pins to act as interrupt but how to initialize it in CUBEMX.

I am planning to build PCB after I successfully assign pins in CUBEMX.

When I choose I2C, It blocks the SWD Pins and Vice versa. Also, is External Crystal necessary for such MCU? Looking forward to most of the suggestions and resources.

My plan is to read a sensor data via I2C and generate interrupt on a GPIO Pin.

Sourabh15_0-1765965467811.png

 

2 REPLIES 2
gbm
Principal

For prototyping and development, keep the PA13 and PA14 pins as SWD.

Maybe you should start by using a Nucleo board with C031, develop the software on it, then migrate to your target MCU.

It will be hard anyway with C011J, since there is no alternative for I2C1_SDA, so maybe you should consider another MCU with slightly more pins.

All the details in clocking may be found in reference Manual, RCC section. It's impossible to do any engineering work without the RefMan, so I would suggest you get acquainted with it.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Andrew Neil
Super User

@Sourabh15 wrote:

When I choose I2C, It blocks the SWD Pins and Vice versa.


Well, that is inherent in choosing a package with such a small pin count, isn't it?

There are simply not enough pins to give access to all of those features simultaneously!

This should have been clear from the datasheet.

This is not just an SMT32 issue - the same thing affects all low pin count microcontrollers.

It has been said that, "if you don't have enough resources to devote 10% to debug/diagnostics, then you just don't have enough resources" - in this context, "resources" includes pins!

it's always important that part of your design is, "How will I debug this thing?"

See: Design for Debug.

 

As @gbm said, you should at least start your development on a device with more pins.

If you really must, then move to the lowest pin count when your code is stable and well-proven. You will need to do very rigorous testing before that - because your debug options are severely limited!

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.