Skip to main content
DRobe.4
Associate III
May 2, 2023
Solved

Need Help with Include paths in Keil compiler

  • May 2, 2023
  • 10 replies
  • 9481 views

Using Keil V5, C program for stm32g0. Have tried to add include paths in Project.Options for target. C tab. include paths, for instance:

C:/Users/ashto/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/CMSIS/Include;..\..\STM32Cube\Repository\STM32Cube_FW_G0_V1.6.1\Drivers\STM32G0xx_HAL_Driver\Inc

but GPIOInitStruct is undefined, interrupt request names, USART and Timer register names. Many errors. I must be making some simple, fundamental mistake.

This topic has been closed for replies.
Best answer by raptorhal2

Here is another way to tackle the problem, if you don't mind a more automated process:

Create your project in Cube MX, and then in Project Manager, choose MDK-ARM as the Toolchain/IDE.

My attempt at this resulted in a zero error(s) and warning(s) message for the build.

Perhaps it's my error, but header files were not listed in the Project view.

10 replies

raptorhal2
Lead
May 2, 2023

I must be making some simple, fundamental mistake.

Apparently we both are. If I figure it out first, I will post here. Request you do the same.

DRobe.4
DRobe.4Author
Associate III
May 3, 2023

My GPIO_InitStruct errors disappeared (except for GPIO_SPEED_LOW once I entered the command

GPIO_InitTypeDef GPIO_InitStruct;

I am beginning to understand what may be causing all these errors... the whole STM32 ecosystem is built around Cube, where the pins, functions, clocks are all defined in a graphical interface. I am converting code from Microchip to STM32 without using the graphical interface and so some code seems to be missed (like the above statement, which is probably buried inside some obscure routine when using Cube). Most people don't convert by hand, as I am doing, so Cube is successful for the majority. For me, I'll bet if I ran through the Cube process and then added the non-hardware-interface C code afterwards, I wouldn't get the errors that plague me.

Tesla DeLorean
Guru
May 3, 2023

Well Cube/GUI do hide stuff all over the place making it harder to follow the plot..

Look in the MSP files for the code that actually does a lot of the work behind the scenes.

The HAL doesn't require any of that, you can have clear linear code enable clocks, pins and interfaces/peripherals without any of the CubeMX nonsense/obfuscation.

For missing definitions, check stm32xyz_hal_conf.h has this often controls the include files pulled in, or not.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
KDJEM.1
Technical Moderator
May 2, 2023

Hello @DRobe.4​ ,

Please make sure that you are using the “/�? and not the “\�? in the paths.

This discussion can help you to add path with Keil.

Could you please share what errors did you found?

Thank you.

Kaouthar

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.
DRobe.4
DRobe.4Author
Associate III
May 2, 2023

Here is a sample of the errors... I can send the whole file to you if it helps. The project was previously running successfully for years on a Microchip CPU, but I thought it could be converted easily to STM32... apparently not.

ERNode_G070.c(447): error: use of undeclared identifier 'GPIO_InitStruct'

ERNode_G070.c(433): warning: no previous prototype for function 'USART4_IRQHandler' [-Wmissing-prototypes]..... I guess I need to declare it

ERNode_G070.c(435): error: use of undeclared identifier 'USART4_IRQn'

ERNode_G070.c(413): note: declare 'static' if the function is not intended to be used outside of this translation unit

void USART3_IRQHandler(void)  

ERNode_G070.c(395): error: no member named 'DR' in 'ADC_Common_TypeDef'

    ADC16 = ADC->DR; 

ERNode_G070.c(393): error: no member named 'CR' in 'ADC_Common_TypeDef'

               ADC->CHSELR = 0x80; Delayus(1); ADC->CR = 1; 

ERNode_G070.c(395): error: no member named 'DR' in 'ADC_Common_TypeDef'

               ADC16 = ADC->DR; 

../../STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h(4148): error: use of undeclared identifier 'ADC_AWD1TR_HT1'

            ADC_AWD1TR_HT1 | ADC_AWD1TR_LT1,

            ^

../../STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h(4148): error: use of undeclared identifier 'ADC_AWD1TR_LT1'

            ADC_AWD1TR_HT1 | ADC_AWD1TR_LT1,

                             ^

../../STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h(4223): error: no member named 'AWD1TR' in 'ADC_TypeDef'

 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->AWD1TR,

KDJEM.1
Technical Moderator
May 2, 2023

Hello @DRobe.4​ ,

Could you please share your project and the whole build output file?

Thank you.

Kaouthar

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.
DRobe.4
DRobe.4Author
Associate III
May 2, 2023

Can you give me a link to send it to.. code is 660 lines including comments.

KDJEM.1
Technical Moderator
May 2, 2023

Hi @DRobe.4​ ,

you can add your project in the comment with .zip extension by clicking on this icon (as shown the below figure.


_legacyfs_online_stmicro_images_0693W00000bjDsnQAE.png Kaouthar

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.
DRobe.4
DRobe.4Author
Associate III
May 3, 2023

I don't mind sending you, an ST employee, my files, but I would rather not send the whole world my files. If that is a problem for you, I will have to do without your help.

KDJEM.1
Technical Moderator
May 3, 2023

Hi @DRobe.4​ ,

You can send me the whole project in a private message.

Thank you.

Kaouthar

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.
Pavel A.
Super User
May 2, 2023

Do you have stm32g0xx_hal_conf.h file in your project?

Are the needed modules (GPIO ...) enabled there?

raptorhal2
raptorhal2Best answer
Lead
May 15, 2023

Here is another way to tackle the problem, if you don't mind a more automated process:

Create your project in Cube MX, and then in Project Manager, choose MDK-ARM as the Toolchain/IDE.

My attempt at this resulted in a zero error(s) and warning(s) message for the build.

Perhaps it's my error, but header files were not listed in the Project view.

DRobe.4
DRobe.4Author
Associate III
May 20, 2023

I had heard about this before. All other methods failed to link correctly, but this one worked. So thank you for reminding me of this idea. I now can't download on ST-Link for some reason, so I will have to enter another question to the ST audience of experts.

raptorhal2
Lead
May 15, 2023

Here is another way, if you don't mind a more automated approach.

Create your project with CUBE MX, then in the Project Manager window select MDK-ARM as the Toolchain/IDE, filling in the rest of the window as appropriate. My attempt resulted in a build with no errors or warnings. Perhaps it was my error, but header files were in the project directory, but not listed in the uVision project window.

raptorhal2
Lead
May 21, 2023

A standard ST-Link V2 pod downloaded to flash OK for an STM32L562 application. Make sure your pod firmware is the latest.

Edit: This was in SWD mode.

However, uVision Debug would not run to main. It hung on the first startup code line and would not step. It would not run to main until the second click on Run, then it stepped OK and ran OK. But a power cycle still hung on startup. At this point, I don't know if this is an STLink or Keil uVision problem, or some KEIL/ST integration problem.