Tiny 25 ADC Trigger source

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am having a bit of difficulty trying to decipher the data sheet on this one.
I have a Tiny 25 set up with phase and frequency correct PWM on PB0 and this runs fine at around 245Hz. I have set up the ADC to free run and that also runs ok.
So what's the problem? Well I'm trying to trigger the ADC from the PWM timer / counter and according to the data sheet, by setting ADTS1 and ADTS0 (ADCSRB register)the trigger source will then be Timer / Counter Compare match A. However, when I try this the ADC stops running.

Am I missing something here or can this Timer Counter not be used to trigger the ADC if it is already set up for PFC PWM?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks like it should work - the ADC trigger is effectively the same as the IF bit for that interrupt condition and diagram 13-7 seems to show the comapre match interupt flag will be set during the cycle.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

the trigger source will then be Timer / Counter Compare match A.

Remember that you have to clear the trigger flag. The trigger only fires on the rising edge of the trigger flag.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Remember that you have to clear the trigger flag. The trigger only fires on the rising edge of the trigger flag.

This may well be the source of my problem. Thanks I'll check it out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The timer as trigger source was not a real feature.

The trigger occur only on the transition of the interrupt flag.
So you need the timer interrupt handler also to clear the interrupt flag.

Thus I use only the timer interrupt to store the result and start the next conversion.
This saves code space and CPU time in comparison to two interrupt handlers (ADC + timer interrupt).

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The timer as trigger source was not a real feature.

The trigger occur only on the transition of the interrupt flag.
So you need the timer interrupt handler also to clear the interrupt flag.

Thus I use only the timer interrupt to store the result and start the next conversion.
This saves code space and CPU time in comparison to two interrupt handlers (ADC + timer interrupt).


I have done it the other way (but I don't remember whether it was the Tiny25 series).

I clear the timer interrupt flag in the ADC-complete ISR. This also means only one ISR.

So as far as I know you can do it either way. With using only the ADC-complete ISR, then you can act on the conversion results sooner?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.