Page 2 of 2

Re: CAN Driver for STM8

Posted: Tue Dec 28, 2010 9:30 pm
by Giovanni
Hi Brian,

I didn't remember about this, I will integrate the driver after the 2.2.0 release, both STM8 ports are quite mature now.

Giovanni

Re: CAN Driver for STM8

Posted: Wed Dec 29, 2010 7:01 am
by Saran_yim
Hi Braian, Giovanni,

Is there any process in chibi os disable system interrupts?

I have success implement CAN from ST-Lib with Chibi OS at the moment
I need 3 UART in my application and one of them is Software UART base on Timer 4 (with ST-Lib TIM4) because I need 10400 baud rate.

So my application run just for 3-5 second then it stop and struct in the following process

#if !defined(PORT_OPTIMIZED_READYI) || defined(__DOXYGEN__)
#if CH_OPTIMIZE_SPEED
/* NOTE: it is inlined in this module only.*/
INLINE Thread *chSchReadyI(Thread *tp) {
#else
Thread *chSchReadyI(Thread *tp) {
#endif
Thread *cp;

/* Integrity check.*/
chDbgAssert((tp->p_state != THD_STATE_READY) &&
(tp->p_state != THD_STATE_FINAL),
"chSchReadyI(), #1",
"invalid state");

tp->p_state = THD_STATE_READY;
cp = (Thread *)&rlist.r_queue;
do {
cp = cp->p_next;
} while (cp->p_prio >= tp->p_prio);
/* Insertion on p_prev.*/
tp->p_next = cp;
tp->p_prev = cp->p_prev;
tp->p_prev->p_next = cp->p_prev = tp;
return tp;
}

and then I put the break point in any ISR but no ISR are activate and my system not response to anything

I have create 3 threads
1st thread is checking data from UART1
2nd thread is for transmit data to UART1 (chBSEMwait)
3rd thread is for communicate to Software UART when communication complete chBSEMSignal to call the 2nd thread to work

As I try to debug, I got 3-4 data from 2nd thread (3-4 times working) and then system stop
every time it stop after execute the 2nd thread. any idea?

but if I put the break point on 2nd thread, it not struct in that loop. but I get problem with timedout from 3rd thread. :?: :?:

thank you.

Saran

Re: CAN Driver for STM8

Posted: Wed Dec 29, 2010 7:06 am
by Saran_yim
more information

software struct in this loop

do {
cp = cp->p_next;
} while (cp->p_prio >= tp->p_prio);

Re: CAN Driver for STM8

Posted: Wed Dec 29, 2010 8:21 am
by Giovanni
Hi,

In ChibiOS/RT you must use chSysLock() and chSysUnlock() in order disable/enable interrupts. If your application stops in that loop (chSchReadyI()) probably it is because a problem in your code, it is possible you call and I-Class API (those with names ending with a I) outside a lock zone.

I-class APIs must be invoked between chSysLock() and chSysUnlock() when invoked by a thread or between chSysLockFromIsr() and chSysUnlockFromIsr() when invoked from an ISR. This rule is explained in the "kernel concepts" section of the various kernel reference manuals, see "System States".

Invoking an I-class function outside a lock zone is a possible cause of the problem you are experiencing.

You may post your code on the forum if in doubt.

Giovanni

Re: CAN Driver for STM8

Posted: Wed Dec 29, 2010 8:22 am
by Giovanni
Saran_yim wrote:more information

software struct in this loop

do {
cp = cp->p_next;
} while (cp->p_prio >= tp->p_prio);


This code inserts a thread in a priority ordered double linked list.

Giovanni