Forum: Mikrocontroller und Digitale Elektronik STM32 Keil warning: #223-D: function "assert_param" declared implicitly


von Roger S. (yello8247)


Angehängte Dateien:

Lesenswert?

Hallo Zusammen

Ich habe folgendes Verständnisproblem:

Anhand eines Example-projektes von Keil habe ich ein kleines
Programm aufgebaut und dieses läuf auch fehlerfrei.
Die Einbindung der Library: mit .lib Datei von ST


Anhand eines anderen Beispiel-Projektes wollte ich nun die Einbindung
der Library von ST verändern
Die Einbindung der Library: mit .c Dateien von ST

Vorteil bei C-Dateien kann ich in die Programmierung der Library sehen.
Bei der .LIB Datei nicht !!!

Nun bekomme ich aber folgende Fehlermeldungen:

..\src\stm32f10x_stdperiph_lib\Libraries\STM32F10x_StdPeriph_Driver\src\ 
stm32f10x_adc.c(181):  warning:  #223-D: function "assert_param" 
declared implicitly

Was ist da fehlgelaufen ?
Ist die Datei .LIB nicht einfach eine zusammengepackte Datei mit all
den C-Dateien der Library ?

Ich verstehe wohl das Konzept der Library noch nicht !!

Kann mir Da jemand helfen ?

Gruss
Yello

von Matthias K. (matthiask)


Lesenswert?

Roger Schweizer schrieb:
> assert_param

Hast Du die Assert-Fkt. eingebunden? Wird meist an das Ende des 
Hauptprogrammes gesetzt.
1
#ifdef  USE_FULL_ASSERT
2
3
/**
4
  * @brief  Reports the name of the source file and the source line number
5
  *   where the assert_param error has occurred.
6
  * @param  file: pointer to the source file name
7
  * @param  line: assert_param error line source number
8
  * @retval None
9
  */
10
void assert_failed(uint8_t* file, uint32_t line)
11
{
12
  /* User can add his own implementation to report the file name and line number,
13
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
14
15
  /* Infinite loop */
16
  while (1)
17
  {
18
  }
19
}
20
#endif
21
22
/*
23
 * Minimal __assert_func used by the assert() macro
24
 * */
25
void __assert_func(const char *file, int line, const char *func, const char *failedexpr)
26
{
27
  while(1)
28
  {}
29
}
30
31
/*
32
 * Minimal __assert() uses __assert__func()
33
 * */
34
void __assert(const char *file, int line, const char *failedexpr)
35
{
36
   __assert_func (file, line, NULL, failedexpr);
37
}
38
39
#ifdef USE_SEE
40
#ifndef USE_DEFAULT_TIMEOUT_CALLBACK
41
/**
42
  * @brief  Basic management of the timeout situation.
43
  * @param  None.
44
  * @retval sEE_FAIL.
45
  */
46
uint32_t sEE_TIMEOUT_UserCallback(void)
47
{
48
  /* Return with error code */
49
  return sEE_FAIL;
50
}
51
#endif
52
#endif /* USE_SEE */

von Roger Schweizer (Gast)


Lesenswert?

Hmm

Vielen Dank mal für Deinen input !

Beim Projekt (mit C-Files als Library) habe ich noch folgende 
Header-Datei
gefunden die eingebunden wird:

Hat dies die selbe Wirkung wie Dein Vorschlag ?
Und warum braucht es Dies im Keil Bsp. nicht ?

Gruss
Yello

/**
  ************************************************************************ 
******
  * @file    Project/Template/stm32f10x_conf.h
  * @author  MCD Application Team
  * @version V3.1.2
  * @date    09/28/2009
  * @brief   Library configuration file.
  ************************************************************************ 
******
  * @copy
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING 
CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM 
TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR 
ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS 
ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS 
OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR 
PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
  */

/* Define to prevent recursive inclusion 
-------------------------------------*/
#ifndef __STM32F10x_CONF_H
#define __STM32F10x_CONF_H

/* Includes 
------------------------------------------------------------------*/
/* Uncomment the line below to enable peripheral header file inclusion 
*/
/* #include "stm32f10x_adc.h" */
/* #include "stm32f10x_bkp.h" */
/* #include "stm32f10x_can.h" */
/* #include "stm32f10x_crc.h" */
/* #include "stm32f10x_dac.h" */
/* #include "stm32f10x_dbgmcu.h" */
#include "stm32f10x_dma.h"
#include "stm32f10x_exti.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_fsmc.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_i2c.h"
/* #include "stm32f10x_iwdg.h" */
/* #include "stm32f10x_pwr.h" */
#include "stm32f10x_rcc.h"
/* #include "stm32f10x_rtc.h" */
/* #include "stm32f10x_sdio.h" */
#include "stm32f10x_spi.h"
#include "stm32f10x_tim.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on 
to CMSIS functions) */

/* Exported types 
------------------------------------------------------------*/
/* Exported constants 
--------------------------------------------------------*/
/* Uncomment the line below to expanse the "assert_param" macro in the
   Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT    1 */

/* Exported macro 
------------------------------------------------------------*/
#ifdef  USE_FULL_ASSERT

/**
  * @brief  The assert_param macro is used for function's parameters 
check.
  * @param  expr: If expr is false, it calls assert_failed function
  *   which reports the name of the source file and the source
  *   line number of the call that failed.
  *   If expr is true, it returns no value.
  * @retval None
  */
  #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t 
*)__FILE__, _LINE_))
/* Exported functions 
------------------------------------------------------- */
  void assert_failed(uint8_t* file, uint32_t line);
