Yahoo Groups archive

AVR-Chat

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

Message

RE: [AVR-Chat] Delay functions and "__builtin_avr_delay_cycles".

2011-07-05 by M W

I've never seen a Watchdog Timer prevent a lock up, they do let you recover from one :)

--- On Tue, 7/5/11, STEVEN HOLDER <s.holder123@btinternet.com> wrote:
> ... Loops can get stuck and there should
> always be a "supervisor" module to help the software out if
> it does i.e a watchdog timer, often used and often abused
> but if used in the correct manner can save lock up and
> headaches.

Also on NOPs for timing, there are times to use them, such as isochronous code (i.e. if you are making an embedded system where you have to GUARANTEE that, whatever path through your code is taken, it takes the same number of CPU cycles) - That's rare usually, last time I used it was a while ago, on an Avionics Safety System. It's frankly a lot more work than just using a timer to execute your code, when you need it though, you NEED it, the pay and work ethics / environment made it worth it, at least :)

Also - when you can, use your computer to test your software i.e. make a list of all your assumptions, and create a way to TEST that using software, some way you can instrument i.e. have a timer loop generate a series of periods (square wave is good here) that you can monitor with an OScope, to show you that your timer routine does in fact work as you expect; Fairly simple to do and can save tearing out huge handfuls of hair. If I have spare pins on a uC I tend to have those pins do things to show me what's going on, so I can probe them during debugging, things like "this pin toggles when this timer routine is entered" or the like; You can XOR the pin state, something so you see activity there that is meaningful to YOU, if not to anyone else. Documenting that is a good idea, for WHEN you have to add another kitchen sink to that project a year later :)

  Mark

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.