2017-08-14 02:47 AM
Hi,
I am starting out with STM32 (STM32F103CB). I am thinking of using Visual Studio with VisualGDB and Seggar debugger. Are there high level libraries I can use for setting up IO functions and also for delays and non-blocking timers?
I am wanting something simple like
delay(ms);
non-blocking:
StartTimer(x,delay);
if(Timer[x].Timeout){
}
And digital IO
SetPin(x,OUTPUT); (bit like Arduino code)
digitalWrite(pin,HIGH);
Thanks
2017-08-14 06:32 AM
Hi,
are you using STM32CubeMX? For starting out I would recommend using that to create the basic initialization code, then play around and try to understand the code it generates.
It automatically includes the libraries you need for the functions you select. It will need to download a firmware package for your MCU, which also includes examples, although mostly extremely simple ones. It is not as simplified as for Arduino, but as long as you know how to read or set registers, and have an IDE that allows you to trace declarations through the source code, you should be fine.
I'm not sure it will work with Visual Studio though, but for a free-of-charge IDE you can try the STM32 system workbench based on Eclipse, which is probably easier to set up:
http://www.openstm32.org/System+Workbench+for+STM32
Hope it helps.
2017-08-14 08:25 AM
There's 'a standard' library for newbie, it is called HAL and supplied by STM.
1. It does not offer non-blocking timer (but HAL_Delay performs a blocking timeout). If you need a non-blocking timer, you may do the following:
a) declare somewhere a globaldef.h:
typedef struct {
uint32_t timerValue;
uint32_t maxTimer;
uint8_t timerAllowed;
uint8_t cycleTimer;
uint8_t timeoutTimer;
} NONBLOCKTIMER;
NONBLOCKTIMER theTimer;
b) in main(), before starting the cycle, init the timer:
theTimer.timerValue = 0; theTimer.timerAllowed = 0; theTimer.cycleTimer=0; theTimer.timeoutTimer = 0;
c)in HAL_SYSTICK_IRQHandler (fires once in 1 ms by default) (see file with name like ..._it.c ) add the following to the end of routine:
if (theTimer.timerAllowed==1)&&(theTimer.timeoutTimer==0) {
theTimer.timerValue++;
if ( theTimer.maxTimer<theTimer.timerValue) {
theTimer.timeoutTimer=1; theTimer.timerAllowed=0;
}
}
d)dispatch the state of theTimer in Main Cycle
if (theTimer.timeoutTimer==1) {
//do smth and restart your crude timer
theTimer.timeoutTimer=0;
}
2017-08-14 09:01 AM
Hi
orbitcoms
,There is also Mbed:
https://developer.mbed.org/platforms/ST-Nucleo-F103RB/
.-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-08-14 03:06 PM
Thanks Guys,
I am using my own hardware.