Hey guys,
I'm having a little problem with my custom board, which has a STM32F405 controller. If I enable the EXT subsystem and I pull an input to the ground which I enabled to monitor, the code crashes. I tried reading simply the state of the same input, that works fine, nothing crashing.
Previously I developed this code on a STM32F407Discovery board, on that it was running flawless. I'm not doing anything different. The only difference between the two boards are mainly the F405 and F407, and the quartz frequency, but I successfully changed those settings, and everything else seems to work ok except this EXT system.
What am I missing?
Thanks for any help!
Ervin
PS. I'm running a fairly old ChibiOS version, it's 161.
EXT unhandled exception
-
ervinbalazs
- Posts: 4
- Joined: Mon May 20, 2019 7:25 am
- Has thanked: 1 time
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: EXT unhandled exception
Hi,
Hard to tell, is the pointer NULL in the EXT configuration structure? that could explain the crash.
I strongly suggest you to update ChibiOS, EXT is not even supported any more.
Giovanni
Hard to tell, is the pointer NULL in the EXT configuration structure? that could explain the crash.
I strongly suggest you to update ChibiOS, EXT is not even supported any more.
Giovanni
-
ervinbalazs
- Posts: 4
- Joined: Mon May 20, 2019 7:25 am
- Has thanked: 1 time
Re: EXT unhandled exception
Hi,
This is how my code looks:
This is how my code looks:
Code: Select all
void extDnBtnTest(EXTDriver *extp, expchannel_t channel)
{
chprintf((BaseSequentialStream *)&SD3, "Down Button Pressed");
}
static const EXTConfig extcfg = {
{
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOC, extDnBtnTest},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL}
}
};
void initExt()
{
extStart(&EXTD1, &extcfg);
chprintf((BaseSequentialStream *)&SD3, "EXT INIT\r\n");
}- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: EXT unhandled exception
It tells me nothing, try putting a breakpoint in the EXTI ISR and see where the exception is triggered.
Assuming it goes into the ISR, it could go directly in the undefined handler if the ISR is not linked correctly to the table.
Giovanni
Assuming it goes into the ISR, it could go directly in the undefined handler if the ISR is not linked correctly to the table.
Giovanni
-
ervinbalazs
- Posts: 4
- Joined: Mon May 20, 2019 7:25 am
- Has thanked: 1 time
Re: EXT unhandled exception
Okay, so I have to admit I'm a beginner, and I didn't really found where should I put the breakpoint exactly.
But I tried the new ChibiOS and the palEnablePadEvent function, with the palSetPadCallback, and the behaviour is the same. The code execution just stops, and I get an unhandled exception.
Ervin
But I tried the new ChibiOS and the palEnablePadEvent function, with the palSetPadCallback, and the behaviour is the same. The code execution just stops, and I get an unhandled exception.
Ervin
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: EXT unhandled exception
Does it reach the callback or it crashes before that?
Could you post a minimal application that triggers the problem? I will test it of a 407 however.
Giovanni
Could you post a minimal application that triggers the problem? I will test it of a 407 however.
Giovanni
Re: EXT unhandled exception
the problem is that you cannot use a chprintf in an interruption handler.
you need to read the chibios documentation, it explains that there is function that can be called from thread context, and functions that can bell called from interruption context.
chprintf is a function that can only be called from a thread context.
you can read an exhaustive explanation here : chibios book
Alexandre
you need to read the chibios documentation, it explains that there is function that can be called from thread context, and functions that can bell called from interruption context.
chprintf is a function that can only be called from a thread context.
you can read an exhaustive explanation here : chibios book
Alexandre
-
ervinbalazs
- Posts: 4
- Joined: Mon May 20, 2019 7:25 am
- Has thanked: 1 time
Re: EXT unhandled exception
Wow, thanks Alexandre!
Indeed the chprintf function caused my problem. I tried without it, and now it's working properly. Well it's still odd that it works on the F407Discovery and not on my custom F405 board, but whatever. I can live with it.
Ervin
Indeed the chprintf function caused my problem. I tried without it, and now it's working properly. Well it's still odd that it works on the F407Discovery and not on my custom F405 board, but whatever. I can live with it.
Ervin
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: EXT unhandled exception
Note, it should not work, if you enable the state checker in chconf.h then you would get an error.
I suggest to keep debug options enabled during development.
Giovanni
I suggest to keep debug options enabled during development.
Giovanni