cancel
Showing results for 
Search instead for 
Did you mean: 

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

Hani Chahine
Associate II
Posted on June 05, 2017 at 05:24

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 ?:

0690X00000607EFQAY.png

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.

0690X00000607EGQAY.png

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.

#stm32f #foc-4.3
1 ACCEPTED SOLUTION

Accepted Solutions
Hani Chahine
Associate II
Posted on June 05, 2017 at 06:56

OK. So after spending all that time preparing a detailed post.... I found the issue!!! Sigh.

Out of desperation, I tried to recompile using the STM32303C-EVAL_SINGLEDRIVE as this seemed to work for me initially. I changed the project configuration as required (eg. selecting correct device, making sure correct MC library is used etc). After compiling I loaded it into my hardware and BAM it worked!!

Strange - I set it up the same way as for the other F302 user project.

I started investigating. I looked at map files from both projects and noticed that the code was not exactly the same (as one would have expected). One of the functions compiled with a different size:

0690X00000607AhQAI.png

I investigated further and compared the project options, one by one. I noticed that one defined symbol was missing in the STM32F302_SINGLE_DRIVE project (eg. the one that was not working). ''CCMRAM'' was missing from the defined symbols list in project options. After adding this to the project that was crashing on me, it started to work. Comparing the map files now revealed exactly the same output from both projects.

Not sure exactly how not defining this symbol created the bad code so would love to hear someones though on this.

In short, this was an error in the SDK which probably should be rectified. Thanks ST .

View solution in original post

2 REPLIES 2
Hani Chahine
Associate II
Posted on June 05, 2017 at 06:56

OK. So after spending all that time preparing a detailed post.... I found the issue!!! Sigh.

Out of desperation, I tried to recompile using the STM32303C-EVAL_SINGLEDRIVE as this seemed to work for me initially. I changed the project configuration as required (eg. selecting correct device, making sure correct MC library is used etc). After compiling I loaded it into my hardware and BAM it worked!!

Strange - I set it up the same way as for the other F302 user project.

I started investigating. I looked at map files from both projects and noticed that the code was not exactly the same (as one would have expected). One of the functions compiled with a different size:

0690X00000607AhQAI.png

I investigated further and compared the project options, one by one. I noticed that one defined symbol was missing in the STM32F302_SINGLE_DRIVE project (eg. the one that was not working). ''CCMRAM'' was missing from the defined symbols list in project options. After adding this to the project that was crashing on me, it started to work. Comparing the map files now revealed exactly the same output from both projects.

Not sure exactly how not defining this symbol created the bad code so would love to hear someones though on this.

In short, this was an error in the SDK which probably should be rectified. Thanks ST .

Laurent Ca...
Lead II

The question has been moved from the "Motor Control Hardware" section to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards