comp.arch.embedded programming atmega48 The code below is intended to detect a rising transition on the external interput pin by sampling the flag register but it doesn't work on an atmega48. With the ei-mask bit set (no sei), the code didn't detect a transition either. On an atmega162 this does work, however, and the documentation describes the functioning of the flags in the same manner. Perhaps the 48 requires setting something I missed. Any suggestions? Hul ldi areg, 0xc ; set external irpt 1 for rising edge sts EICRA, areg sbi EIFR, 1 ; clear flag in ext irpt 1 - number 1 bit ; stalling untill meas device is connected & running exirst1: in areg, EIFR andi areg, 2 ; check flags existence brz exirst1 ; & wait if not there
programming atmega48
Started by ●October 1, 2008
Reply by ●October 2, 20082008-10-02
On Oct 1, 5:49=A0pm, Hul Tytus <h...@panix.com> wrote:> =A0 =A0 =A0 =A0 The code below is intended to detect a rising transition =on the> external interput pin by sampling the flag register but it doesn't work o=n an> atmega48. With the ei-mask bit set (no sei), the code didn't detect a > transition either.I had a similar problem - I was tearing my hair out - trying to poll interrupts on an ATmega649. It turned out that I was using the wrong header file (for the 169) and the bit assignments were NOT the same! Moral: check which bits you're actually sampling vs. what you're supposed to be sampling; I see magic numbers in your code snippet.
Reply by ●October 2, 20082008-10-02
Good thought - I'll check on the ports & such. Hul larwe <zwsdotcom@gmail.com> wrote:> On Oct 1, 5:49?pm, Hul Tytus <h...@panix.com> wrote:> > ? ? ? ? The code below is intended to detect a rising transition on the > > external interput pin by sampling the flag register but it doesn't work on an > > atmega48. With the ei-mask bit set (no sei), the code didn't detect a > > transition either.> I had a similar problem - I was tearing my hair out - trying to poll > interrupts on an ATmega649. It turned out that I was using the wrong > header file (for the 169) and the bit assignments were NOT the same! > Moral: check which bits you're actually sampling vs. what you're > supposed to be sampling; I see magic numbers in your code snippet.