I have a UC3B0256 board where I am trying to drop current consumption.
Thus, I wish to sleep. In particular, I wish to sleep until the uart is almost done transmitting, so i have code like this:
if (tx ready irq is enabled) SLEEP(1);
The uart interrupt will disable itself as soon as the last character is sent. If this happens 'before' or during sleep, everything is good. If it happens between the test being performed and the sleep, it will sleep forever.
On AVR( 8 ) one could get away with this (equivalent):
DisableGlobalInterrupt(); if (tx ready irq is enabled) SLEEP(1); EnableGlobalInterrupt();
However if I do that on AVR32, it will never get out of sleep. I can stop execution before the sleep instruction, inspect that the status and mask registers indeed do have bit 1 (txrdy) set, and it still sleeps.
What is the right way to NOT sleep if one's wakeup source has already fired and gone away?
I am currently at 3.2mA @ 11MHz xtal /2 =5.5MHz for cpu, pba, pbb clocks. I need to keep the adc and usart running, so I can not stop the oscillator.