AnsweredAssumed Answered

Issue: FOC V4.3 application for STM32F303RB on custom hardware

Question asked by Hani Chahine on Jun 5, 2017
Latest reply on Jun 5, 2017 by Hani Chahine

I need help please.


I have successfully built (using IAR) and run V4.3 FOC project on an STM32303E Eval board. I used the standard included project for this and after a few teething problems, I got it all to work.


The next step was to spin a custom board for my application. It is at this point I am having some issues. After re-configuring everything, it compiles fine and loads ok BUT when running the program, it seems to hang at some obscure memory location (see below).


I designed a custom PCB based off of NUCLEO-F303RE (which is supported by SDK). However, I'm using MCU STM32F303RB and have remapped most of the pins to appropriate and supported pins by the FOC SDK (see attached schematic). Other than the pins, the main difference is that I'm using an on-board 8MHz crystal as the clock source - I believe the Nucleo gets its clock source from the st-link part of the board. Do I need to reconfigure something in the library because of this?


Here is the process I took to get to where I am:

  • Configure system parameters using ST Motor Control Workbench (.h files attached), adding them to the project below.
  • Recompile the "STM32F30x_MC Library" using project "STM32F303_SINGLE_DRIVE"
    •   I did change the target for actual STM32F303RB processor.
  • I couldn't find the right STM32F303 User project so I modified the "STM32F302_SINGLE_DRIVE" project
    • Under Project Options > General Options, I changed device to STM32F303RB
    • Under Project Options > C/C++ Compiler>Preprocessor, I changed "Defined symbol" STM32F302X to STM32F303X
    • Under Project Options > Linker > Config, I changed the Linker configuration file from $PROJ_DIR$\stm32f302_flash.icf to $PROJ_DIR$\stm32f303_flash.icf
    • Excluded library  "MC_Library_STM32F30w_single_drive.a" from build and included the newly compiled "MC_Library_STM32F303_single_drive.a" library
    • Excluded file  "startup_stm32f302.s" from build and included file "startup_stm32f303.s"


This compiled fine and uploaded but when running it always crashes and hangs. I'm not sure how it got to this location or what it is. An interrupt vector or ?:


To debug, I stepped through the program until it hanged and I traced the crash point to the "MCboot(oMCI,oMCT);" function in main.c. So I assume something in the initialization is breaking down. Further stepping revealed that it seems to crash at the point of enabling IRQ channel 0x18 which I believe is TIM8_BRK_IRQn. If I try to step any further through the C code, it'll hang at this point. If I step through the disassembled code, it seems to get through this function but will then still hang if I let it free run after this.



I'm not sure how to debug this issue so I first wanted to check if there is something I've done wrong with the configuration of the project. It feels like a timer/clock source issue. I've probed the crystal with a scope and I can see the 8Mhz waveform which looks stable enough so I'm not sure what it is and why it goes to that wierd memory location.


Any help would be appreciated.