Other Parts Discussed in Thread: CONTROLSUITE, MOTORWARE
Tool/software: TI C/C++ Compiler
Hi every one .
i tried to modify C:\ti\controlSUITE\Example_F2802xExternalInterrupt\Example_2802xExternalInterrupt.c and use it in Motorware proj_lab13b,c
but I did not get the good result of it. Please kindly see if it has any problem.
// set the default controller parameters CTRL_setParams(ctrlHandle,&gUserParams); // setup faults HAL_setupFaults(halHandle); // initialize the interrupt vector table HAL_initIntVectorTable(halHandle); // enable the ADC interrupts HAL_enableAdcInts(halHandle); //================================================= // this is my function for initializing External intrrupt SAL_Xint(salHandel); //========================================================= // enable global interrupts HAL_enableGlobalInts(halHandle); // enable debug interrupts HAL_enableDebugInt(halHandle); // disable the PWM HAL_disablePwm(halHandle); // initialize the ENC module encHandle = ENC_init(&enc, sizeof(enc));
my function is this
void SAL_Xint(SAL_Handle handle) { SAL_Obj* obj= (SAL_Obj*) handle; //============================ external intrruot section========================================= // PIE_setDebugIntVectorTable(obj->HAL_Handle->pieHandle); PIE_enable(obj->HAL_Handle->pieHandle); EALLOW; ((PIE_Obj*)obj->HAL_Handle->pieHandle)->XINT1 = &xint1_isr; EDIS; // Register interrupt handlers in the PIE vector table PIE_registerPieIntHandler(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_SubGroupNumber_4, (PIE_IntVec_t)&xint1_isr); PIE_registerPieIntHandler(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_SubGroupNumber_5, (PIE_IntVec_t)&xint2_isr); // Enable XINT1 and XINT2 in the PIE: Group 1 interrupt 4 & 5 // Enable INT1 which is connected to WAKEINT PIE_enableInt(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1); PIE_enableInt(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_InterruptSource_XINT_2); CPU_enableInt(obj->HAL_Handle->cpuHandle, CPU_IntNumber_1); // Enable Global Interrupts CPU_enableGlobalInts(obj->HAL_Handle->cpuHandle); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPIO_setMode(obj->HAL_Handle->gpioHandle, GPIO_Number_39, GPIO_39_Mode_GeneralPurpose); GPIO_setDirection(obj->HAL_Handle->gpioHandle, GPIO_Number_39, GPIO_Direction_Input); GPIO_setQualification(obj->HAL_Handle->gpioHandle, GPIO_Number_39, GPIO_Qual_Sync); GPIO_setMode(obj->HAL_Handle->gpioHandle, GPIO_Number_22, GPIO_22_Mode_GeneralPurpose); GPIO_setDirection(obj->HAL_Handle->gpioHandle, GPIO_Number_22, GPIO_Direction_Input); GPIO_setQualification(obj->HAL_Handle->gpioHandle, GPIO_Number_22, GPIO_Qual_Sample_6); GPIO_setQualificationPeriod(obj->HAL_Handle->gpioHandle, GPIO_Number_22, 0xFF); // GPIO0 is XINT1, GPIO1 is XINT2 GPIO_setExtInt(obj->HAL_Handle->gpioHandle, GPIO_Number_22, CPU_ExtIntNumber_1); GPIO_setExtInt(obj->HAL_Handle->gpioHandle, GPIO_Number_39, CPU_ExtIntNumber_2); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // initialize Intrrupt // Configure XINT1 PIE_setExtIntPolarity(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_RisingEdge); PIE_setExtIntPolarity(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_2, PIE_ExtIntPolarity_RisingEdge); // Enable XINT1 and XINT2 PIE_enableExtInt(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_1); PIE_enableExtInt(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_2); //====================================================== }
please check if the sequence of initialize has any problem.
__interrupt void xint1_isr(void) { PulseCounter++; // Acknowledge this interrupt to get more from group 1 PIE_clearInt(sal_Handel->HAL_Handle->pieHandle, PIE_GroupNumber_1); } __interrupt void xint2_isr(void) { PulseCounter++; // Acknowledge this interrupt to get more from group 1 PIE_clearInt(sal_Handel->HAL_Handle->pieHandle, PIE_GroupNumber_1); }
I would be happy if you help me.
Regards
Dave.