MQX Task Stop Running the 2nd Time ISR is Invoked

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MQX Task Stop Running the 2nd Time ISR is Invoked

ソリューションへジャンプ
1,208件の閲覧回数
chiasyan
Contributor II

Hi,


Situation:

I am receiving a character through UART when the MQX is running, the UART ISR is invoked and the task is running just fine.

However, my debug session is halted at some time (1~1.5 sec) after the character has been sent (please refer to the image below).

The task is still running (my LED is still toggling).


Next, when I try to receive another character, the UART ISR is still invoked. But this time, the task is no longer running.

Any subsequent character received is invoking still the interrupt routine handler.


Observation:

1. MQX task is stop running when the 2nd time ISR is visited.

2. Might be related to TASK and ISR priority?


Please help, thank you.


Debug Session

Untitled.png


MQX Task Template

TASK_TEMPLATE_STRUCT MQX_template_list[] =

{

  { TASK1, Task1, 1024, 8, "task1", MQX_AUTO_START_TASK },

  { TASK2, Task2, 1024, 8, "task2", MQX_AUTO_START_TASK },

  { 0, 0, 0, 0, 0, 0 } // end of template

};

Task2: Just a simple task to toggle a LED

void Task2(uint_32 initial_data)

{

  while(1)

  {

    /* MY OWN IMPLEMENTATION: TOGGLE LED1 HERE */

    _time_delay_ticks(100);

  }

}

Task1: Initialize GPIO , UART and ISR

/* GPIO Initialization for LED is not shown here */

void Task2(uint_32 initial_data)

{

  MY_ISR_STRUCT_PTR  isr_ptr;

 

  // UART1 PIN ALTERNATIVE

  PORTC_PCR3 |= PORT_PCR_MUX(0x03);

  // UART1 SYSTEM CLOCK GATING

  SIM_SCGC4 |= SIM_SCGC4_UART1_MASK;

  // DISABLE UART1 TX AND RX

  UART1_C2 &= (uint8_t)~(uint8_t)((UART_C2_TE_MASK | UART_C2_RE_MASK));

  // CONFIGURE UART1 CONTROL 1

  UART1_C1 = 0x00U;

  // CONFIGURE UART1 BAUD

  UART1_BDH = UART_BDH_SBR(0x02);

  UART1_BDL = UART_BDL_SBR(0x8B);

  UART1_C4 = UART_C4_BRFA(0x01);                           

  // INSTALL UART1 ISR

  isr_ptr = _mem_alloc_zero((_mem_size)sizeof(MY_ISR_STRUCT));

  isr_ptr->TICK_COUNT = 0;

  isr_ptr->OLD_ISR_DATA = _int_get_isr_data(INT_UART1_RX_TX);

  isr_ptr->OLD_ISR = _int_get_isr(INT_UART1_RX_TX);

  _int_install_isr(INT_UART1_RX_TX, new_tick_isr, isr_ptr);

  _bsp_int_init(INT_UART1_RX_TX,2,2,TRUE);

  // CLEAR UART1 FLAGS

  (void) UART1_S1; /* Dummy read of the UART1_S1 register to clear flags */

  (void) UART1_D;  /* Dummy read of the UART1_D register to clear flags */

  // ENABLE UART1 TX AND RX

  UART1_C2 = (UART_C2_RIE_MASK | UART_C2_RE_MASK);                           

  _bsp_int_enable(INT_UART1_RX_TX);

  _time_delay_ticks(200);

  while(1)

  {

    _time_delay_ticks(100);

  }

}

ISR Structure

typedef struct my_isr_struct

{

   pointer    OLD_ISR_DATA;

   void       (_CODE_PTR_ OLD_ISR)(pointer);

   _mqx_uint  TICK_COUNT;

} MY_ISR_STRUCT, _PTR_ MY_ISR_STRUCT_PTR;

UART1 ISR

void new_tick_isr(pointer user_isr_ptr)

{

  MY_ISR_STRUCT_PTR  isr_ptr;

 

  isr_ptr = (MY_ISR_STRUCT_PTR)user_isr_ptr;

  isr_ptr->TICK_COUNT++;

  (*isr_ptr->OLD_ISR)(isr_ptr->OLD_ISR_DATA);

  if (UART1_S1 & UART_S1_RDRF_MASK)

  {

    /* MY OWN IMPLEMENTATION: TOGGLE LED2 HERE */

    (void) UART1_D;  /* Dummy read of the UART1_D register to clear flags */

  }

}

タグ(5)
0 件の賞賛
返信
1 解決策
762件の閲覧回数
c0170
Senior Contributor III

Hello chiasyan,

my question would be why do you invoke the OLD_ISR code from your ISR? Where did you see this? I believe you copied it from somewhere if you have no clue what it does.

That line you removed, invoked again ISR routine, according to the pasted code. You can verify it with the value of that function pointer, it should point to the UART1 ISR.

Regards,

0xc0170

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
762件の閲覧回数
chiasyan
Contributor II

Hi,

I found out that if I try to remove the line, everything seems to work fine.

(*isr_ptr->OLD_ISR)(isr_ptr->OLD_ISR_DATA); /* Chain to the previous notifier */


What is the function of this line of code?

Thank you.

0 件の賞賛
返信
763件の閲覧回数
c0170
Senior Contributor III

Hello chiasyan,

my question would be why do you invoke the OLD_ISR code from your ISR? Where did you see this? I believe you copied it from somewhere if you have no clue what it does.

That line you removed, invoked again ISR routine, according to the pasted code. You can verify it with the value of that function pointer, it should point to the UART1 ISR.

Regards,

0xc0170

0 件の賞賛
返信