Understanding Coding and Libraries in STM32CubeIDE
Hey guys i recently completed mastering arduino , esp32 and all different types of atmega328 boards . Even completed learning embedded C and its application on atmega32 . I want to get started in STM32 . I have spend few weeks learning about its ide but the coding part is too much confusing , till now i am able to just use HAL Library and writing a embedded c code (target type - empty ) for it from scratch . But I am looking forward on understanding the coding part of the STM32 cube ide like how to add different libraries and how to use different types of stm32 chips and use there special feature for example few STM32 w Chips have lora inbuild . Can anyone help me with getting started .
24 Replies
blink on stm32 with just registers is particulary easy since you have a startup that gives you a very nice start environment. Let's go step by step what is the first issue you are facing.
The first problem is understanding the code generated using ioc , like ik how to set pins and generate a code , i have even used a Hal lib on it to blink Led but I am unable to hook a random sensor and get value from it ( I am unable to write code for that ) .
what sensor are you trying to hook up
IR infrared module
awesome, good start so what does the data sheet say how do you talk to this sensor?
it has three pins - gnd , vcc , data out ( active high)
so you need to use data out pin ofc , but no additional info is present on the internet
So it's analog out?
yes
What sensor is it?
Presumably then you need analog in?
HW-201
yes need a analog pin to read it (adc)
perfect if you can use IOC and set up GPIO you can do the same for ADC yes?
yeah , but don't you need a specific library like we do in arduino ?
or normal HAL lib command will work ?
Ok so with this information what have you tried?
i am trying to find a library for that particular sensor similar to what arduino ide has .
ah there might be one, but what do you need the library to do for you?
get the reading and display in on a console .
i am just asking , is it possible to extract the value by simiply connecting the output pin of the sensor to the ADC pin on stm32 and write a simple code to read the value , or else i will be needing a specific lib for that specific sensor to get the readings ( which is usually the case in arduino ide ).
Solution
it's definitely possible yes
ohk thanks got it , i will give it a try .
you can do it easily wihout library