Bonjour,

Je suis actuellement en train de tester des routines d'interruptions sur ma Nucleo STM32L152RE, j'ai le code suivant qui fonctionne bien (les deux leds clignotent bien):

Code C : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <stm32l1xx_gpio.h>
#include <stm32l1xx_tim.h>
#include <stm32l1xx_rcc.h>
#include <misc.h>
 
void InitializeLEDs()
{
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
 
    GPIO_InitTypeDef gpioStructure;
    gpioStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14;
    gpioStructure.GPIO_Mode = GPIO_Mode_OUT;
    gpioStructure.GPIO_Speed = GPIO_Speed_40MHz;
    GPIO_Init(GPIOA, &gpioStructure);
 
    GPIO_WriteBit(GPIOA, GPIO_Pin_13 | GPIO_Pin_14	, Bit_RESET);
}
 
void InitializeTimer2()
{
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
 
    TIM_TimeBaseInitTypeDef timerInitStructure;
    timerInitStructure.TIM_Prescaler = 40000;
    timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
    timerInitStructure.TIM_Period = 500;
    timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    TIM_TimeBaseInit(TIM2, &timerInitStructure);
    TIM_Cmd(TIM2, ENABLE);
    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
}
 
void InitializeTimer4()
{
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
 
    TIM_TimeBaseInitTypeDef timerInitStructure;
    timerInitStructure.TIM_Prescaler = 50000;
    timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
    timerInitStructure.TIM_Period = 500;
    timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    TIM_TimeBaseInit(TIM4, &timerInitStructure);
    TIM_Cmd(TIM4, ENABLE);
    TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE);
}
 
void EnableTimerInterrupt2()
{
	NVIC_InitTypeDef nvicStructure;
	nvicStructure.NVIC_IRQChannel = TIM2_IRQn;
	nvicStructure.NVIC_IRQChannelPreemptionPriority = 0;
	nvicStructure.NVIC_IRQChannelSubPriority = 1;
	nvicStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&nvicStructure);
}
 
void EnableTimerInterrupt4()
{
	NVIC_InitTypeDef nvicStructure;
	nvicStructure.NVIC_IRQChannel = TIM4_IRQn;
	nvicStructure.NVIC_IRQChannelPreemptionPriority = 0;
	nvicStructure.NVIC_IRQChannelSubPriority = 1;
	nvicStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&nvicStructure);
}
 
 
int main()
{
    InitializeLEDs();
    InitializeTimer2();
    EnableTimerInterrupt2();
    InitializeTimer4();
    EnableTimerInterrupt4();
 
    while(1)
    {
 
    }
   /*for (int i=0; i<1000000; i++)
	   asm("nop");
   GPIO_ToggleBits(GPIOA, GPIO_Pin_14);*/
}
 
void TIM2_IRQHandler()
{
	if(TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
	{
		TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
		GPIO_ToggleBits(GPIOA, GPIO_Pin_13);
	}
}
 
void TIM4_IRQHandler()
{
	if(TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET)
	{
		TIM_ClearITPendingBit(TIM4, TIM_IT_Update);
		GPIO_ToggleBits(GPIOA, GPIO_Pin_14);
	}
}

Cependant j'obtiens quand meme des erreurs dans le mode debug:
Code Debugger : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Open On-Chip Debugger 0.10.0-dev-00007-g58350bc-dirty (2018-01-08-12:20)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter_nsrst_delay: 100
adapter speed: 240 kHz
Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 240 kHz
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : STLINK v2.1 JTAG v28 API v2 M17 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.250952
Info : Stlink adapter speed set to 240 kHz
Info : STM32L152RETx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
Info : Stlink adapter speed set to 240 kHz
adapter speed: 240 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000934 msp: 0x20014000
STM32L: Enabling HSI
Info : Stlink adapter speed set to 4000 kHz
adapter speed: 4000 kHz
Info : Device: STM32L1xx (Cat.5/Cat.6)
Info : STM32L flash has dual banks. Bank (0) size is 256kb, base address is 0x8000000
Info : Device: STM32L1xx (Cat.5/Cat.6)
Info : STM32L flash has dual banks. Bank (1) size is 256kb, base address is 0x8040000
Info : Stlink adapter speed set to 240 kHz
adapter speed: 240 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000934 msp: 0x20014000
Info : Stlink adapter speed set to 240 kHz
adapter speed: 240 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000934 msp: 0x20014000
STM32L: Enabling HSI
Info : Stlink adapter speed set to 4000 kHz
adapter speed: 4000 kHz
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000000e msp: 0x20014000
Info : Stlink adapter speed set to 240 kHz
adapter speed: 240 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000934 msp: 0x20014000
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: JTAG failure -4
Error: jtag status contains invalid mode value - communication failure
Polling target STM32L152RETx.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target STM32L152RETx.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 300ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target STM32L152RETx.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 700ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target STM32L152RETx.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 1500ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target STM32L152RETx.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 3100ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target STM32L152RETx.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 6300ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target STM32L152RETx.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 6300ms

J'ai lu ceci dans un tutoriel (https://visualgdb.com/tutorials/arm/stm32/timers/):
Furthermore, unless you explicitly provide a method for a given interrupt handler, such as TIM2_IRQHandler(), GCC will automatically substitute it with DefaultHandler() that will halt your program.
Est ce que ca aurait un rapport?

Merci.