ChibiOS public support forum for all topics not covered by a specific support forum.
Moderators: RoccoMarco, lbednarz, tfAteba
-
Tabulous
- Posts: 518
- Joined: Fri May 03, 2013 12:02 pm
- Has thanked: 7 times
- Been thanked: 18 times
Post
by Tabulous »
if i want to post a message from a EXTDriver callback which chMBPost would i use I-interrupt ?
i.e.
Code: Select all
static void extcb1(EXTDriver *extp, expchannel_t channel)
{
struct iom m;
static VirtualTimer vt4;
(void)extp;
(void)channel;
m.id = IOM_OUTPUT1;
m.state = IOM_OUTPUT_ON;
chMBPostI(&mbox, (msg_t)&m);
chSysLockFromIsr();
if (chVTIsArmedI(&vt4))
{
chVTResetI(&vt4);
}
/* LED4 set to OFF after 200mS.*/
chVTSetI(&vt4, MS2ST(200), led1off, NULL);
chSysUnlockFromIsr();
}
If so why would i be getting SV#10 panics ?
-
Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Post
by Giovanni »
Because you call the I-class function before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
-
Tabulous
- Posts: 518
- Joined: Fri May 03, 2013 12:02 pm
- Has thanked: 7 times
- Been thanked: 18 times
Post
by Tabulous »
Giovanni wrote:Because you call the I-class function before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
Ok so if i used chMBPostS(&mbox, (msg_t)&m); i get SV#11
and
if i used chMBPost(&mbox, (msg_t)&m); i get SV#4
so how do i post to a message box from the EXTDriver Callback ?
-
Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Post
by Giovanni »
You need to use chMBPostI(), callbacks are called from ISR context.
Giovanni
-
Tabulous
- Posts: 518
- Joined: Fri May 03, 2013 12:02 pm
- Has thanked: 7 times
- Been thanked: 18 times
Post
by Tabulous »
Giovanni wrote:You need to use chMBPostI(), callbacks are called from ISR context.
Giovanni
it doesnt work, this is what i have
Code: Select all
static void extcb1(EXTDriver *extp, expchannel_t channel)
{
struct iom m;
static VirtualTimer vt4;
(void)extp;
(void)channel;
m.id = IOM_OUTPUT1;
m.state = IOM_OUTPUT_ON;
chMBPostI(&mbox, (msg_t)&m);
chSysLockFromIsr();
if (chVTIsArmedI(&vt4))
{
chVTResetI(&vt4);
}
/* LED4 set to OFF after 200mS.*/
chVTSetI(&vt4, MS2ST(200), led1off, NULL);
chSysUnlockFromIsr();
}
I get debug panic SV#10, dbg_isr_cnt = 1 and dbg_lock_cnt = 0
-
Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Post
by Giovanni »
Because you call the I-class function (chMBPostI()) before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
-
Tabulous
- Posts: 518
- Joined: Fri May 03, 2013 12:02 pm
- Has thanked: 7 times
- Been thanked: 18 times
Post
by Tabulous »
Giovanni wrote:Because you call the I-class function (chMBPostI()) before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
so if i move the call to chMBPostI() outside the chSysLockFromIsr() lock zone, would i call just chMBPost ?
-
Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Post
by Giovanni »
You can only call I-class functions from ISRs and callbacks.
Code: Select all
static void extcb1(EXTDriver *extp, expchannel_t channel)
{
struct iom m;
static VirtualTimer vt4;
(void)extp;
(void)channel;
m.id = IOM_OUTPUT1;
m.state = IOM_OUTPUT_ON;
chSysLockFromIsr();
chMBPostI(&mbox, (msg_t)&m);
if (chVTIsArmedI(&vt4))
{
chVTResetI(&vt4);
}
/* LED4 set to OFF after 200mS.*/
chVTSetI(&vt4, MS2ST(200), led1off, NULL);
chSysUnlockFromIsr();
}
This.
Giovanni