own firmware. interrupt handler

Firmware/software/electronics/mechanics
Post Reply
almaz_1c
Member
Posts: 43
Joined: Tue Dec 09, 2014 12:58 pm

own firmware. interrupt handler

Post by almaz_1c »

Hello. I write my own firmware for quadrocopter. And I have a problem with the implementation of the interrupt handlers. This is my code:

Code: Select all

#include <gpio.h>
#include <clk.h>
#include <led.h>
#include <crazyflie_board.h>


void SysTick_Handler(void)
{
	led_toggle(LED_GREEN);
}

int main (void)
{
	clk_HSE_enable();
// 	sysTick_init(50);

	led_init(LED_GREEN);
	led_on(LED_GREEN);
	led_init(LED_RED);
	led_on(LED_RED);

	uint32_t cnt = 0;
	while(1)
	{
		led_toggle(LED_RED);
		for(cnt=0;cnt<1000000;cnt++);
	}
	return 1;
}
In this form, the code works. The red LED blinks. But if I uncomment line

Code: Select all

// 	sysTick_init(50);
In which I enable systick interrupt, both LEDs stop blinking. It seems like processor go to hardFault.

I specify using thoose memory area in my linker script:

Code: Select all

/* Specify the memory areas */
/*  FLASH (rx)      : ORIGIN = 0x08002800, LENGTH = 118K */
MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08002800, LENGTH = 118K
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 20K
  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
}
Interrupt vector table defined in startup file in standart manner:

Code: Select all

g_pfnVectors:
	.word	_estack
	.word	Reset_Handler
	.word	NMI_Handler
	.word	HardFault_Handler
	.word	MemManage_Handler
	.word	BusFault_Handler
	.word	UsageFault_Handler
	.word	0
	.word	0
	.word	0
	.word	0
	.word	SVC_Handler
	.word	DebugMon_Handler
	.word	0
	.word	PendSV_Handler
	.word	SysTick_Handler
	.word	WWDG_IRQHandler

   .weak	PendSV_Handler
	.thumb_set PendSV_Handler,Default_Handler

	.weak	SysTick_Handler
	.thumb_set SysTick_Handler,Default_Handler

	.weak	WWDG_IRQHandler
	.thumb_set WWDG_IRQHandler,Default_Handler
Used bootloader - is standart, given to crazyflie.
What is proper way of handle interrupts in case of using bootloader?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: own firmware. interrupt handler

Post by arnaud »

Hi,

Are you using the ST startup files? By default they reset the interrupt vector table address: https://github.com/mikeferguson/stm32/b ... 4xx.c#L249
you need to comment these line, the interrupt vector table address is already setup by the bootloader so there is no need to touch it (I have no idea why ST is doing that, even without bootloader there is no need to touch it unless you run from RAM).
Post Reply