Hello,
When I single step my program and watch the TCNT Word in the debugger, it changers by great amounts, like 30,000 steps at a time, even when I assembler step it.
It should change by two steps for each assembler step at the absolute maximum.
I am running 16x32 division through TSCR2 and PTPSR so I would expect the pulses to take many single steps.
What is happening?
My PLL is working fine as I can generate known frequencies on the ECLK pin.
Also this is causing continuous interrupts and the flags are always set.
However when I run it on the processor, it runs nearly as expected, except it is out by a factor of 8 to what my expected period is.
This is my Init routine...
**********************************************************
void ECT_Init(void){
ECT_TSCR1 = 0x98; / // turn Counter on and enable precision timer.
ECT_TSCR2 = 0x04; // Divide by 16
ECT_PTPSR = 0x1F; // Divide by 32
// Bus Freq (80Mhz) Divided by (16*32) = 156,250hz
ECT_TIOS |= 0x01; // Set IOS0 as Output Compare
ECT_TCTL2 |= 0x01; // Set Output Compare 0 to toggle
ECT_TIE = 0x01; // Set OC0 and OC1 to allow interrupts
ECT_TC0 = ECT_TCNT + 0x0870; // Load first compare value 216 degrees
}
interrupt void ISR_MakeCrankSignal (void){ // ECT0
int CmpVal = 0;
ECT_TFLG1 = 0x01; // Clear Flag
if (CAS_Pos == 1){
CmpVal = CAS_PW;
}
if (CAS_Pos == 2){
CmpVal = CAS_PW*4;
}
if (CAS_Pos == 3){
CmpVal = CAS_PW*2;
}
if (CAS_Pos == 4){
CmpVal = CAS_PW*3;
}
ECT_TC0 += CmpVal;
CAS_Pos = CAS_Pos + 1;
if (CAS_Pos == 5){
CAS_Pos = 1;
}
return;
}
**********************************************************