Diagnosis of Timer 1 Period (Phase Correct Top ICR1)

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

Hi, my friends, I hope you're fine

 

I use timer 1 Phase Correct Top ICR1 mode

How can i Diagnosis of Timer 1 Period  ?

I need an interruption shown in the picture

 

 

 

Thanks

 

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

Wouldn't we need to know the AVR model?

 

I should make the checklist some kind of sticky...

https://www.avrfreaks.net/commen... and many others

Please post a complete test program.  Tell your AVR model and clock speed.  Tell your language, brand of toolchain and version.  Tell compile options, and build results.  Are there any warnings?Show your schematic and describe what is connected.

 

What do you expect to happen?  What >>is<< happening?  How are you testing?

OK, what does a representative datasheet imply about when the compare match interrupt is carried out?

So you are using Mode 10?

That chart doesn't help much.  But the description of the mode...

 

 

So you will get an interrupt on both edges.  Have code at the head of the ISR to ignore the falling edge.

 

 

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

excuse me

 

 

Atmega8A 8mhz

 

Yes Mode 10

 

How can I ignore the second interruption in compare match A?

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

azadfalah wrote:
How can I ignore the second interruption in compare match A?

I don't think you can "ignore" it, but you can detect it and then leave the ISR.

 

All of this is not important to measure the period, as you already know that -- it is the value of ICR1.

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

I did the following with the code below, do you think this method is reliable and logical?

 

i using if( !(PINB & (1<<2)) ) to detect it

 

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

theusch wrote:
I don't think you can "ignore" it, but you can detect it and then leave the ISR.

 

How can i detect this ? 

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

yes i know the period but i want measure the rms voltage and need know status of output in moment

if i using ICR1 match interruption we have
two half cycle and one full cycle can i take samples from this wave and measure rms voltage ? or no i should take samples from beginning to end ?

thank

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

Not clear what you want.

Do you want to produce a signal using timer1 ?

And do you want to know the rms of this signal?

 

Then you can calculate it from timer settings.

 

E.g.

duty_cycle = OCR1A / ICR1 

rms = Voltage * sqrt(duty_cycle)

 

But maybe I did not understand the question.