#else
  #define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */

#endif /* __STM32F10x_CONF_H */

/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF 
FILE****/

von Matthias K. (matthiask)


Lesenswert?

Keil-Beispiele laufen mW ohne die STM FW-Lib. Die haben was eigenes. 
Vermutlich wird dort die assert-Funktion nicht gebraucht(?)

von Roger Schweizer (Gast)


Lesenswert?

ok

Vielen Dank für Eure Inputs !

Demnach muss ich mich wohl doch noch in die FW-Lib von ST
einlesen ?!?

Kennt jemand ein Tutorial welches sich alleine auf die Lib bezieht ?

Gruss
Yello

von Matthias K. (matthiask)


Lesenswert?

In der FW-Lib sind viele Beispiele drin, zu praktisch jeden 
Peripherie-Modul. Ein Tutorioal zur FW Lib ist mir nicht bekannt, halte 
Dich einfach an die Beispiele und Templates. Für Keil ist auch eins 
dabei.

Das kennst Du?
http://www.mikrocontroller.net/articles/STM32
http://www.mikrocontroller.net/articles/STM32F10x_Standard_Peripherals_Library

von Roger Schweizer (Gast)


Lesenswert?

Vielen Dank

Mit den Artikeln hier vom Forum und der Library von ST
sollte ich wohl zurecht kommen.

Gruss
Yello

von A. B. (funky)


Lesenswert?

Ich habe jetzt das gleiche Problem

Ich binde in meiner main.c  die Datei "stm32f2xx_conf.h" ein. Dort sind 
auch die Assert Makros definiert&aktiviert
Aktiviere ich dort aber zum Beispiel die GPIO Library ein, bekomme ich 
auch den "function "assert_param" declared implicitly" Fehler, weil in 
der GPIO Lib  die Assert makros nicht bekannt sind.

Binde ich in der GPIO Library die "stm32f2xx_conf.h", verschwindet der 
Fehler.

Das kann ich ja noch nachvollziehen. Aber da das eine fertige Library 
ist, wundert es mich schon, ob ich die "stm32f2xx_conf.h" jetzt überall 
manuell bei den einzelnen StdPeripherie Treibern einbinden muss?
Oder kann man das irgendwie über die IDE lösen, das man für bestimmte 
Files die "stm32f2xx_conf.h" standardmässig einbindet?  Ich benutze Keil 
uVision.


Und nun habe ich in dem Zusammenhang noch ein Problem:

Ich binde das "stm32f2xx_conf.h" manuell bei dem GPIO Treiber ein. Die 
"...declared implicity" Meldung verschwindet.

ich setze USE_FULL_ASSERT auf 0, so das eigenlich die assert - Makros 
nicht benutzt werden sollten. Nun bekomme ich aber die Fehlermeldung:

Error: L6218E: Undefined symbol assert_failed (referred from 
stm32f2xx_gpio.o)

Woran könnte das liegen?

von Matthias K. (matthiask)


Lesenswert?

A. B. schrieb:
> Ich binde in meiner main.c  die Datei "stm32f2xx_conf.h" ein. Dort sind
> auch die Assert Makros definiert&aktiviert

Eigentlich sind die hinter der Main abgelegt. Die "stm32f2xx_conf.h" 
ansich braucht man nicht separat einbinden. Man kann darin evetuell 
nicht gebrauchte Libs rauskomentieren. Bringt nur etwas Zeitgewinn beim 
compilieren aber nicht weniger Code.

Binde stattdessen am Anfang die "stm32f10x.h" ein und setze global die 
notwendigen Symbos.

von Steffen (Gast)


Lesenswert?

A. B. schrieb:
> ich setze USE_FULL_ASSERT auf 0, so das eigenlich die assert - Makros
> nicht benutzt werden sollten. Nun bekomme ich aber die Fehlermeldung:
>
> Error: L6218E: Undefined symbol assert_failed (referred from
> stm32f2xx_gpio.o)
>
> Woran könnte das liegen?

Da USE_FULL_ASSERT per
1
#ifdef
 getestet wird, ist der Wert egal. Das Define darf garnicht definiert 
werden.

von A. B. (funky)


Lesenswert?

ach scheisse...ja, das wirds sein. so ein dämlicher fehler :) probier 
ich dann gleich nochmal aus.

und bezüglich der "stm32f2xx_conf.h"
also bei mir waren die asserts in dem file konfiguriert? ich habe das 
file aus einem der beispielprojekte kopiert. denn in dem normalen 
standard library zip ist das file ja gar nicht enthalten.

aber danke schon mal :)

von A. B. (funky)


Lesenswert?

ja, das mit dem ifdef wars natürlich

zu anfang war auch die ganze zeile auskommentiert, im zuge des testens 
hab ichs dann verpeilt

von Hexo (Gast)


Lesenswert?

Hallo,
ich hatte das gleiche Problem mit dem Assert Fehler
(habe den IAR compiler)

Lösung war:
in main.c, am ende:

#ifdef  USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{ while (1){}
}
#endif


und USE_STDPERIPH_DRIVER in den Defines Symbols "options Präprozessor" 
einfügen

damit die stm32f0xx_conf.h eingebunden wird
(#ifdef USE_STDPERIPH_DRIVER
  #include "stm32f0xx_conf.h"
#endif in der Datei "stm32f0xx.h" )

von Sagaert (Gast)


Lesenswert?

Hi

You must add USE_STDPERIPH_DRIVER in the pre processor (c/c++) tab of 
the project settings.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.