Forum: Mikrocontroller und Digitale Elektronik Auslesen Reset Source STM32


von Markus R. (freehawk)


Lesenswert?

Hallo zusammen,

ich hab ein Problem beim Auslesen der Reset Source von meinem STM32F429.

Das Projekt habe ich neu angelegt mittels STMCubeMX und dann in SW4STM32 
folgende Zeilen ergänzt:

  // Reset Source auslesen
  // test the reset flags in order because the pin reset is always set.
  if ( RCC_GetFlagStatus ( RCC_FLAG_SFTRST ))
  {
    printf ( "Reset Source: Software Reset\r\n" );
  }
  else if ( RCC_GetFlagStatus ( RCC_FLAG_PORRST ))
  {
    printf ( "Reset Source: Hardware Reset\r\n" );
  }
  else if ( RCC_GetFlagStatus ( RCC_FLAG_PINRST ))
  {
    printf ( "Reset Source: Reset Pin used\r\n" );
  }
  else
  {
    printf ( "Reset Source: unbekannt\r\n" );
  }
  // The flags must be cleared manually after use
  RCC_ClearFlag();

Allerdings bekommen ich Fehler beim Übersetzten:
D:\work\stm32\03_SolarController\Debug/../Src/main.c:128: undefined 
reference to `RCC_GetFlagStatus'
D:\work\stm32\03_SolarController\Debug/../Src/main.c:145: undefined 
reference to `RCC_ClearFlag'
D:\work\stm32\03_SolarController\Debug/../Src/main.c:132: undefined 
reference to `RCC_GetFlagStatus'
D:\work\stm32\03_SolarController\Debug/../Src/main.c:136: undefined 
reference to `RCC_GetFlagStatus'

Meine Vermutung ist dass ich ein include nicht richtig gesetzt habe. 
Entschuldigt bitte ich bin totaler Anfänger in dem Thema.

Danke

Gruß
Markus

von STM Apprentice (Gast)


Lesenswert?

Markus R. schrieb:
> Meine Vermutung ist dass ich ein include nicht richtig gesetzt habe.

Dann zeig doch mal was du inluded hast.

von Markus R. (freehawk)


Lesenswert?

Hier ist die komplette Main.c. Wie gesagt stammt aus dem Cube von dem 
her mit den vielen Kommentaren.
1
/**
2
  ******************************************************************************
3
  * File Name          : main.c
4
  * Description        : Main program body
5
  ******************************************************************************
6
  * This notice applies to any and all portions of this file
7
  * that are not between comment pairs USER CODE BEGIN and
8
  * USER CODE END. Other portions of this file, whether 
9
  * inserted by the user or by software development tools
10
  * are owned by their respective copyright owners.
11
  *
12
  * Copyright (c) 2017 STMicroelectronics International N.V. 
13
  * All rights reserved.
14
  *
15
  * Redistribution and use in source and binary forms, with or without 
16
  * modification, are permitted, provided that the following conditions are met:
17
  *
18
  * 1. Redistribution of source code must retain the above copyright notice, 
19
  *    this list of conditions and the following disclaimer.
20
  * 2. Redistributions in binary form must reproduce the above copyright notice,
21
  *    this list of conditions and the following disclaimer in the documentation
22
  *    and/or other materials provided with the distribution.
23
  * 3. Neither the name of STMicroelectronics nor the names of other 
24
  *    contributors to this software may be used to endorse or promote products 
25
  *    derived from this software without specific written permission.
26
  * 4. This software, including modifications and/or derivative works of this 
27
  *    software, must execute solely and exclusively on microcontroller or
28
  *    microprocessor devices manufactured by or for STMicroelectronics.
29
  * 5. Redistribution and use of this software other than as permitted under 
30
  *    this license is void and will automatically terminate your rights under 
31
  *    this license. 
32
  *
33
  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 
34
  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 
35
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
36
  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
37
  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 
38
  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
41
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
42
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
43
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
44
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45
  *
46
  ******************************************************************************
47
  */
