This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTX isr_mbx_receive problem

hi,

i have a problem with the isr_mbx_receive() function, which is not working for me.

i have written a class for the mailbox functions and i can send messages between tasks and from an ISR routine to another task

but i can't send any messages from a task to an ISR routine

my add message method

MBX_MSG_STATUS MbxQueueSC::add(U8 in, U16 timeout){
        if ((inptr = (T_MBX_SC*)_alloc_box(mailpool))==NULL){
                        return MBX_ALLOC_FAIL;          // no memory available
        }

  if (os_mbx_check(mailbox) == 0){  // mailbox full
      return MBX_FULL;
        }

  inptr->data = in;

  if (os_mbx_send(mailbox, inptr, timeout) != OS_R_OK){         //if != OS_R_OK, error happened
                return MBX_TIMEOUT;
        }
        #ifdef _DEBUG
        printf("available: %i\n",os_mbx_check(mailbox));
  #endif
        return MBX_OK;          //successfully added data to mailbox
}

and my read message method for ISR

MBX_MSG_STATUS MbxQueueSC::read_irq(T_MBX_SC *out){
  printf("irq: %i \n",isr_mbx_check(mailbox));
  if (isr_mbx_receive (mailbox, (void**)&outptr) != OS_R_OK){
        *out=*outptr;
                _free_box(mailpool, outptr);
    return MBX_OK;
        }
  else{
    return MBX_EMPTY; //no message was available
  }
}

my ISR

void USART3_IRQHandler(void){
T_MBX_SC send;
  //this part is working
  if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET){ //received char
    if (q_sm4200_irq_rx.add_irq((U8)USART_ReceiveData(USART3))){
        // intercept queue error here
      }
    }

  if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET){
    if (q_sm4200_irq_rx.read_irq(&send) == MBX_EMPTY)
    {
      USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
    }
    else
    {
      USART_SendData(USART3, send.data);
      USART_ClearITPendingBit(USART3, USART_IT_TXE);
    }
   }
}

i did not post my mailbox init routines here, but as is said they are working as it seems

when i add messages from a task and call os_mbx_check(), the free-mailbox number is decrasing, so i think the messages are added to the mailbox.

if i call isr_mbx_check() in the ISR for the same mailbox, it always shows me the maximum mailbox space, as if no messages were added.

do you have any idea what i might do wrong?

0