programming atmega48

Oct 01, 2008 4 Replies

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



on the

n an

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.

Good thought - I'll check on the ports & such.

Hul

larwe wrote:

comp.arch.embedded programming atmega48

The code below is still not working, but some other code using the external interupt mechanism strictly to execute a routine is running. The difficulty there was using: sts EIMSK, areg rather than: out EIMSK, areg.

Possibly, considering the code below, the clock for the interupts is disabled unless both the specific mask bit and the master interupt bit are set, rendering the interupts inoperative as an inspection tool for transitions at a pin. There is probably some other explanation since sacrificing significant function for marginal power reduction might cause a ripple in Atmel's design circle. Then again, power reduction is fashionable... If anyone sees a way to implement the code below or an alternate means to achieve the same result, please mention it.

Hul

Please do not top-post. Your answer belongs after (or intermixed with) the quoted material to which you reply, after snipping all irrelevant material. Without proper quotes and reasonable order your post is basically non-understandable. See the following links:

(taming google) (newusers)

[mail]: Chuck F (cbfalconer at maineline dot net) [page]: Try the download section.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required