[cross-post] nested interrupts

Agreed. Simpler if the hardware can keep track of its own state. Here we're seeing a software system running alongside the serial hardware, trying to keep track of state based on occasional hints. I feel very lucky that the uPs I've worked on all let me run the show using interrupt enables and persistent interrupt flags. Didn't know there were other kinds.


Reply to
Mel Wilson
Loading thread data ...

The 8032 has a TI flag that gets set when the stop bit is sent. You have to clear it in the interrupt handler. When you use the scheme I presented, you only need to set the TI flag yourself to invoke the first interrupt from the main code.


Reply to
Meindert Sprang




IIRC the problem comes with a possible race condition. pseudocode FIFO is not empty, so set flag to indicate TI should not be set after char added. Interrupt empties buffer and clears TI Add char Do not set TI because buffer was not empty. In future TI will not be set because FIFO is not empty.

You can't just set TI every time a char is added to the FIFO as that will cause characters to be lost by overwriting SBUF.

Reply to

Some times, you just need to turn off interrupts:

  • turn of interrupts (or just serial interrupt, if possible)
  • set TI if FIFO empty
  • add character
  • turn on interrupts

(and beware of the extra latency you're adding to everything else)

My liberal friends think I'm a conservative kook.
My conservative friends think I'm a liberal kook.
 Click to see the full signature
Reply to
Tim Wescott

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.