Forum: Mikrocontroller und Digitale Elektronik stm32 Problem


von mark (Gast)


Lesenswert?

Ich bin gerade dabei mich in die stm32 Welt einzuarbeiten,
mithilfe der von ST bereitgestellten API.

Leider scheitert es aber bereits beim simplen Versuch einen Port zu 
konfigurieren.

Bei folgendem Code:
1
#include "stm32f10x.h"
2
#include "stm32f10x_gpio.h"
3
4
  int main(void)
5
  {
6
    while(1)
7
    {
8
      GPIO_InitTypeDef test;
9
      
10
      test.GPIO_Speed = GPIO_Speed_10MHz;
11
      test.GPIO_Pin = GPIO_Pin_1;
12
      test.GPIO_Mode = GPIO_Mode_Out_PP;
13
14
       GPIO_Init(GPIOC, &test);
15
    }
16
   return;
17
  }

erhalte ich beim kompilieren die Meldung:

testing.axf: Error: L6218E: Undefined symbol GPIO_Init (referred from 
main.o).

Als IDE kommt Keil zum Einsatz.

von Jörg R. (ruppi66)


Lesenswert?

Hallo Mark,

erstmal hast Du in der STM32F10x_CONF.h die benutzte Peripherie 
freigegeben? (Defines)
Außerdem fehlt die Taktgeschichte.
Schau dir mal Beispielcode an und den Artikel hier im Forum über
die Standard-Lib von ST. Ist zwar erst im Entstehen, aber
deine ersten Fragen müssten abgedeckt werden.

Gut schwitz und Gruß Ruppi66

von (prx) A. K. (prx)


Lesenswert?

mark schrieb:

> testing.axf: Error: L6218E: Undefined symbol GPIO_Init (referred from
> main.o).

stm32f10x_gpio.h muss mitkompiliert und -gelinkt werden. Darin ist diese 
Funktion definiert.

von Manfred (Gast)


Lesenswert?

A. K. schrieb:
> stm32f10x_gpio.h muss mitkompiliert und -gelinkt werden.

Ist das nicht mit #include "stm32f10x_gpio.h" getan?

von (prx) A. K. (prx)


Lesenswert?

Sorry, cut-and-paste Fehler. Die .c war gemeint.

von DerM (Gast)


Lesenswert?

Habe dasselbe Problem mit einem STM32F0 Board, kann jemand helfen?

folgendes Programm:

#include "stm32f0xx.h"                  // Device header
#include "Board_LED.h"                  // ::Board Support:LED
#include "Board_Buttons.h"              // ::Board Support:Buttons
#include "stm32f0xx_rcc.h"
#include "stm32f0xx_gpio.h"

int main(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  GPIO_WriteBit(GPIOC, GPIO_Pin_9, Bit_SET);

  while(1)  {
  }
}




folgender Fehler:



Rebuild target 'Target 1'
compiling main.c...
main.c(38): warning:  #1-D: last line of file ends without a newline
  }
