Errors While Compiling STM32F10x Standard Peripheral Library in Keil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 06:33 PM - last edited on 2024-08-09 02:01 AM by Amelie ACKERMANN
Hello,
I’m encountering multiple errors and warnings when trying to compile a project using the STM32F10x Standard Peripheral Library in Keil uVision. The specific errors are related to assert_param being undeclared and numerous UTF-8 warnings in comments.
Environment:
STM32F10x Standard Peripheral Library
Keil uVision (Using ARM Compiler v6.21)
Key Errors:
call to undeclared function 'assert_param'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
invalid UTF-8 in comment [-Winvalid-utf8] in stm32f10x.h
It seems like the compiler isn't recognizing the assert_param macro, which is leading to multiple errors. I’ve ensured that the stm32f10x_conf.h file includes the necessary header files, but the issue persists.
Has anyone experienced similar issues or can provide guidance on resolving these errors?
Thank you!
Solved! Go to Solution.
- Labels:
-
Bug-report
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 10:40 PM
Thank you for your kind response. I found the solution by defining USE_STDPERIPH_DRIVER in the project header file. I made the following changes in the stm32f10x_rcc.h header file, and now everything is working fine:
#ifndef __STM32F10X_CONF_H
#define __STM32F10X_CONF_H
#define USE_STDPERIPH_DRIVER
#include "stm32f10x.h" // Main STM32F10x header
#include "stm32f10x_gpio.h" // GPIO header
#include "stm32f10x_rcc.h" // RCC header
// Include other necessary headers...
// Define assert_param macro if not already defined
#ifdef USE_STDPERIPH_DRIVER
#define assert_param(expr) ((void)0) // Implement according to your needs
#else
#define assert_param(expr) ((void)0)
#endif
#endif /* __STM32F10X_CONF_H */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 07:01 PM
> invalid UTF-8 in comment [-Winvalid-utf8] in stm32f10x.h
You sure you have valid files? The library shouldn't have non UTF-8 characters.
Perhaps post your file here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 07:16 PM
Thank you for your response. I double-checked the files, and they seem to be valid. The issue might not be with the library itself but potentially with the encoding settings on my end. I’ve followed the instructions as you suggested, but the problem persists.
Here’s what I’ve tried so far:
- Verified that the files are not corrupted and match the repository.
- Made sure my editor is set to use UTF-8 encoding.
- Recompiled the project after ensuring everything is in UTF-8.
However, I still get the invalid UTF-8 in comment [-Winvalid-utf8] error in stm32f10x.h
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 08:00 PM
The SPL data back to uVision 4
Where are you pulling these files? Some third-party repo, or the .zip files for the libraries off ST's site? What version?
What line and comment is it objected too?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 08:22 PM
I am using Keil uVision 5 to run some code. When I translate the current file, I get zero errors but 5 warnings. However, when I build the target files, I encounter many errors. I have attached the code and the error messages below. I have been trying to solve this problem for more than five days but still can't figure it out. Can someone help me identify the issue and how to fix it?
***************************************************************************************************************************
#include "stm32f10x.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_tim.h"
// Function Prototypes
void PWM_Init(uint16_t period, uint16_t prescaler);
void Set_PWM_DutyCycle(uint16_t dutyCycle);
int main(void) {
// Initialize PWM with a period of 1000 and a prescaler of 72
PWM_Init(1000, 72);
while (1) {
// Set the PWM duty cycle to 50% (mid-speed)
Set_PWM_DutyCycle(500);
// Add your control logic here (e.g., changing the duty cycle based on speed commands)
}
}
void PWM_Init(uint16_t period, uint16_t prescaler) {
// Enable clock for GPIOA and TIM2
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
// Configure PA0 (TIM2_CH1) as alternate function push-pull
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// Timer configuration
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructure.TIM_Period = period - 1;
TIM_TimeBaseStructure.TIM_Prescaler = prescaler - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
// PWM mode configuration
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 0; // Start with 0% duty cycle
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM2, &TIM_OCInitStructure);
// Start TIM2
TIM_Cmd(TIM2, ENABLE);
}
void Set_PWM_DutyCycle(uint16_t dutyCycle) {
TIM_SetCompare1(TIM2, dutyCycle);
}
*******************************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 08:37 PM
Are you defining USE_STDPERIPH_DRIVER during the build process? Or you can make sure it's defined from within stm32f10x.h. Need that to pull in assert_param.
Looks like your apostrophe marks are not UTF-8.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-08-08 10:40 PM
Thank you for your kind response. I found the solution by defining USE_STDPERIPH_DRIVER in the project header file. I made the following changes in the stm32f10x_rcc.h header file, and now everything is working fine:
#ifndef __STM32F10X_CONF_H
#define __STM32F10X_CONF_H
#define USE_STDPERIPH_DRIVER
#include "stm32f10x.h" // Main STM32F10x header
#include "stm32f10x_gpio.h" // GPIO header
#include "stm32f10x_rcc.h" // RCC header
// Include other necessary headers...
// Define assert_param macro if not already defined
#ifdef USE_STDPERIPH_DRIVER
#define assert_param(expr) ((void)0) // Implement according to your needs
#else
#define assert_param(expr) ((void)0)
#endif
#endif /* __STM32F10X_CONF_H */