programming atmega48

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

Reply to
Hul Tytus
Loading thread data ...

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.

Reply to
larwe

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

Hul

larwe wrote:

Reply to
dbr

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

Reply to
Hul Tytus

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]: 
 Click to see the full signature
Reply to
CBFalconer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.