MOD54415 CWT reset using PIT
Posted: Wed Jul 02, 2014 7:54 am
Hi all,
I'm trying to get my CWT to reset properly but just can't seem to get it right. It's set up to trigger every 1.8 seconds, and I have a PIT running that loads 0x55 and 0xAA into the CWSR consecutively every full second (PIT interrupt routine handles that). Somehow, it's not working. The interrupt routine is configured at the moment to interrupt every second, and the only function it has is to reset the CWT before it trips, send an interrupt count number to the serial port, and to reset the PIT. By itself, the PIT is working just fine. with the CWT enabled, I get through the first interrupt routine, and the CWT starts barking at me (consistent reset). The CWT is set to trigger after 1.8 seconds, and I've tried it set to 3.7 seconds as well (0x19 and 0x1A respectively) but it just goes into an instant reset loop. Any ideas why?
Current CWT settings:
PIT interrupt function:
I'm trying to get my CWT to reset properly but just can't seem to get it right. It's set up to trigger every 1.8 seconds, and I have a PIT running that loads 0x55 and 0xAA into the CWSR consecutively every full second (PIT interrupt routine handles that). Somehow, it's not working. The interrupt routine is configured at the moment to interrupt every second, and the only function it has is to reset the CWT before it trips, send an interrupt count number to the serial port, and to reset the PIT. By itself, the PIT is working just fine. with the CWT enabled, I get through the first interrupt routine, and the CWT starts barking at me (consistent reset). The CWT is set to trigger after 1.8 seconds, and I've tried it set to 3.7 seconds as well (0x19 and 0x1A respectively) but it just goes into an instant reset loop. Any ideas why?
Current CWT settings:
Code: Select all
unsigned short settings = 0; // simple masking variable for CWCR
settings |= 0x8000; // sets CWCR as read-only - bit 15
settings |= 0x0019; // sets timeout to 3.7 seconds - bits 4-0
settings |= 0x00C0; // bit 7 = enable, bits 6-5 = generate system reset on timeout
sim2.scm.cwcr = settings; // load CWCR - starts WDT immediately
Code: Select all
INTERRUPT(exPitISR, 0x2400)
{
static WORD counter = 0;
sim2.scm.cwsr = 0x55;
sim2.scm.cwsr = 0xAA;
sim2.pit[1].pcsr |= 0x0004; // clear the PIT IRQ flag
SETUP_PIT1_ISR( exPitISR, 4 ); // setup PIT to trigger ISR
sim2.pit[1].pmr = 0xEE6B; // set count to 61035
sim2.pit[1].pcsr = 0x0B1B; // set prescale = 2048, rld, and enable
if (!release) iprintf("Timer 2 Reset. Count = %d \r\n", counter);
counter++;
}