AVR, ATMega8, who is running his code on mine?

Hi,

I am wondering what happens here, like if code would run in the background :-)

If I run this code (initialisation part being removed to clarify), PortB.2 remains low:

Timer0Overflow: reti

Reset: ... sei cbi PORTB, 2

Main: rjmp Main

And if I run following, PortB.2 goes low but immediatly after, et goes high again (seen on my scope):

Timer0Overflow:

cbi PORTB, 2 reti

Reset: ... sei

Main: rjmp Main

In this second case the AVR behaves like if I would have cbi then sbi. So, who is raising my PortB.2 output?

Regards

Reply to
sap
Loading thread data ...

in fact, it seems it bahaves like if Reset occurs immediatly after Timer0Overflow. but I still do not know why.

Reply to
sap

looks it works much better if I initialize the stack pointer... sorry!

ldi R16, LOW(RAMEND) out SPL, R16 ldi R16, HIGH(RAMEND) out SPH, R16

sei

Reply to
sap

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.