how debug unhandled exception
Moderator: RoccoMarco
how debug unhandled exception
hi,
my code is getting unhandled exception, but i can't understand why.
what is the approact to find out what is causing this?
it seems to happen inside a i2cMasterTransmitTimeout
my code is getting unhandled exception, but i can't understand why.
what is the approact to find out what is causing this?
it seems to happen inside a i2cMasterTransmitTimeout
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: how debug unhandled exception
well, i down't know how provide context 
there are 2 thread, the "main thread", witch every 3 ms check if there is new data and print it by USB (worked fine)
the "read thread" witch wait for an event (send by 2 interrupt) and make a SPI a I2C read.
Basically the board's sensor of the STM32f3discovery end the data redy interrupt, the interrupt send an event to the "read thread", witch start the reading. code https://github.com/MauroMombelli/testCh ... d_thread.h
the reading (i haven't upload the code yesterday) is a basic
and should be correct as initial configuration of the sensor are fine.
the point is i don't think to had change the code of the sensor, so i may had done something wrong with somehow trigger the reading error.
reading sensor:
https://github.com/MauroMombelli/testCh ... l3g4200d.c
and
https://github.com/MauroMombelli/testCh ... sm303dlh.c
there are 2 thread, the "main thread", witch every 3 ms check if there is new data and print it by USB (worked fine)
the "read thread" witch wait for an event (send by 2 interrupt) and make a SPI a I2C read.
Basically the board's sensor of the STM32f3discovery end the data redy interrupt, the interrupt send an event to the "read thread", witch start the reading. code https://github.com/MauroMombelli/testCh ... d_thread.h
the reading (i haven't upload the code yesterday) is a basic
Code: Select all
spiAcquireBus(&SPID1);
spiStart(&SPID1, &spi1cfg);
spiSelect(&SPID1);
spiExchange(&SPID1, 8, txbuf, rxbuf);
spiUnselect(&SPID1);
spiStop(&SPID1);
spiReleaseBus(&SPID1);and should be correct as initial configuration of the sensor are fine.
the point is i don't think to had change the code of the sensor, so i may had done something wrong with somehow trigger the reading error.
reading sensor:
https://github.com/MauroMombelli/testCh ... l3g4200d.c
and
https://github.com/MauroMombelli/testCh ... sm303dlh.c
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: how debug unhandled exception
lesto wrote:well, i down't know how provide context
This is a problem. If you are going to ask for help it is your best interest:
1) Provide enough data or help cannot be given.
2) Don't give not relevant data or the message is lost in the noise.
In general:
3) Make the simplest program that shows the problem and post just that.
About the code, why post SPI code if the problem seems to be I2C?
I recommend single step into the functions and see where it fails, this should give an hind about the problem. Usually a good approach is to remove everything and start reintegrating parts and see where it fails (divide et impera).
Giovanni
Re: how debug unhandled exception
problem appear with i2c and spi.
i'll try to strip down thing, but i would like to understand if there is a "error message", maybe even a stack trace to find out what i'm dong wrong, or at least point me in the right direction.
ps. the forum seems really unstable, it gives error 500
i'll try to strip down thing, but i would like to understand if there is a "error message", maybe even a stack trace to find out what i'm dong wrong, or at least point me in the right direction.
ps. the forum seems really unstable, it gives error 500
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: how debug unhandled exception
yes, but they are sequental, in the same thread, just because this..
BTW edbugghing here and there i found out what was causing the issue:
commenting out CH_IRQ_PROLOGUE and CH_IRQ_EPILOGUE seems to fix the behavior. Is this correct?
Is EXTDriver taking care of it?
Btw the problem is never, or very rare with SPI, using I2C after some hundred read it break.
weird thing is that sometimes i got a unhandled_exception and sometimes port_halt, seems to depend on with part of code i enable (reading to accelerometer i2c or magnetometer i2c)
BTW edbugghing here and there i found out what was causing the issue:
Code: Select all
void unkonw_interrupt(EXTDriver *extp, expchannel_t channel) {
/* Wakes up the thread.*/
(void) extp;
(void) channel;
//CH_IRQ_PROLOGUE();
interruptCounter[channel]++;
//CH_IRQ_EPILOGUE();
}commenting out CH_IRQ_PROLOGUE and CH_IRQ_EPILOGUE seems to fix the behavior. Is this correct?
Is EXTDriver taking care of it?
Btw the problem is never, or very rare with SPI, using I2C after some hundred read it break.
weird thing is that sometimes i got a unhandled_exception and sometimes port_halt, seems to depend on with part of code i enable (reading to accelerometer i2c or magnetometer i2c)
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: how debug unhandled exception
Callbacks are not ISRs, you are not supposed to use those macros there.
Giovanni
Giovanni