cancel
Showing results for 
Search instead for 
Did you mean: 

[solved] Interrupt priorities

Patriks
Senior
Posted on November 25, 2014 at 13:18

Hello,

Yesterday, I investigated a problem with my software project for an SPC560B. There are several calculations running on the controller and it additionally communicates over UART with a PC. When I tried to increase the UART baud rate, I got the effect that the controllers ''miss'' some bytes sent by the PC.

I found out, that reason for that effekt has something to do with the UART RX interrupt and an interrupt created by the periodical timer PIT. After the PIT causes an interrupt, the UART RX can not trigger an interrupt. I always thought that a higher priority interrupt can break the program even when another lower prior interrupt is currently running?

Best regards,

Patrik
This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 ACCEPTED SOLUTION

Accepted Solutions
Erwan YVIN
ST Employee
Posted on April 23, 2015 at 18:28

Hello Patrik ,

The problem has been reproduced .

in forcing in ivor.s, it is working.

/* Allows preemption while executing the software handler.*/
wrteei 1
/* Executes the software handler.*/
bctrl
/* Prevents preemption again.*/
wrteei 0

Could you try this piece of code ''ivor.s'' ?

The compilation switch was not taken in account.

i am checking the platform configuration in SPC5studio

Best Regards

Erwan

________________

Attachments :

photo.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0VV&d=%2Fa%2F0X0000000bZm%2FItO27sKjPGzL3Ya3K0cSNAw_8by8ZlvVr186uAmJKRE&asPdf=false

View solution in original post

16 REPLIES 16
Erwan YVIN
ST Employee
Posted on November 27, 2014 at 09:30

Hello Patrik ,

We are investigating the issue

            Best Regards

                      Erwan

Patriks
Senior
Posted on December 12, 2014 at 07:31

Dear Erwan,

Can you already give me a hint how I can avoid the described behaviour? I thought about locking other interrupts during the UART receive process. Is there a way to lock parts of the source code (e.g. an interrupt handler) that it can not be interrupted from another interrupt source?

Best regards,

Patrik

Erwan YVIN
ST Employee
Posted on January 21, 2015 at 17:53

Hello Patrik ,

Sorry for the late answer.

osalSysLockFromISR is used to enter to a critical zone.

OSAL_USE_IRQ_PREEMPTION is not defined (cf osal.h)

you can try to define OSAL_USE_IRQ_PREEMPTION in your project (Platform component)

but we have not tested this case.

Which speed do you try to validate ?

   best regards

                Erwan

Patriks
Senior
Posted on January 23, 2015 at 12:50

Hello Erwan,

I have added a picture which shows the loss of UART data (hope it worked). The PIT interrupt raises every 100ms and can´t be interrupted from the UART RX interrupt. UART baud rate was configured as 460800.

Best regards,

Patrik

________________

Attachments :

pic.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyLa&d=%2Fa%2F0X0000000bZq%2FEx56LI44R7FHrFI4CPZ_DHJPwcDyMZa4VSdrVMigVak&asPdf=false
Erwan YVIN
ST Employee
Posted on January 30, 2015 at 11:01

Hello Patrik ,

in the default OSAL Configuration,

PIT_0 happenned every 1 ms. (set to 1000) in OSAL

did you try ''Preemptable ISRs'' ?

  Best Regards

             Erwan

Patriks
Senior
Posted on February 02, 2015 at 07:52

Hello Erwan,

do you mean to set

OSAL_ENABLE_IRQ_PREEMPTION

in osal.h to TRUE? I never tried to change any of theses default settings.

/*===========================================================================*/ 
/* Module pre-compile time settings. */ 
/*===========================================================================*/ 
/** 
* @brief Enables the interrupts during the ISRs execution. 
*/ 
#if !defined(OSAL_ENABLE_IRQ_PREEMPTION) || defined(__DOXYGEN__) 
#define OSAL_ENABLE_IRQ_PREEMPTION FALSE 
#endif 

For what is PIT_0 used in default configuration? Best regards, Patrik
Erwan YVIN
ST Employee
Posted on February 02, 2015 at 17:58

Hello Patrick ,

OSAL_ENABLE_IRQ_PREEMPTION

is configurable on OSAL Component. (Configuration level) FALSE by default

#if OSAL_ENABLE_IRQ_PREEMPTION
/* Allows preemption while executing the software handler.*/
wrteei 1
#endif
/* Executes the software handler.*/
bctrl
#if OSAL_ENABLE_IRQ_PREEMPTION
/* Prevents preemption again.*/
wrteei 0
#endif

PIT_0 is used for 1ms tick (os-less) If you think that the Tick is too heavy, you can try to enable this feature. Best Regards Erwan
Posted on February 03, 2015 at 14:53

Hi Patrik,

At which baud rate you start to experience the issue?

Giovanni

Patriks
Senior
Posted on February 03, 2015 at 15:59

Hello Giovanni,

I tried three baud rates. It worked with 57,6kb/s, but not with 460,8kb/s and 128kb/s.

Best regards,

Patrik