48
/* Includes ------------------------------------------------------------------*/
49
#include "main.h"
50
#include "stm32f4xx_hal.h"
51
#include "cmsis_os.h"
52
#include "lwip.h"
53
54
/* USER CODE BEGIN Includes */
55
56
/* USER CODE END Includes */
57
58
/* Private variables ---------------------------------------------------------*/
59
UART_HandleTypeDef huart3;
60
61
osThreadId defaultTaskHandle;
62
63
/* USER CODE BEGIN PV */
64
/* Private variables ---------------------------------------------------------*/
65
66
/* USER CODE END PV */
67
68
/* Private function prototypes -----------------------------------------------*/
69
void SystemClock_Config(void);
70
static void MX_GPIO_Init(void);
71
static void MX_USART3_UART_Init(void);
72
void StartDefaultTask(void const * argument);
73
74
/* USER CODE BEGIN PFP */
75
/* Private function prototypes -----------------------------------------------*/
76
77
78
79
#ifdef __GNUC__
80
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
81
   set to 'Yes') calls __io_putchar() */
82
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
83
#else
84
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
85
#endif /* __GNUC__ */
86
87
88
89
/* USER CODE END PFP */
90
91
/* USER CODE BEGIN 0 */
92
93
/* USER CODE END 0 */
94
95
int main(void)
96
{
97
98
  /* USER CODE BEGIN 1 */
99
100
  /* USER CODE END 1 */
101
102
  /* MCU Configuration----------------------------------------------------------*/
103
104
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
105
  HAL_Init();
106
107
  /* USER CODE BEGIN Init */
108
109
  /* USER CODE END Init */
110
111
  /* Configure the system clock */
112
  SystemClock_Config();
113
114
  /* USER CODE BEGIN SysInit */
115
116
  /* USER CODE END SysInit */
117
118
  /* Initialize all configured peripherals */
119
  MX_GPIO_Init();
120
  MX_USART3_UART_Init();
121
122
  /* USER CODE BEGIN 2 */
123
124
  printf ( "\r\nApplikation gestartet!\r\n" );
125
126
  // Reset Source auslesen
127
  // test the reset flags in order because the pin reset is always set.
128
  if ( RCC_GetFlagStatus ( RCC_FLAG_SFTRST ))
129
  {
130
    printf ( "Reset Source: Software Reset\r\n" );
131
  }
132
  else if ( RCC_GetFlagStatus ( RCC_FLAG_PORRST ))
133
  {
134
    printf ( "Reset Source: Hardware Reset\r\n" );
135
  }
136
  else if ( RCC_GetFlagStatus ( RCC_FLAG_PINRST ))
137
  {
138
    printf ( "Reset Source: Reset Pin used\r\n" );
139
  }
140
  else
141
  {
142
    printf ( "Reset Source: unbekannt\r\n" );
143
  }
144
  // The flags must be cleared manually after use
145
  RCC_ClearFlag();
146
147
148
149
  /* USER CODE END 2 */
150
151
  /* USER CODE BEGIN RTOS_MUTEX */
152
  /* add mutexes, ... */
153
  /* USER CODE END RTOS_MUTEX */
154
155
  /* USER CODE BEGIN RTOS_SEMAPHORES */
156
  /* add semaphores, ... */
157
  /* USER CODE END RTOS_SEMAPHORES */
158
159
  /* USER CODE BEGIN RTOS_TIMERS */
160
  /* start timers, add new ones, ... */
161
  /* USER CODE END RTOS_TIMERS */
162
163
  /* Create the thread(s) */
164
  /* definition and creation of defaultTask */
165
  osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
166
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
167
168
  /* USER CODE BEGIN RTOS_THREADS */
169
  /* add threads, ... */
170
  /* USER CODE END RTOS_THREADS */
171
172
  /* USER CODE BEGIN RTOS_QUEUES */
173
  /* add queues, ... */
174
  /* USER CODE END RTOS_QUEUES */
175
 
176
177
  /* Start scheduler */
178
  osKernelStart();
179
  
180
  /* We should never get here as control is now taken by the scheduler */
181
182
  /* Infinite loop */
183
  /* USER CODE BEGIN WHILE */
184
  while (1)
185
  {
186
  /* USER CODE END WHILE */
187
188
  /* USER CODE BEGIN 3 */
189
190
  }
191
  /* USER CODE END 3 */
192
193
}
194
195
/** System Clock Configuration
196
*/
197
void SystemClock_Config(void)
198
{
199
200
  RCC_OscInitTypeDef RCC_OscInitStruct;
201
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
202
203
    /**Configure the main internal regulator output voltage 
204
    */
205
  __HAL_RCC_PWR_CLK_ENABLE();
206
207
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
208
209
    /**Initializes the CPU, AHB and APB busses clocks 
210
    */
211
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
212
  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
213
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
214
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
215
  RCC_OscInitStruct.PLL.PLLM = 4;
216
  RCC_OscInitStruct.PLL.PLLN = 168;
217
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
218
  RCC_OscInitStruct.PLL.PLLQ = 7;
219
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
220
  {
221
    _Error_Handler(__FILE__, __LINE__);
222
  }
223
224
    /**Initializes the CPU, AHB and APB busses clocks 
225
    */
226
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
227
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
228
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
229
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
230
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
231
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
232
233
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
234
  {
235
    _Error_Handler(__FILE__, __LINE__);
236
  }
237
238
    /**Configure the Systick interrupt time 
239
    */
240
  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
241
242
    /**Configure the Systick 
243
    */
244
  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
245
246
  /* SysTick_IRQn interrupt configuration */
247
  HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0);
