This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Migrate project to Keil µVision 4

Hello,

I got difficulties with the Keil µVision 4 IDE. I'm using the ST Discovery-Board (STM32F407VG) and want to use the Discovery-Board as an I2C-Master. I got a working CooCox-project, but now I have to migrate it to Keil µVision 4.

When I create a new project (in µVision 4) I'm able to communicate with the board (I did some blinky-programs successfully).
Problem seems to be the correct usage of libraries/ errors from the linker.

My working CooCox-project is derived from this example:
").

This project has main.c/.h and stm32_ub_i2c1.c/.h with I2C-functions.
Other embedded code in the CooCox-project: stm32f4xx.c/.h stm32f4xx_gpio.c/.h stm32f4xx_rcc.c/.h stm32f4xx_i2c.c/.h

Thank you for your help.

Best Regards,
Ilyas

  • Clone one of the STM32F4-Discovery project examples or templates, and then merge in your changes.

    Alternatively look at one of those projects, paying specific attention to the file structures, and the defines and include paths.

  • Hello,

    thank you for your answer. I tried to use example projects, but those that I got are read-only. So I can't add new files to my project or save changes.

    Where do you got the examples from?
    Thank you for your help.

    Ilyas

  • that would probably be the time to consider removing the read only attribute then.

    you're not trying to edit a project on a cd are you?

  • Some ZIP archive tools will do that, based on the attributes stored with the file.

    Ok, so after you copy and paste the directory, go in and right click and remove the Read-Only attribute. Or use ATTRIB from the command line, or use a file manager of choice.

  • Hello,

    the folder with the example-projects was zipped, after extracting it was locked. I removed the write-protect and tried again.

    The standard MDK-ARM project (STM32F4xx_StdPeriph_Template) compiled with just 37 Errors.

    (I downloaded the standard-peripheral-library, extracted it [on my HDD], removed the write protect, opened the project, selected my device and complied)

    So something must be wrong here.
    Do you got a source where I can get working example code?

    Thanks a lot,
    Ilyas

  • 37 errors may sound like much but may be nothing. It can be enough with a single missed #define to create an avalanche of errors. So it's often only relevant to look at the first error and figure out the solution to solve that. Then recompile and see how many errors that remains.

  • Hello,

    I tried to solve the errors, but didn't succeed.
    First error:
    ********************
    compiling system_stm32f4xx.c...
    ..\..\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h(418): error: #67: expected a "}" EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
    ********************

    The related position in the code (stm32f4xx.h) is:

    (...)
    
    #if defined (STM32F429_439xx)
      CAN1_TX_IRQn                = 19,     /*!< CAN1 TX Interrupt                               */
    (...)
     LTDC_ER_IRQn                = 89,     /*!< LTDC Error global Interrupt                      */
      DMA2D_IRQn                  = 90      /*!< DMA2D global Interrupt                          */
    #endif /* STM32F429_439xx */
    
    #if defined (STM32F401xx) /* this is line 67 of stm32f4xx.h */
      EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                   */
      TIM1_BRK_TIM9_IRQn          = 24,     /*!< TIM1 Break interrupt and TIM9 global interrupt  */
    

    If I add the suggested bracket after

    #if defined (STM32F401xx)
    

    I get 73 errors, first one is:
    ..\..\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h(342): error: #14-D: extra text after expected end of preprocessing directive #if defined (STM32F429_439xx) {

    ... This is confusing to me.

    Greetings, Ilyas

  • The related position in the code (stm32f4xx.h) is:

    Not if that comment

    #if defined (STM32F401xx) /* this is line 67 of stm32f4xx.h */
    

    is correct it isn't. In that message, '#67' is not the line number.

    The problem most likely is that for some reason, you have multiple STM32... macros defined, while that code somewhat clearly expects that only one such macro be defined.

  • Indeed, what defines do you have in the project (the ones Keil puts on the command line, and specified in the "C/C++" pane of the Project Options

  • I had tried to respond earlier but kept getting 500.100 errors from the server, as if it were sensitive the content of the post, the timing, or the IP address

  • First of all: thanks to all of you for your answers.
    I added the comment "/* this is line 67 of stm32f4xx.h */" in the code, I'm sorry. It was my mistake.

    The hint with the macros and various derivations of the STM32F4 Discovery-Board made me think. In µVision 4 you have to choose your device in the "Target Options". This was the setting I checked the whole time, it was always right with stm32f407vg. But: There's an additional drop-down menu in the options where you have to select the correct target as well. That offers just 4 options: STM32F429_439xx; STM32F427_437xx; STM32F40_41xx and STM32F401xx. (I never really expected a second target-selection-menu ...).

    So with the first setting on "stm32f407vg" and the second on "STM32F40_41xx" it compiles with 0 errors and some (37 warnings), most of them are like >..\..\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h(88): warning: #47-D: incompatible redefinition of macro "STM32F40_41xxx"<.
    The other 3 options of the second drop-down-menu generate 37 errors (as before).

    So now I got it compiled (second setting on "STM32F40_41xx", but when trying to load the code to the board it says "Unknown target connected" and "Error: Flash Download failed - Target DLL has been cancelled".
    I got the Discovery-Board connected via ST-Link to my PC (device manager doesn't show any issues with the device).
    Which settings do I have to change or does the project not support this board?!

    Greetings, Ilyas

  • I missed the fact, that I selected the ST-Link in the properties of the project. So what might be wrong here?

    Ilyas

  • Did you also select the ST-Link in the Utilities tab for Flash Download (Options for Target)?

  • Hello,

    I now got a working connection with µVision 4 to the Discovery Board.
    You have to select the ST-Link Debugger in the "Debug"-Tab of the project-settings. But with just this (as I tried it) is not the whole story. Additional you have to configure the ST-Link Debugger to use "SW" as port instead of JTAG and then select the ARM CoreSight device. Note that you have your Discovery-Board plugged in, otherwise it won't display the ARM CoreSight device.

    At the moment, I got a working connection to the board and an example project (Template project). Now I have to transform the code from the CooCox-project to µVision 4.
    What do I have to consider?
    I'll report back in about 2 hours, I didn't had the opportunity to move the CooCox project till now.

    Greetings, Ilyas

  • Hi there,

    sorry that I am late with my answer, but something in life didn't go as intended.
    So now I added the code from the CooCox-project into the µVvision 4 project and tried to compile. I was quite happy that all libraries seem to fit. I got a connection to the board, so I can transmit the code. But When starting debugging, it doesn't start code execution.

    The LED of the ST-Link blinks red, green, red, etc... when I hit start debugging and keeps blinking. (If everything is fine, the LED blinks for some seconds and stays green then.)
    Is that a sign of a problem within the start-up of the CPU and how can I solve the issue?

    Greetings, Ilyas