cancel
Showing results for 
Search instead for 
Did you mean: 

strange problem with keil uvision 5 and interrupts

andjelko
Associate II
Posted on December 06, 2014 at 23:52

hello ,

first of all sorry for my bad english.

I have problem with isr on keil uvision 5.

Simple exception handler, for instance handler for systick interrupt defined as:

void SysTick_Handler(){

  ....code...

}

does not working.

When debugint it goes to startup_stm32f4xx.s and there stays in infinte loop.(B.)

why is it not overriden with code in main.c?

best regards,

Andjelko.

#keil-uvision-5-interrupt #keil-uvision-5-interrupt #keil-uvision-5-interrupt #keil-uvision-5-interrupt
6 REPLIES 6
Posted on December 07, 2014 at 00:35

Uncheck ''Run to main'' and identify where it's crashing. From your vague description I'm assuming it is faulting somewhere, perhaps because the PLL settings are wrong for the board/clocks you are using.

The code in, and called by, SystemInit() runs before your main() routine is called.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andjelko
Associate II
Posted on December 07, 2014 at 09:16

thanks for reply.

If i try to light up 4 leds on stm32f4 discovery board without using interrupt it works(by deleting SisTick_Handler function and all other stuff nedded for interrupt and moving portDout=0xF000 inside main function).

This is new project created from scratch.Included are cmsis core and device startup.

I understand concepts behind interrupts and all that, have done many projects on my own with atmel avr and pic.

here is code that is not working.When debuging it start to do all right.After reset core is in thread privileged.When systick counter runs out core goes to thread and stays there forever not setting upper 4 bits of portd high.Debuger is on startup_stm32f4xx.s file within systick handler defined as week that should be ovrriden wiht my function.

#include <stm32f407xx.h>

#define portDout *((uint16_t*)(0x40020c14))

#define portAin  *((uint16_t*)(0x40020010))

#define portDmod *((uint32_t*)(0x40020c00))

#define RCCreg *((uint32_t*)(0x40023830))

int main(){

    SystemInit();

    RCCreg=0xFF;

    portDmod=0x55000000;

    SysTick_Config(SystemCoreClock/1000);

    NVIC_SetPriority(SysTick_IRQn,0);

    NVIC_EnableIRQ(SysTick_IRQn);

    while(1);

    return 0;

}

void SysTick_Handler(){

    portDout=0xF000;

}

I am not using settings for this board because i plans to use cortex m microcontrollers for my own design.

sorry for my bad english,i hope that now it is clear what is my problem.

best regards,

Andjelko.
andjelko
Associate II
Posted on December 07, 2014 at 09:51

exception handlers inside startup_stm32f4xx.s file are infinite loops defined as weak, not week...and many other typing errors...sorry for that.

Posted on December 07, 2014 at 16:21

You can edit your posts when logged in.

You don't need to call SystemInit() in main(), this is normally done in the code path of ResetHandler.

You need to look at the SystemInit() code in system_stm32f4xx.c, what PLL settings are being applied, and if those are appropriate for YOUR hardware. You need to do some debugging, and step through the code until if fails if you cannot identify the issues walking through the source.

Review the template projects, make sure you have the correct defines passed to the compiler, that HSE_VALUE is correct for your platform.

The DISCO boards use 8 MHz crystals, many of the examples are for the EVAL boards use 25 MHz. Check also stm32f4xx_conf.h in your project directory.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andjelko
Associate II
Posted on December 09, 2014 at 22:45

It has to be c file, not c++

That was problem, now if i make new project exactly the same as that not working and code is in c file it works.

thx for helping me.

Best regards,

Andjelko.
Posted on December 09, 2014 at 22:53

With C++ (.cpp) you have to watch for name mangling, otherwise generic interrupt names will not get linked properly to the vector table. You should be able to see this via the .MAP file.

Consider:

extern ''C'' void USART1_IRQHandler(void)

{

}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..