248
}
249
250
/* USART3 init function */
251
static void MX_USART3_UART_Init(void)
252
{
253
254
  huart3.Instance = USART3;
255
  huart3.Init.BaudRate = 115200;
256
  huart3.Init.WordLength = UART_WORDLENGTH_9B;
257
  huart3.Init.StopBits = UART_STOPBITS_1;
258
  huart3.Init.Parity = UART_PARITY_NONE;
259
  huart3.Init.Mode = UART_MODE_TX_RX;
260
  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
261
  huart3.Init.OverSampling = UART_OVERSAMPLING_16;
262
  if (HAL_UART_Init(&huart3) != HAL_OK)
263
  {
264
    _Error_Handler(__FILE__, __LINE__);
265
  }
266
267
}
268
269
/** Configure pins as 
270
        * Analog 
271
        * Input 
272
        * Output
273
        * EVENT_OUT
274
        * EXTI
275
     PA8   ------> USB_OTG_FS_SOF
276
     PA9   ------> USB_OTG_FS_VBUS
277
     PA10   ------> USB_OTG_FS_ID
278
     PA11   ------> USB_OTG_FS_DM
279
     PA12   ------> USB_OTG_FS_DP
280
*/
281
static void MX_GPIO_Init(void)
282
{
283
284
  GPIO_InitTypeDef GPIO_InitStruct;
285
286
  /* GPIO Ports Clock Enable */
287
  __HAL_RCC_GPIOC_CLK_ENABLE();
288
  __HAL_RCC_GPIOH_CLK_ENABLE();
289
  __HAL_RCC_GPIOA_CLK_ENABLE();
290
  __HAL_RCC_GPIOB_CLK_ENABLE();
291
  __HAL_RCC_GPIOD_CLK_ENABLE();
292
  __HAL_RCC_GPIOG_CLK_ENABLE();
293
294
  /*Configure GPIO pin Output Level */
295
  HAL_GPIO_WritePin(GPIOB, LD3_Pin|LD3B14_Pin|LD2_Pin, GPIO_PIN_RESET);
296
297
  /*Configure GPIO pin Output Level */
298
  HAL_GPIO_WritePin(USB_PowerSwitchOn_GPIO_Port, USB_PowerSwitchOn_Pin, GPIO_PIN_RESET);
299
300
  /*Configure GPIO pin : USER_Btn_Pin */
301
  GPIO_InitStruct.Pin = USER_Btn_Pin;
302
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
303
  GPIO_InitStruct.Pull = GPIO_NOPULL;
304
  HAL_GPIO_Init(USER_Btn_GPIO_Port, &GPIO_InitStruct);
305
306
  /*Configure GPIO pins : LD3_Pin LD3B14_Pin LD2_Pin */
307
  GPIO_InitStruct.Pin = LD3_Pin|LD3B14_Pin|LD2_Pin;
308
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
309
  GPIO_InitStruct.Pull = GPIO_NOPULL;
310
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
311
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
312
313
  /*Configure GPIO pin : USB_PowerSwitchOn_Pin */
314
  GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;
315
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
316
  GPIO_InitStruct.Pull = GPIO_NOPULL;
317
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
318
  HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
319
320
  /*Configure GPIO pin : USB_OverCurrent_Pin */
321
  GPIO_InitStruct.Pin = USB_OverCurrent_Pin;
322
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
323
  GPIO_InitStruct.Pull = GPIO_NOPULL;
324
  HAL_GPIO_Init(USB_OverCurrent_GPIO_Port, &GPIO_InitStruct);
325
326
  /*Configure GPIO pins : USB_SOF_Pin USB_ID_Pin USB_DM_Pin USB_DP_Pin */
327
  GPIO_InitStruct.Pin = USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin;
328
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
329
  GPIO_InitStruct.Pull = GPIO_NOPULL;
330
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
331
  GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
332
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
333
334
  /*Configure GPIO pin : USB_VBUS_Pin */
335
  GPIO_InitStruct.Pin = USB_VBUS_Pin;
336
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
337
  GPIO_InitStruct.Pull = GPIO_NOPULL;
338
  HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);
