Problems with delay_ms

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I am new in this forum, but rather experienced with ATmega  I have seen a lot of topics regarding delay_ms function, but no match with my problem.

Since many years, I use the function delay_ms(xx) in various projects. In my current project, it worked up to last week. Now it doesn't anymore. To find the reason, I use the following mini code:

#include <asf.h>

main (void) {
    sysclk_init();
    delay_ms(1);
}

It works for parameters 1 ... 8 . Beginnig with 9 ms the program hangs up in the routine _portable_avr_delay_cycles  in cycle_counter.h:

static inline void __portable_avr_delay_cycles(unsigned long n)
{
    while (n) {
        barrier();
        n--;
    }

I appreciate any help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry, I forgot to mention that I use Atmel Studio 7

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

uli-scm wrote:
the program hangs up in the routine _portable_avr_delay_cycles  in cycle_counter.h

So are you using an AVR ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

watch dog timer ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SOLVED!!  The watchdog timer fuse bit was set.

 

That's is!   Many, many thanks!!!!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

uli-scm wrote:
SOLVED!! 

Jolly good. Now please mark the solution - see Tip #5 in my signature, below:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...