main.c: 1 warning, 0 errors
compiling Buttons_STM32F0-Discovery.c...
compiling LED_STM32F0-Discovery.c...
assembling startup_stm32f051.s...
compiling system_stm32f0xx.c...
linking...
.\Objects\test.axf: Error: L6218E: Undefined symbol GPIO_Init (referred 
from main.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol GPIO_StructInit 
(referred from main.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol GPIO_WriteBit 
(referred from main.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol 
RCC_AHBPeriphClockCmd (referred from main.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 4 error messages.
".\Objects\test.axf" - 4 Error(s), 1 Warning(s).
Target not created.

von Jim M. (turboj)


Lesenswert?

DerM schrieb:
> Habe dasselbe Problem mit einem STM32F0 Board, kann jemand helfen?

Die Lösung steht direkt über Deinem Beitrag. Es fehlen die 
entsprechenden .c Dateien der ST-Lib im Projekt.

von DerM (Gast)


Lesenswert?

Die sind jetzt drin, machts aber auch nicht besser:

Rebuild target 'Target 1'
compiling main.c...
main.c(38): warning:  #1-D: last line of file ends without a newline
  }
main.c: 1 warning, 0 errors
compiling stm32f0xx_gpio.c...
stm32f0xx_gpio.c(122): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(174): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(250): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_LIST_PERIPH(GPIOx));
stm32f0xx_gpio.c(299): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(323): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(345): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(369): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(389): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(410): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(435): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(460): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c(516): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
stm32f0xx_gpio.c: 12 warnings, 0 errors
compiling stm32f0xx_rcc.c...
stm32f0xx_rcc.c(204): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_HSE(RCC_HSE));
stm32f0xx_rcc.c(266): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_HSI_CALIBRATION_VALUE(HSICalibrationValue));
stm32f0xx_rcc.c(298): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(326): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_HSI14_CALIBRATION_VALUE(HSI14CalibrationValue));
stm32f0xx_rcc.c(355): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(376): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(408): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_LSE(RCC_LSE));
stm32f0xx_rcc.c(434): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_LSE_DRIVE(RCC_LSEDrive));
stm32f0xx_rcc.c(458): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(491): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));
stm32f0xx_rcc.c(515): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(541): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(565): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_PREDIV1(RCC_PREDIV1_Div));
stm32f0xx_rcc.c(590): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(621): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_MCO_SOURCE(RCC_MCOSource));
stm32f0xx_rcc.c(777): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource));
stm32f0xx_rcc.c(827): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_HCLK(RCC_SYSCLK));
stm32f0xx_rcc.c(858): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_PCLK(RCC_HCLK));
stm32f0xx_rcc.c(887): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_ADCCLK(RCC_ADCCLK));
stm32f0xx_rcc.c(912): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_CECCLK(RCC_CECCLK));
stm32f0xx_rcc.c(932): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_I2CCLK(RCC_I2CCLK));
stm32f0xx_rcc.c(964): warning:  #223-D: function "assert_param" declared 
implicitly
    assert_param(IS_RCC_USARTCLK(RCC_USARTCLK));
stm32f0xx_rcc.c(1003): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_USBCLK(RCC_USBCLK));
stm32f0xx_rcc.c(1288): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));
stm32f0xx_rcc.c(1305): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(1328): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
stm32f0xx_rcc.c(1366): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph));
stm32f0xx_rcc.c(1405): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
stm32f0xx_rcc.c(1451): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
stm32f0xx_rcc.c(1482): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_AHB_RST_PERIPH(RCC_AHBPeriph));
stm32f0xx_rcc.c(1518): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
stm32f0xx_rcc.c(1561): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
stm32f0xx_rcc.c(1613): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_IT(RCC_IT));
stm32f0xx_rcc.c(1656): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_FLAG(RCC_FLAG));
stm32f0xx_rcc.c(1726): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_GET_IT(RCC_IT));
stm32f0xx_rcc.c(1758): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_CLEAR_IT(RCC_IT));
stm32f0xx_rcc.c: 36 warnings, 0 errors
compiling Buttons_STM32F0-Discovery.c...
compiling LED_STM32F0-Discovery.c...
assembling startup_stm32f051.s...
compiling system_stm32f0xx.c...
linking...
.\Objects\test.axf: Error: L6218E: Undefined symbol assert_param 
(referred from stm32f0xx_gpio.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 1 error messages.
".\Objects\test.axf" - 1 Error(s), 49 Warning(s).
Target not created.

von DerM (Gast)


Angehängte Dateien:

Lesenswert?

Im Anhang ist der Programmaufbau zu sehen. Trotzdem kommen Tonnenweise 
Warnings und Errors.

Rebuild target 'Target 1'
compiling main.c...
main.c(19): warning:  #1-D: last line of file ends without a newline
  }