339
340
}
341
342
/* USER CODE BEGIN 4 */
343
344
345
346
/**
347
  * @brief  Retargets the C library printf function to the USART.
348
  * @param  None
349
  * @retval None
350
  */
351
PUTCHAR_PROTOTYPE
352
{
353
  /* Place your implementation of fputc here */
354
  /* e.g. write a character to the USART3 and Loop until the end of transmission */
355
  HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);
356
357
  return ch;
358
}
359
360
361
362
/* USER CODE END 4 */
363
364
/* StartDefaultTask function */
365
void StartDefaultTask(void const * argument)
366
{
367
  /* init code for LWIP */
368
  MX_LWIP_Init();
369
370
  /* USER CODE BEGIN 5 */
371
  /* Infinite loop */
372
  for(;;)
373
  {
374
    osDelay(1);
375
  }
376
  /* USER CODE END 5 */ 
377
}
378
379
/**
380
  * @brief  This function is executed in case of error occurrence.
381
  * @param  None
382
  * @retval None
383
  */
384
void _Error_Handler(char * file, int line)
385
{
386
  /* USER CODE BEGIN Error_Handler_Debug */
387
  /* User can add his own implementation to report the HAL error return state */
388
  while(1) 
389
  {
390
  }
391
  /* USER CODE END Error_Handler_Debug */ 
392
}
393
394
#ifdef USE_FULL_ASSERT
395
396
/**
397
   * @brief Reports the name of the source file and the source line number
398
   * where the assert_param error has occurred.
399
   * @param file: pointer to the source file name
400
   * @param line: assert_param error line source number
401
   * @retval None
402
   */
403
void assert_failed(uint8_t* file, uint32_t line)
404
{
405
  /* USER CODE BEGIN 6 */
406
  /* User can add his own implementation to report the file name and line number,
407
    ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
408
  /* USER CODE END 6 */
409
410
}
411
412
#endif
413
414
/**
415
  * @}
416
  */ 
