I am unable to get the ADC engine to respond to the line:
AdcRegs.ADCSOCFRC1.all = 0x007F; // 7 ADC conversions, SOC0 -> SOC6
While running from my large program in flash. However, the same intialization (shown here)
// *****************************************************************************
void ConfigureADCSampling(){ // Configure ADC
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
(*Device_cal)();
EDIS;
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // use internal bandgap reference
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // power up reference
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // power up band gap
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // power up ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // enable ADC
AdcRegs.ADCSOC0CTL.all = 0x000E; // ADCINA0, pin10, Synthesizer_5p2
AdcRegs.ADCSOC1CTL.all = 0x004E; // ADCINA1, pin8, UltraCap_Float
AdcRegs.ADCSOC2CTL.all = 0x00CE; // ADCINA3, pin7, Panel_Temp
AdcRegs.ADCSOC3CTL.all = 0x01CE; // ADCINA7, pin6, Outside_Temp
AdcRegs.ADCSOC4CTL.all = 0x02CE; // ADCINB3, Battery_Bus
AdcRegs.ADCSOC5CTL.all = 0x02CE; // ADCINB3, Battery_Bus
AdcRegs.ADCSOC6CTL.all = 0x03CE; // ADCINB7, Ambient_Light
EDIS;
}
// ****************************************************************************
When running from RAM in the following code snippet
// Enable CPU_Timer 1 in PIE
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable PIE block
IER |= M_INT13; // Enable CPU Interrupt 13, CPU_Timer 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
LoopCount = 0;
ConversionCount = 0;
// Wait for Timer interrupt to increment count
for(;;) {
LoopCount++;
if(CpuTimer1.InterruptCount != InterruptCount_old){
EALLOW;
AdcRegs.SOCPRICTL.all = 0x0400; // reset round robin pointer to 32
EDIS;
AdcRegs.ADCSOCFRC1.all = 0x007F; // 7 ADC conversions, SOC0 -> SOC6
InterruptCount_old = CpuTimer1.InterruptCount;
}
}
} // close main
// *******************************************************************
The ADC responds to the software forced SOC and result are visible in the results registers. The timer1 interrupt
routine simply increments a counter that's tested in the for(;;) loop to detemine if a ADC "refresh" is needed.
The logic is esentually the same in the larger program, but try as I might, I am unable to kick off a conversion sequence.
Thinking this might have something to do with the location of RAM versus ROM, I created a "ramfunc" ADC kickoff function
// *******************************************************************
void ADC_StartConv(){ // declared ramfunc
EALLOW;
AdcRegs.SOCPRICTL.all = 0x0400; // reset round robin pointer to 32
EDIS;
AdcRegs.ADCSOCFRC1.all = 0x007F; // 7 ADC conversions, SOC0 -> SOC
}
// ******************************************************************
that is called from the ROM code. No joy, still refuses to start.
I am stumped. Can anyone suggest a solution to this? PLEASE, PLEASE, PLEASE!
DE