AnsweredAssumed Answered

TWR-KV31F120M Processor Expert Triggered analog conversion does not occur.

Question asked by Mark Wyman on Oct 12, 2016
Latest reply on Oct 13, 2016 by Mark Wyman

Hi All,

 

I decided to go the Processor Expert route for generating code on this project since I am using a tower model (TWR-KV31F120M) for vetting software, then switching over to a custom board for final development with a very different configuration. I didn't want a lot of fuss when switching between targets, and this seemed to be the way to go. However, I am having quite a few issues with the analog to digital converter beans, and I am hoping someone can shed some light into what I may be doing wrong, or if there is a problem in the beans that I am running into.

 

What I am attempting:

The final code needs to support ADC0 triggered on an external signal (for filtering out a fundamental frequency to look at everything else), and ADC1 also triggers on a separate external signal for the same reasons. Both of these signals are derived from self-resonant circuits, so I run them into Analog Comparator inputs with peak detectors so that I can synchronize them to the processor clock domain and convert on the peak measured AC signal only. It prevents me from having to sample like crazy to find peak voltages consistently and accurately in-phase with my analog signal. I need to pick very small signal changes out from a much larger signal, and this seems like an elegant solution.

 

So far so good:

I started with a processor expert project for this specific development board, so the pin definitions all came in properly.

 

Running the ADC0 and ADC1 blocks using AD#_StartSingleMeasurement() methodology works fine, AS LONG AS I don't start with Number of conversions greater than one. What I mean by this is I can get the bean to begin working if I set it to 1 first, generate code, and then set it to some other number and generate again.  If I start with any more than one, and the event for AD#_OnMeasurementComplete() never fires. I know, odd.

 

The Analog Comparator 0 (CMP0) I have set to simply increment a global counter upon interrupt, and using an external signal generator to test, it works fine. I have output filtering turned on , and again it works fine. I can see my counter increment in-step with my test frequency generator.

 

Not so good:

So I then take the ADC0 block (it is assigned AD1 in PE) and try to get it to trigger from CMP0. I changed my conversion init routine to the following:

 

void A2D_init(void)
{
//Initialize the analog compare input.
//Enables when complete
myAC1_Ptr = AC1_Init(NULL);

//Initialize the A2D converter devices.
myAD1_Ptr = AD1_Init(NULL);
myAD2_Ptr = AD2_Init(NULL);

//Select unique static sample group 0 for each...
Error = AD1_SelectSampleGroup(myAD1_Ptr, 0);
Error = AD2_SelectSampleGroup(myAD2_Ptr, 0);

//For switching sample groups on AD2 per display update
//checks that it can be done.
toggle = FALSE;

//Used in interrupt vectors for signaling a conversion
//occurred, and how many per display cycle.
globals.AD1_ConversionCount = 0;
globals.AD2_ConversionCount = 0;

//Turn on AD1, this should start converting upon a compare event
//It never interrupts or completes even though AC1 fires fine.
Error = AD1_StartLoopTriggeredMeasurement(myAD1_Ptr);
 //Debug test counter
lastConversionCount = 0;

//Turn on AD2, this starts immediately, but does not appear to
//work if multiple sample averaging is turned on for the bean
//With single conversions, it works fine.
Error = AD2_StartSingleMeasurement(myAD2_Ptr);

//Message that this was run.
dprintf(0, "A2D Initialized");
}
//In Events.c

void AD1_OnMeasurementComplete(LDD_TUserData *UserDataPtr)
{
/* Write your code here ... */
globals.AD1_ConversionCount++; //Never even fires once.
}

 

 

So as can be seen after setup/init I call:

Error = AD1_StartLoopTriggeredMeasurement(myAD1_Ptr);

yet no interrupt for MeasurementComplete ever fires, and AD1 stays stuck busy. Meanwhile the Analog Compare interrupt continues to fire correctly on my external signal. It behaves as if the trigger is not connected to the bean properly.

 

I also tried to use a PIT timer with the same result. PIT interrupt fires fine, no triggered conversions.

I have tried different numbers of conversions, Discontinuous checked vs. unchecked, different sample times, different number of conversions, different conversion times, all with the same result: No trigger fires the conversion.

 

Note: I don't have DMA on.

 

See attached image for the Trigger settings I am using.

 

Thanks for any ideas to try, or insights into using PE for this sort of thing. I have had great success with PE in the past.

 

-Mark

Attachments

Outcomes