417
418
/**
419
  * @}
420
*/ 
421
422
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

von Stefan F. (Gast)


Lesenswert?

Wahrscheinlich hast du zwar die richtigen #includes in deinem Quelltext 
aber der Linker benötigt noch die Information, welche Libraries er dazu 
linken soll (wo die Implementierung der Funktion drin ist).

von Mampf F. (mampf) Benutzerseite


Lesenswert?

Linker-Fehler sagt, der Source für RCC wird nicht mitkompiliert.

Oft sind die Source-Files exkludiert, da nicht benötigt.

Du musst suchen, wo man die wieder aktivieren kann, dann klappt es auch 
mit dem Linken.

von Mampf F. (mampf) Benutzerseite


Angehängte Dateien:

Lesenswert?

Das sieht - bei mir in Eclipse - so aus, wie im angehängten Bild 
(hellgrau ist deaktiviert und wird nicht mitkompiliert).


Deinen Editor kenne ich nicht (dachte aber, er ist Eclipse-basierend?) 
und ich verwende nicht HAL, aber es müsste in etwa ähnlich sein.

von STM Apprentice (Gast)


Lesenswert?

Markus R. schrieb:
> #include "stm32f4xx_hal.h"

Wenn der Compiler dabei nicht meckert dann suche in dieser Datei
den Aufruf für <RCC_GetFlagStatus>. Dieser lautet in den HAL-
Sourcen vermutlich etwas anders. Vermutlich HAL_RCC_GetFlagStatus
oder so. Einfach mal nach Teilstrings suchen, und wenn erfolglos
dann in allen Header-Dateien.

Bei der SPL lautet die erforderliche Header-Datei <stm32f4xx_rcc.h>

Vielleicht muss im HAL-Fall eine solche Datei mit HAL dran
inkludiert werden.

von Markus R. (freehawk)


Lesenswert?

Ich kann in meinem ganzen Workspace keinen Eintrag finden der 
RCC_GetFlagStatus heißt bzw. so ähnlich heißt.

Ich vermute ich habe das was aus einer anderen HAL gefunden und nicht 
aus der die CubeMX und SW4Stm32 nutzt schade.

Hat jemand für mich einen Tipp wie ich an die Reset Source ankomme?

von W.S. (Gast)


Lesenswert?

Markus R. schrieb:
> Meine Vermutung ist dass ich ein include nicht richtig gesetzt habe.
> Entschuldigt bitte ich bin totaler Anfänger in dem Thema.

So, du bist also ein totaler Anfänger, aber du wagst dich ohne zuvoriges 
Üben an ein Thema, das dich offensichtlich überfordert.

Nein, ich teile deine Vermutung nicht. Vielmehr vermute ich, daß es dir 
besser täte, in das Referenzmanual zu schauen und dort nachzulesen, wie 
das Hardware-register tatsächlich heißt, welches die von dir begehrte 
Information enthält. Und wenn dieses Register in deiner STMdingsda.h 
nicht enthalten ist, dann mußt du dir wohl oder übel die entsprechende 
Zeile mit dem #define ... selber formulieren. Die Adresse des Registers 
hast du ja bereits im RefMan gelesen.

Ebenso schau nach, ob dieses Register sich beliebig oft auslesen läßt 
oder nur einmalig (ich wälze jetzt das Manual nicht für dich!).

W.S.

von STM Apprentice (Gast)


Lesenswert?

Markus R. schrieb:
> Hat jemand für mich einen Tipp wie ich an die Reset Source ankomme?

Suche dir in der SPL (vermutlich must du sie dir bei ST erst
herunterladen) die entsprechende Source und Header-Datei.
Und binde sie in dein Projekt ein.

Also

stm32f4xx_rcc.h   und  stm32f4xx_rcc.c

von head off (Gast)


Lesenswert?

