Hi, I am pretty new to this controller (got the demo board yesterday), and am trying to create a pushbutton power on/off system. I am in need of a delay function that can delay upwards to 1 second. i have written some code that i thought should work, but it doesn't seem to be working. can anyone help me out on this one? Also, at the end of this project, I want the system to be in low power wait/stop3 mode, during all of its waiting (for the button press, or one other signal. Can anyone help me out with this?
code:
/*this part is in main function, before the wait func is called*/
EnableInterrupts; /* enable interrupts */
MTIMCLK_PS = 8;
MTIMCLK_CLKS = 1;
MTIMMOD = 0xFF;
*/
void longWait()
{
timerFlag = 0;
MTIMMOD = 0xFE;
MTIMSC = 0x20; /* reset and start MTIM, enable ints */
MTIMSC = 0; //start it?
while(!MTIMSC_TOF && PTAD_PTAD2)
; //wait ~1 second, or so
MTIMSC = 0x10;
}
I have also attached the whole file.