AnsweredAssumed Answered

STM32F107 Interrupt crash

Question asked by Laga.Freya on Mar 30, 2017
Latest reply on Mar 30, 2017 by KIC8462852 EPIC204278916

Hi to all,
I have a problem about interrupt, expecially USART interrupt.
I use USART1 to interface my boarf to computer (FT232), but often my routine crashes.
Here is the code:

 


uint16_t iocnt = 0;
extern "C" void USART1_IRQHandler()    // Default print
{
    uint8_t c;
    
    c = USART1->DR;
    if(iocnt < MAXBUF - 10)
    {
        if(c != '\n')
        {
            iobuf[iocnt++] = c;
            iobuf[iocnt] = 0;
        }
        else
        {
            USART1->CR1 &= ~USART_CR1_RXNEIE;    //Disable RXNE interrupt
            iobuf[iocnt] = 0;
            iocnt = 0;
            DecodeCom(iobuf);
            USART1->CR1 |= USART_CR1_RXNEIE;    //Enable RXNE interrupt
            myusart1.PrintString((uint8_t *) "\n\tInterrupt finished\n ", 0);
        }
    }
    return;
}

 

Every input character is correctly catched
Function DecodeCom() is correctly executed
Check string ("interrupt finished") correctly sent to pc

 

Then sometime MCU stops (that is no further program line is executed), sometime program continue its run.
It seems the problem could be in return from routine but I do not know where I can check

 

Any hint?

 

Thank you
Freya

Outcomes