Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
17 years ago

help:uart error

hi,

i used the uart correctly before, but when i added a function in the uart interrupt function, it can receive the data only once, receiveed another data, the program run out. why?

7 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    What function did you add to your interrupt routine? We could try guessing but a bit more information might help us get there quicker.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Fair enough. Well there's nothing intrinsically wrong with calling a function from within an ISR. The most likely problem is that you are using a HAL function call which relies on interrupts being enabled.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hi,

    yeah, in the function, i used "alt_write_flash() & alt_read_flash()".
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Well according to the literature, neither of those functions should be used in an ISR. I think you need to restructure your code to make the ISR function much simpler.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    i have tried to call programme in other location, and i set a flag in the usart isr. the main programme checked the flag, and called programme. then the same problem happened.so why?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It seems likely that during flash write operations, interrupts could be disabled for relatively long periods (I'm just guessing, I haven't checked). You could therefore get uart buffer overrun errors and lose data.

    Without a lot more information about your code, it's hard to make any useful suggestions.