Firstly, and importantly, this is for an instaSPIN application. InstaSPIN forums suggest I try my luck here....
I am trying to 'read' 50Hz, 1-2ms (high) PWM to use as the torque set-point for instaSPIN. I have already written some code to do this on my F28027 Launch and I am now trying to port it to instaSPIN. Step one of this is to trigger the ISRs, I have two separate ISRs being triggered from the rising / falling edge of GPIO12 (HW is DRV8301BOOST) which I *believe are setup correctly... When GPIO12 changes state (i.e. either rising or falling edge) my code gets caught by the illegal_ISR routine... I have done some research on this and it seems that it may be the stack getting 'lost' - not enough memory dedicated so I tried to increase from 0x200 (default) to 0x280, the largest I could go without rewriting the linker (which I'm not game to do without some advice on memory locations first) but this obviously didn't work.
*I have also stepped through my program and it is definitely falling over when the interrupt is triggered... If I leave GPIO12 floating I can spin the motor and everything plays nicely.
My code, (added to a clean copy of lab05a.c - below is the only change from stock lab05a)
In drv.c I have added:
Enable interrupts
void DRV_enableRCInts(DRV_Handle handle) //PF
{
DRV_Obj *obj = (DRV_Obj *)handle;
PIE_setExtIntPolarity(obj->pieHandle, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_RisingEdge);
PIE_setExtIntPolarity(obj->pieHandle, CPU_ExtIntNumber_2, PIE_ExtIntPolarity_FallingEdge);
PIE_enableExtInt(obj->pieHandle, CPU_ExtIntNumber_1);
PIE_enableExtInt(obj->pieHandle, CPU_ExtIntNumber_2);
CPU_enableInt(obj->cpuHandle, CPU_IntNumber_1);
}
Setup GPIO12:
// No Connection GPIO_setMode(obj->gpioHandle,GPIO_Number_12,GPIO_12_Mode_GeneralPurpose); /////////////////////////////////////PF/////////////////////////////////////////////////// GPIO_setDirection(obj->gpioHandle, GPIO_Number_1, GPIO_Direction_Input); GPIO_setQualification(obj->gpioHandle, GPIO_Number_1, GPIO_Qual_Sample_6);//GPIO_Qual_Sync); GPIO_setExtInt(obj->gpioHandle, GPIO_Number_12, CPU_ExtIntNumber_1); GPIO_setExtInt(obj->gpioHandle, GPIO_Number_12, CPU_ExtIntNumber_2); ///////////////////////////////////////////////////////////////////////////////////////
And in DRV.h I have:
define interrupts:
// ************************************************************************** // the globals extern interrupt void mainISR(void); extern interrupt void xint1_isr(void);//PF extern interrupt void xint2_isr(void);//PF // **************************************************************************
Enable ExtInt
static inline void DRV_initRCIntVectorTable(DRV_Handle handle) //PF
{ DRV_Obj *obj = (DRV_Obj *)handle;
PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
PIE_enableInt(obj->pieHandle, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1);
PIE_enableInt(obj->pieHandle, PIE_GroupNumber_1, PIE_InterruptSource_XINT_2);
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;
}
Acknowledge interrupt
static inline void DRV_acqRCInt(DRV_Handle handle) //PF
{
DRV_Obj *obj = (DRV_Obj *)handle;
// Acknowledge interrupt from PIE group 1
PIE_clearInt(obj->pieHandle,PIE_GroupNumber_1);
return;
}
And, in Lab05a.c I have:
// the globals volatile uint32_t Xint1Count;//PF volatile uint32_t Xint2Count;//PF
Clear Count
Xint1Count=0; //PF Xint2Count=0; //PF
Initialize PIE for external interrupt:
// initialize the interrupt vector table DRV_initIntVectorTable(drvHandle); //PF DRV_initRCIntVectorTable(drvHandle); // enable the ADC interrupts DRV_enableAdcInts(drvHandle); // PF DRV_enableRCInts(drvHandle); // enable global interrupts DRV_enableGlobalInts(drvHandle);
The ISRs:
interrupt void xint1_isr(void)
{
Xint1Count++;
//CpuTimer2Regs.TCR.bit.TRB = 1; //Reload Timer
//CpuTimer2Regs.TCR.bit.TSS = 0; //Start Timer
// Acknowledge this interrupt to get more from group 1
// PIE_clearInt(myPie, PIE_GroupNumber_1);
DRV_acqRCInt(drvHandle);
}
interrupt void xint2_isr(void)
{ Xint2Count++;
//CpuTimer2Regs.TCR.bit.TSS = 1; //Stop Timer
//test = (0xFFFFFF-CpuTimer2Regs.TIM.all)*0.00002; // Read TimerTIMER_getCount(myTimer2);
// Acknowledge this interrupt to get more from group 1
// PIE_clearInt(myPie, PIE_GroupNumber_1);
DRV_acqRCInt(drvHandle);
}
This screen shot has some address's in it that I thought might be useful for debugging?
Thanks for any tips, I've been stuck on what should in essence be very simple for two days now.
PS. to any InstaSPIN devs who see this - assuming I can get this working, how should I be timing the high time of the PWM? I was originally thinking Timer2, but the instaSPIN forums seem to think there may be a better way (PWM ticks)???

