AnsweredAssumed Answered

Waiting for Data with Interrupt

Question asked by honeycutt.matt on Feb 4, 2014
Latest reply on Feb 5, 2014 by honeycutt.matt
Gents (and maybe Ladies),

My goal is to wait until a certain amount of data has been received. I have setup an interrupt (Can Bus) and when it is triggered it stuffs the message into an Array. I'm using the following code to wait until all the data is received.

However, while in the loop, the CAN interrupt does not trigger. This loop is inside input interrupt, and is after the EXTI flag has been cleared. (There is an infinite loop in the main function)

What is the best way to achieve this?


int recCount = CanDriver::CacheCount();
while (recCount < 100)
      recCount = CanDriver::CacheCount();

CanRxMsg RxMessageArray[200];
int ArrayCounter = 0;
int recCounter = 0;
extern "C" void CAN1_RX0_IRQHandler(void)
    GPIO_WriteBit(GPIOD, GPIO_Pin_3, Bit_SET);
    CanRxMsg rxMessage;
    CAN_Receive(CAN1, CAN_FIFO0, &rxMessage);
    CAN_ClearITPendingBit(CAN1, CAN_IT_TME);
    GPIO_WriteBit(GPIOD, GPIO_Pin_3, Bit_RESET);
void CanDriver::StuffCanMsg(CanRxMsg RxMessage)
    RxMessageArray[ArrayCounter++] = RxMessage;
std::vector<CanRxMsg> CanDriver::ReceiveCache(bool empty /*= true*/)
    std::vector<CanRxMsg> returnMessages;
    returnMessages.assign(RxMessageArray, RxMessageArray + ArrayCounter);
    if (empty)
        ArrayCounter = 0;
        recCounter = 0;
    return returnMessages;
int CanDriver::CacheCount()
    return recCounter;