beim F1 sieht es so aus:
http://stm32.kosyak.info/doc/stm32f10x__rcc_8h.html
http://stm32.kosyak.info/doc/stm32f10x__rcc_8c_source.html

Ach ja, deine Fehlermeldung kommt vom Compiler, nicht vom Linker. Es 
fehlt (mind.) der include vom header.

von Mampf F. (mampf) Benutzerseite


Lesenswert?

Ich bin schon erschüttert, was hier alles für nonsense-Tipps gegeben 
werden ...

Der richtige Weg ist:

- schau in die stm32f4xx_hal_rcc.c und stm32f4xx_hal_rcc_ex.c und such 
dir die Funktionen, die du brauchst. Im Code und in den Header-Files 
steht im Prinzip, was welche Funktion macht.
- aktivier den entsprechenden Source-Code, sodass er mitkompiliert wird 
- dann meckert auch nicht der Linker.

von head off (Gast)


Lesenswert?

Geht mir auch so. Man sollte nicht mit vollem Mund sprechen. :-P

Da der Fehler auf .C mit Zeilennummer zeigt, kommt er vom Compiler. Der 
Linker würde auf die.o verweisen. ;-)

von Markus R. (freehawk)


Lesenswert?

Danke für die vielen Antworten.

Ich hab nochmals die stm32f4xx_hal_rcc.c und die stm32f4xx_hal_rcc_ex.c 
gecheckt. Ich konnte keine Funktion finden die das gewünschte übernimmt. 
Vielleicht bin ich auch blind. Aber ich lasse es jetzt im Moment so, 
vielleicht finde ich ja noch eine andere Lösung die reset source über 
die CubeHAL auszulesen.

Der Weg über das Einbinden der alten LIB .c und .h funktioniert 
übrigens.

Gruß
Markus

von Stefan F. (Gast)


Lesenswert?

> vielleicht finde ich ja noch eine andere Lösung die reset
> source über die CubeHAL auszulesen.

Ich hätte schon längst das Reference Manual nach "reset source" 
durchsucht und das entsprechende Register einfach ausgelesen.

Ich zitiere:

The reset source can be identified by checking the reset flags in the 
RCC clock control & status register (RCC_CSR).

Bit 31 LPWRRSTF: Low-power reset flag
This bit is set by hardware when a Low-power management reset occurs.
Cleared by writing to the RMVF bit.
0: No Low-power management reset occurred
1: Low-power management reset occurred
For further information on Low-power management reset, refer to 
Low-power management
reset.

Bit 30 WWDGRSTF: Window watchdog reset flag
This bit is set by hardware when a window watchdog reset occurs.
Cleared by writing to the RMVF bit.
0: No window watchdog reset occurred
1: Window watchdog reset occurred

Bit 29 IWDGRSTF: Independent watchdog reset flag
This bit is set by hardware when an independent watchdog reset from VDD 
domain occurs.
Cleared by writing to the RMVF bit.
0: No watchdog reset occurred
1: Watchdog reset occurred

Bit 28 SFTRSTF: Software reset flag
This bit is set by hardware when a software reset occurs.
Cleared by writing to the RMVF bit.
0: No software reset occurred
1: Software reset occurred

Bit 27 PORRSTF: POR/PDR reset flag
This bit is set by hardware when a POR/PDR reset occurs.
Cleared by writing to the RMVF bit.
0: No POR/PDR reset occurred
1: POR/PDR reset occurred

Bit 26 PINRSTF: PIN reset flag
This bit is set by hardware when a reset from the NRST pin occurs.
Cleared by writing to the RMVF bit.
0: No reset from NRST pin occurred
1: Reset from NRST pin occurred

Bit 25 BORRSTF: BOR reset flag
Cleared by software by writing the RMVF bit.
This bit is set by hardware when a POR/PDR or BOR reset occurs.
0: No POR/PDR or BOR reset occurred
1: POR/PDR or BOR reset occurred

