Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: AVR Power Supply Noise

2006-07-12 by David VanHorn

Please do big code by posting a link, or uploading a file.

Disable Interrupts                                          ' to test
if occasional errors in Log10 calc. comes from interrupts?
Lux = Log10(r0)

This part scares me to death.

Interrupts are your friend.  Honest.
If something isn't done right in the ISR though, it will really hose up your
day.
This smacks of a stack unbalance problem, or some register not saved that
should be, or a routine called from within the ISR that's using registers
that were in use when the int happened.


Diagnosing it in an HLL is a bit more interesting than in assembler, but
here goes:

The ISR must save the SREG register, and must also save any registers it
touches.
The ISR must also avoid messing with data that might be in the middle of a
calculation.
For example if the main line code compares X > 5 and X < 2, we might see
something like this, in pseudocode:

Start with X=2

If X > 2 and (It is)
(interrupt happens, modifies X so that X=9)
and X <5 (It isn't now)
then do something.

Well, coming in you would have expected this to do something, but the value
of X got changed in mid comparison.

This is another reason we like serial buffers.  The receive ISR puts chars
into the rx buffer, and that's all.. The receive processor takes them out.
The TX processor puts them into the tx buffer, and the UDRIE or TXC int
takes them out.
No task modifies another task's pointer, or modifies data that the other one
is using.

When making large blocks of tests, you may need to disable ints for a
moment, so that everything you're looking at is all in the same state.
Better yet, buffer it .


[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.