disable external Interrupt from time to time, possible ?

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

I have an external interrupt that is generated every second from an PCF8583 clock chip. In this routine I read the time from the clock.

Is it possible to disable this interrupt from time to time e.g. when I'm in an data entry routine where I can correct and set the time in the clock chip ?

How would you do that ? I don't want to disable interrupt generally because my data entry routine depends on interrupts too.

Can I do this by modifying the external interrupt mask register (EIMSK) ?

Harald.

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

Quote:

Can I do this by modifying the external interrupt mask register (EIMSK) ?

Yes.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Thank's, that's easy. I will give it a try.

Harald.

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

blueled wrote:

Can I do this by modifying the external interrupt mask register (EIMSK) ?

Harald.

Or, you might set a flag variable of some kind to indicate that time setting routine is active, and if an interrupt comes from the RTC chip, just ignore it based on the flag variable.

Actually, I would do it so that the only thing that happens in RTC interrupt is to set a flag variable to 1 that an RTC interrupt has happened, and in main loop somewhere check that flag and do some processing then. Then I would not have to worry about interrupts happening in the middle of something or worry about disabling interrupts.

- Jani

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

Jani, Thanks.

This is what I'm doing right now and it works so far for me. But I wanted to keep the interrupt routines as small as possible and not wanting to blow them up by reading flags and stuff...

So I was just wondering how you guys would do such things.
Maybe there are better methods I did'nt think of so far.

Harald.

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

Hi,

and ther are other ways:

* If you use the AVR internal pullup for the interrupt input, then disable it.
the line will then allways be low, unless there is no exterenal pullup.

* disable the RTC´s interrupt output by selecting "Alarm interrupt" and set the alarm registers to a time in the past.

Quote:
Can I do this by modifying the external interrupt mask register (EIMSK) ?

Why didn´t you test this by yourself? Very easy!

Klaus
********************************
Look at: www.megausb.de (German)
********************************

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

Hi Klaus,

unfortunatly I have the RTC's output pin pulled up by a external R and than connected to my Int7 on the mega128.

But as you've said setting the alarm to a past time would be another way to temporary disable the int.

many way's leed to Rome. ;-)

- Harald.

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

MegaUSBFreak wrote:
* If you use the AVR internal pullup for the interrupt input, then disable it. the line will then allways be low, unless there is no exterenal pullup.

Carefull here! Disabling the internal pullup does not mean that the input will always be low. If the pullup is needed at all it means that the RTC output is Open Drain. So the input will be floating giving random results ( you bring you hand near the board and it trips).

OTOH You could change the pin to output and drive it low. That would present the low impedance required to prevent random pickup of noise.

DFR

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

Depending on the type of interrupt you use, like edge-triggered, the interrupt flag may still be set, even though you mask it off via eimsk. When you finally enable the interrupt with eimsk, the interrupt will immeadiately trigger. So clear the interrupt flag before enabling the mask.

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

@DFR,

rechecking on the datasheet of the RTC confirms your assumption that it is open drain.
I remember that this was the reason for me to add the pullup R on my board because it was really unstable before.

Thanks for that hint.

Harald.

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

@danafraymond

Switching the output to GND is far better then leave it floating!
(I did not thik about this. The open drain output is 1Hz 50% dutycycle, so i thought there should be not that much pullup currents to pull it HIGH within 500ms)

Quote:
it was really unstable before.

I use the PCF8593 with the AVR internal pullup only - without problems.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

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

From the descriptions so far, why not just let the interrupt continue firing, and have a "in setup" flag? The ISR can just exit if it is set. It only takes a few cycles every second to check the flag.

Lee

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.