1
if (RCC->CSR & RCC_CSR_PINRSTF)
2
{
3
   puts("Reset wurde am NRST Pin ausgelöst");
4
}

Ist jetzt nicht so schwer, oder?

von Dumpf Backe (Gast)


Lesenswert?

Mampf F. schrieb:
> Ich bin schon erschüttert, was hier alles für nonsense-Tipps gegeben
> werden ...
>
> Der richtige Weg ist:
>
> - schau in die stm32f4xx_hal_rcc.c und stm32f4xx_hal_rcc_ex.c und such
> dir die Funktionen, die du brauchst. Im Code und in den Header-Files
> steht im Prinzip, was welche Funktion macht.


Markus R. schrieb:
> Der Weg über das Einbinden der alten LIB .c und .h funktioniert
> übrigens.

von Stefan F. (Gast)


Lesenswert?

Das habe ich schon mitbekommen. Ich wollte nur mal meinen Senf gegen die 
HAL loswerden.

von Nop (Gast)


Lesenswert?

Stefan U. schrieb:

> Ist jetzt nicht so schwer, oder?

Das Reference Manual beißt aber. Scheinen viele jedenfalls zu glauben. 
^^

von Sebastian S. (amateur)


Lesenswert?

Auch ohne den STM32 persönlich zu kennen würde ich sagen:
>D:\work\stm32\03_SolarController\Debug/../Src/main.c:128: undefined
>reference to `RCC_GetFlagStatus'
klingt nicht nach einer Fehlermeldung des Compilers, sondern nach einer 
des Linkers.

Wenn Du Dir mal die genaue Fehlerliste der Ausgabe ansehen würdest, 
könntest du das selber feststellen.
Der Compiler selber ist glücklich, wenn er zu jeder Angabe weiß, was sie 
zu bedeuten hat. Dies geht aus den eingebundenen Headerdateien hervor. 
Dies wiederum bedeutet aber nicht automatisch auch, dass auch die 
Bibliothek erreichbar ist. Das merkt erst der Linker, der die Funktionen 
zusammenklaubt.

Wenn das stimmt, sollte der Fehler darin liegen, dass Du dem Linker 
nicht "gesagt" hast, welche Bibliotheken er verwenden soll.

von Nop (Gast)


Lesenswert?

W.S. schrieb:

> Ebenso schau nach, ob dieses Register sich beliebig oft auslesen läßt
> oder nur einmalig (ich wälze jetzt das Manual nicht für dich!).

Läßt es sich, zum Reset muß man das Bit RMVF schreiben. Trotzdem ist es 
grundsätzlich besserer Stil, ein volatile-Register in eine lokale 
Variable auszulesen und auf der letzteren zu arbeiten, weil der Compiler 
das dann optimieren kann.

von Dumpf Backe (Gast)


Lesenswert?

Sebastian S. schrieb:
> Auch ohne den STM32 persönlich zu kennen würde ich sagen:

Würde ich sagen: lerne ihn erst mal kennen und rede dann mit.

Es gab hier genügend Leute die wesentlich näher an dem
Problem und seiner Lösung dran waren also du.

Also im Zweifelsfall:
Wenn man keine Ahnung hat, lieber mal die F..... halten.

von pegel (Gast)


Lesenswert?

1
  if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST))
2
  {
3
    printf ( "Reset Source: Software Reset\r\n" );
4
  } ....

von Markus Rost (Gast)


Lesenswert?

Dumpf Backe sehr hilfreicher Kommentar vielen Dank!

von pegel (Gast)


Lesenswert?

RCC_ClearFlag();  ->  __HAL_RCC_CLEAR_RESET_FLAGS();

von Markus R. (freehawk)


Lesenswert?

Danke pegel!

Jetzt weiß ich auch warum ich das nicht gefunden habe, die Funktion 
versteckt sich in der .h.

Na da lerne ich was dazu...

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.