Hi,
I am doing an ADC Timer Interrupt program which includes a few functions. When I try to examine the program with Step Into, the program performs the step only the first time:
But second time, when supposed next step shoud jump to Line 84, the following error appears:
ARM Linker Path is correctly defined and also startup has the definition for ADC Int Handler properly. My code is shown below. Could you please say me if there is something wrong with it, that is causing error to prompt?. Thanks in advance
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/adc.h"
#include "driverlib/fpu.h" //Floating Point Unit Support
#include <math.h>
#include "driverlib/pin_map.h"
#ifdef DEBUG
void__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
unsigned long uliSA[1];
unsigned long iSD; //D-Stator Current
int SA,SB,SC, Sa, Sb, Sc; //Inverter switching states
float Real_Comp,Im_Comp; //Real & Imaginary components
float Ud=108.04; //Bus DC Voltage
float Rs=17.49; //Stator Resistance
float T; //Sample time
float FluxSD; //D-Stator Flux
int WatchInt;
float Re_Table(int x, int y, int z){
float Re;
/*If else table is made to implement Real component */
if (x==0 && y==0 && z==0) {Re=0; }
else if (x==0 && y==0 && z==1) {Re=-0.5; }
else if (x==0 && y==1 && z==0) {Re=-0.5; }
else if (x==0 && y==1 && z==1) {Re=-1; }
else if (x==1 && y==0 && z==0) {Re=1; }
else if (x==1 && y==0 && z==1) {Re=0.5; }
else if (x==1 && y==1 && z==0) {Re=0.5; }
else {Re=0; }
return(Re);
}
float Im_Table(int x1, int y1, int z1){
float Im;
/*If else table is made to implement Imaginary component */
if (x1==0 && y1==0 && z1==0) {Im=0; }
else if (x1==0 && y1==0 && z1==1) {Im=-((sqrt(3))/2); }
else if (x1==0 && y1==1 && z1==0) {Im=((sqrt(3))/2); }
else if (x1==0 && y1==1 && z1==1) {Im=0; }
else if (x1==1 && y1==0 && z1==0) {Im=0; }
else if (x1==1 && y1==0 && z1==1) {Im=-((sqrt(3))/2); }
else if (x1==1 && y1==1 && z1==0) {Im=((sqrt(3))/2); }
else {Im=0; }
return(Im);
}
float Flux_Est_D(float realc, float vbus, float rst, float st, unsigned long sdcurrent){
//Pending flux k-1 term
float fsd;
fsd=((2/3)*vbus*st*realc)-rst*st*sdcurrent;
return (fsd);
}
int main(void)
{
//Clock 80 MHz
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
//Floating Point Unit Enable
FPULazyStackingEnable();
FPUEnable();
/*GPIO*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
/*Timer*/
//TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet() / 50000);//Timer timer couldn't be higher than sample rate
//Enable the timer’s ADC output trigger
TimerControlTrigger(TIMER0_BASE, TIMER_A, true);
// Enable the timer and start conversion process
// TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(TIMER0_BASE, TIMER_A);
// Enable ADC sequencer 0 and its interrupt (in both the ADC and NVIC)
/*ADC*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // ADC0 module enable
SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); // 1.000.000 samples per second
ADCSequenceDisable(ADC0_BASE, 3); //Disable ADC Sequencer 0
//Sequencer will be triggered by one of the general-purpose timers.
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH6| ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
IntMasterEnable();
ADCIntEnable(ADC0_BASE, 3);
IntEnable(INT_ADC0SS3);
//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0);
WatchInt=0;
while(1){
Real_Comp=Re_Table(SA,SB,SC);
Im_Comp=Im_Table(SA,SB,SC);
FluxSD=Flux_Est_D(Real_Comp,Ud,Rs,T,iSD);
}
}
void ADC0IntHandler(void)
{
WatchInt=1;
//Clear sample sequence interrupt source
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, uliSA);
iSD=uliSA[0];
Sa = GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1);
Sb = GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2);
Sc = GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3);
//Positions 0, 1 and 2 are divided by 2, 4 and 8 respectively having so 0 or 1 values
SA=Sa/2.0;
SB=Sb/4.0;
SC=Sc/8.0;
}




