I'm using PIC32MZ2048EFM144, XC32 V1.40 and MPLABX v3.30.
I'm trying to use timers 7, 8, 9 for dead time in software generated space vector PWM. No matter what PR9 I set, I get a delay of 655,5 us = 65 550 count (at 1:1 prescaler and 100 Mhz clk) - so at overflow.
My code :
- Code: Select all
void init_timer_9(void){
T9CONbits.ON = 0;
T9CONbits.SIDL = 0;
T9CONbits.TGATE = 0;
T9CONbits.TCKPS = 0b000;
T9CONbits.TCS = 0;
TMR9 = 0;
PR9 = 200; //2us
}
void __ISR(_TIMER_9_VECTOR, IPL6SRS) DTL3 (void){
if(StanjePWML3 == 1) {
PWM_L3_L_SET();
StanjePWML3 = 0;
}
else {
PWM_L3_H_SET();
StanjePWML3 = 1;
}
T9CONCLR = _T9CON_ON_MASK;
TMR9 =0;
IFS1CLR =_IFS1_T9IF_MASK;
}
//form interrupt init code snippet
//timer 9
IPC10bits.T9IP = 6; //priority 6
IPC10bits.T9IS = 1; //sub priority 1
IFS1bits.T9IF = 0; //clear flag
IEC1bits.T9IE = 1; //int enable
}
The problem is on timer 7,8,9, but I'm only debugging 9 atm. On a side note - How do I write directly to a register - eg to PR9 at Virtual adress (BF84_1020)? It may be that the register is not mapped correctly to PR9, as it is set to 0xFFFF after reset according to the datasheet.
Best regards,
Marko