main.c: 1 warning, 0 errors
compiling stm32f0xx_gpio.c...
src\stm32f0xx_gpio.c(122): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(174): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(250): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_LIST_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(299): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(323): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(345): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(369): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(389): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(410): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(435): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(460): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c(516): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
src\stm32f0xx_gpio.c: 12 warnings, 0 errors
compiling stm32f0xx_rcc.c...
src\stm32f0xx_rcc.c(204): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_HSE(RCC_HSE));
src\stm32f0xx_rcc.c(266): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_HSI_CALIBRATION_VALUE(HSICalibrationValue));
src\stm32f0xx_rcc.c(298): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(326): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_HSI14_CALIBRATION_VALUE(HSI14CalibrationValue));
src\stm32f0xx_rcc.c(355): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(376): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(408): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_LSE(RCC_LSE));
src\stm32f0xx_rcc.c(434): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_LSE_DRIVE(RCC_LSEDrive));
src\stm32f0xx_rcc.c(458): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(491): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));
src\stm32f0xx_rcc.c(515): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(541): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(565): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_PREDIV1(RCC_PREDIV1_Div));
src\stm32f0xx_rcc.c(590): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(621): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_MCO_SOURCE(RCC_MCOSource));
src\stm32f0xx_rcc.c(777): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource));
src\stm32f0xx_rcc.c(827): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_HCLK(RCC_SYSCLK));
src\stm32f0xx_rcc.c(858): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_PCLK(RCC_HCLK));
src\stm32f0xx_rcc.c(887): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_ADCCLK(RCC_ADCCLK));
src\stm32f0xx_rcc.c(912): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_CECCLK(RCC_CECCLK));
src\stm32f0xx_rcc.c(932): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_I2CCLK(RCC_I2CCLK));
src\stm32f0xx_rcc.c(964): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_USARTCLK(RCC_USARTCLK));
src\stm32f0xx_rcc.c(1003): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_USBCLK(RCC_USBCLK));
src\stm32f0xx_rcc.c(1288): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));
src\stm32f0xx_rcc.c(1305): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(1328): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_FUNCTIONAL_STATE(NewState));
src\stm32f0xx_rcc.c(1366): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph));
src\stm32f0xx_rcc.c(1405): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
src\stm32f0xx_rcc.c(1451): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
src\stm32f0xx_rcc.c(1482): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_AHB_RST_PERIPH(RCC_AHBPeriph));
src\stm32f0xx_rcc.c(1518): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
src\stm32f0xx_rcc.c(1561): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
src\stm32f0xx_rcc.c(1613): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_IT(RCC_IT));
src\stm32f0xx_rcc.c(1656): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_FLAG(RCC_FLAG));
src\stm32f0xx_rcc.c(1726): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_GET_IT(RCC_IT));
src\stm32f0xx_rcc.c(1758): warning:  #223-D: function "assert_param" 
declared implicitly
    assert_param(IS_RCC_CLEAR_IT(RCC_IT));
src\stm32f0xx_rcc.c: 36 warnings, 0 errors
compiling Buttons_STM32F0-Discovery.c...
compiling LED_STM32F0-Discovery.c...
assembling startup_stm32f051.s...
compiling system_stm32f0xx.c...
linking...
.\Objects\test.axf: Error: L6218E: Undefined symbol assert_param 
(referred from stm32f0xx_gpio.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 1 error messages.
".\Objects\test.axf" - 1 Error(s), 49 Warning(s).
Target not created.

von komisch (Gast)


Lesenswert?

Stell einmal das vollständige uVision Projekt ein und gib den genauen 
Typ vom STM32 an.

von W.S. (Gast)


Lesenswert?

mark schrieb:
> Ich bin gerade dabei mich in die stm32 Welt einzuarbeiten,
> mithilfe der von ST bereitgestellten API.

Ja, eben.
Probiere das doch erstmal schlicht und einfach zu Fuß, indem du selber 
auf die Peripherie zugreifst und dort einstellst, was du denn eigentlich 
so haben willst. Dann lernst du auch, wie die Peripherie so aussieht, 
wie sie funktioniert und wie man damit umgeht. Hardware ist schließlich 
kein Hexenwerk.

Mit dem Herumhampeln an der ST-Lib kriegst du die eigentlichen Lernziele 
ja gar nicht mit.

W.S

von DerM (Gast)


Angehängte Dateien:

Lesenswert?

Hier das komplette Teil als Anhang...
Bei dem Board handelt es sich um ein STM32F0Discovery-Board mit einem 
STM32F051R8 -Chip darauf

von holger (Gast)


Lesenswert?

Mach einfach folgendes define bevor du die STM Header includierst:

#define assert_param(expr) ((void)0)

#include "stm32f10x.h"
#include "stm32f10x_gpio.h"

von DerM (Gast)


Lesenswert?

1
#include "stm32f0xx.h"
2
#include "stm32f0xx_gpio.h"
3
#include "stm32f0xx_rcc.h"
4
5
int main(void)
6
{
7
  GPIO_InitTypeDef GPIO_InitStructure;
8
9
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC,ENABLE);
10
  GPIO_StructInit(&GPIO_InitStructure);
11
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
12
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
13
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
14
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
15
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
16
  GPIO_Init(GPIOC, &GPIO_InitStructure);
17
  GPIO_WriteBit(GPIOC, GPIO_Pin_8, Bit_SET);}
