Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Hello world stm32f0xx Cannot even toggle GPIOS

I’m new to these microcontrollers. All I need is a kickstart to know I have all libraries and compilations in order. I’ve tried toggling pins, using example programs etc. I have no errors or problems when compiling the files. However once I load the “.bin” file, nothing is happening on the board.

I need some help in pointing out what it is I am doing wrong. I’m using the “std_peripheral library”.

I attached complete source code, but in short

Output pins are defined as follows:

  1. define WASH_LED_PORT GPIOA
  2. define WASH_LED GPIO_Pin_11
  3. define SPIN_LED_PORT GPIOA
  4. define SPIN_LED GPIO_Pin_12

  1. define PORTA_OUTPUTS (WASH_LED | SPIN_LED)


void gpio_ConfigPortAOutputs(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

GPIO_InitStruct.GPIO_Pin = PORTA_OUTPUTS;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOA, &GPIO_InitStruct);

GPIO_ResetBits(GPIOA, PORTA_OUTPUTS);
}

//Leds are toggled as below

void gpio_LedCtrl(void)
{
static uint8_t washLedState = LED_OFF;
static uint8_t spinLedState = LED_OFF;

if (sWashLed.LedState != washLedState)
{
washLedState = sWashLed.LedState;
GPIO_WriteBit(WASH_LED_PORT, WASH_LED, sWashLed.LedState);
}

if (sSpinLed.LedState != spinLedState)
{
spinLedState = sSpinLed.LedState;
GPIO_WriteBit(SPIN_LED_PORT, SPIN_LED, sSpinLed.LedState);
}
}


I think the code is fine. I must be doing something else wrong in how I configure the IDE.

Thanks in advance

My sympathies.
I struggle with exactly the same thing. I am “just” trying to flash an LED every second.

What I have noticed though, is this SMT32CubeMX generates code that doesn’t run at all from the get go.

It doesn’t appear from your code that you are using CMSIS threads or FreeRTOS threads.

Check in the generated code, there is a “default task” that gets created. Your “loop” needs to go in there.

But, then you will get stuck where I am, now. All the interupt priorities and NULL pointers and other things (my LED is STILL not flashing)

Hopefully in near future I will have an “example” project with one of those cheap STM32F108CT8 boards that “just” flashes it’s LED.

(maybe I am too spoilt with Arduino, where you flash LEDs out of the box)


In the end I did find the solution. Apparently the workbench was inserting a “generic startup file” that is not specific to my microcontroller, and definitely not running properly. This was because I generated my own board as compared to using a Devkit. The solution was downloading the Standard Peripheral library from ST’s website, locating the appropriate startup file and everything went well.

Note: I was using the standard periph libray instead of CubeHal.

The link that helped is given below.

https://community.st.com/thread/39304-why-ac6-system-workbench-inserts-wrong-startup-file-when-creating-a-new-projectQuestion

Wow! Thanks for the link!

I “assumed” that the INT vector tables should be “correct” (since this wizard creates it)

Will definitely give it a try.

I checked, it seems the tool is inserting a “correct” startup file named: “startup_stm32f103xb.s”