18
19
#ifdef USE_FULL_ASSERT
20
void assert_failed(uint8_t* file, uint32_t line){
21
    /* Infinite loop */
22
    /* Use GDB to find out why we're here */
23
    while(1);
24
}
25
#endif

Mit dem letzten part:
1
#ifdef USE_FULL_ASSERT
2
void assert_failed(uint8_t* file, uint32_t line){
3
    /* Infinite loop */
4
    /* Use GDB to find out why we're here */
5
    while(1);
6
}
7
#endif

läuft es, keine Ahnung wieso, hab das irgendwo im Netz ausgegraben. Kann 
das vielleicht jemand kurz erläutern?
Danke schon einmal!

von Jope (Gast)


Lesenswert?

Wirf mal einen Blick in die Datei stm32f0xx_conf.h, vielleicht geht Dir 
dann ein Licht auf.

von DerM (Gast)


Lesenswert?

dort steht
1
/* Exported types ------------------------------------------------------------*/
2
/* Exported constants --------------------------------------------------------*/
3
/* Uncomment the line below to expanse the "assert_param" macro in the 
4
   Standard Peripheral Library drivers code */
5
/* #define USE_FULL_ASSERT    1 */
6
7
/* Exported macro ------------------------------------------------------------*/
8
#ifdef  USE_FULL_ASSERT
9
10
/**
11
  * @brief  The assert_param macro is used for function's parameters check.
12
  * @param  expr: If expr is false, it calls assert_failed function which reports 
13
  *         the name of the source file and the source line number of the call 
14
  *         that failed. If expr is true, it returns no value.
15
  * @retval None
16
  */
17
  #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
18
/* Exported functions ------------------------------------------------------- */
19
  void assert_failed(uint8_t* file, uint32_t line);
20
#else
21
  #define assert_param(expr) ((void)0)
22
#endif /* USE_FULL_ASSERT */
Wenn ich meinen Code mit dem letzten Abschnitt laufen lasse funktioniert 
es.
Wenn ich aber in meinem Code den letzten Abschnitt auskommentiere und 
dafür die stm32f0xx_conf.h includiere dann funktioniert es nicht obwohl 
dort dasselbe steht! Warum ist das so?

von Jope (Gast)


Lesenswert?

In Deinem Projekt ist ganz offensichtlich USE_FULL_ASSERT definiert.
Dass führt dazu, dass durch das Makro assert_param die Funktion 
assert_failed() aufgerufen wird. Diese Funktion ist in der Headerdatei 
aber nur deklariert, nicht definiert, also muss sie irgendwo auch 
definiert werden.

von Ich (Gast)


Lesenswert?

Naja, die ganzen "Experten" raten hier ja kräftig draufzu. Lies mal 
besser diesen Beitrag:
http://raviyp.in/index.php/embedded/178-keil-function-assert-param-declared-implicitly-solution

von Ich (Gast)


Lesenswert?

USE_STDPERIPH_DRIVER wird Dich beglücken.

von DerM (Gast)


Lesenswert?

Vielen lieben Dank!

USE_STDPERIPH_DRIVER

Daran lags und es funktioniert nun alles wie es soll!
SUPER!

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.