How to Skip the "Delay Subroutine" in Avr Studio Simulator Debugging Mode

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

Hi,

 

I wrote a program to blink an LED for each second. And built solution in avr studio. Then i entered into debugging mode with 'Simulator' tool.

 

For each 'step in', each program line is executed. Pls see a part of the program.

 

In debugging mode, after the yellow cursor reach the line "OUT PORTB, R16" (/// Line 1), next it will go to "Delay_1sec" function.

 

Next, I want to run the delay function in background and reach the "///Line 2" quickly (without entering into delay subroutine). How i can try in avr studio 6.2

My program:

 

.....
......

Toggle_LED:

        IN R16, PORTB
        COM R16
        OUT PORTB, R16        /// Line 1

        RCALL Delay_1sec

        IN R16, PORTB        /// Line 2
        COM R16
        OUT PORTB, R16

        RJMP Toggle_LED

......
......

Delay_1sec:

        LDI R16, 8
        Loop1:

            LDI R17, 120
            Loop2:

                LDI R18, 250
                Loop3:
                    NOP
                    NOP
                    DEC R18
                    BRNE Loop3
                DEC R17
                BRNE Loop2
            DEC R16
            BRNE Loop1

        RET

-

Lenin

- Lenin Chakravarthy

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

Use Step Over (steps over function/subroutine calls) - not Step Into 

 

Alternatively, set a Breakpoint after the call - and just let it run to the breeakpoint.

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

Personally I think I'd go for:

//#define SIMULATING
Toggle_LED:

        IN R16, PORTB
        COM R16
        OUT PORTB, R16        /// Line 1

#ifndef SIMULATING
        RCALL Delay_1sec
#endif        

        IN R16, PORTB        /// Line 2
        COM R16
        OUT PORTB, R16

        RJMP Toggle_LED

Remove the "//" comment from the define when you build to simulate.

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

Use the preprocessor directives that are defined for debug mode;  (see options)

 

#if !defined(DEBUG)
   RCALL Delay_1sec
#endif

 

Happy Trails,

Mike

JaxCoder.com

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

Well yes and no.

 

DEBUG could be either simulation or on chip debugging. For the latter you might actually want the delays in place. It's only really SIMULATING where you want to defeat the delays because you are working with a 50kHz AVR rather than a 1/2/4/8MHz one.

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

clawson wrote:

Well yes and no.

 

DEBUG could be either simulation or on chip debugging. For the latter you might actually want the delays in place. It's only really SIMULATING where you want to defeat the delays because you are working with a 50kHz AVR rather than a 1/2/4/8MHz one.

 

Good point, it's just such a pain to deal with when debugging!

Usually if I'm doing chip debugging I disable delays also, but then that depends on what I'm doing!

Happy Trails,

Mike

JaxCoder.com

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

Thanks to u all for giving ideas.

 

I'm new to assembly programming. Where i can learn assembler pre-processor better (with some example codes).

 

Have a nice day

 

-

lenin

- Lenin Chakravarthy

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

leninchakr wrote:

Thanks to u all for giving ideas.

 

I'm new to assembly programming. Where i can learn assembler pre-processor better (with some example codes).

 

Have a nice day

 

-

lenin

 

Shameless plug AVR Assembler 101

Happy Trails,

Mike

JaxCoder.com

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

Hi,

 

i got this attachment from internet. I read it, but unable to understand clearly.

 

Is there any material can give me to understand better?

 

If you are providing example codes for all preprocessor directives like clawson & mike32217 means, it will be very useful to me.

 

Thank you

Attachment(s): 

- Lenin Chakravarthy

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

I guess you realise that the assembler manual is online?

 

http://www.atmel.com/webdoc/avra...

 

The limited description of the pre-processor is here:

 

http://www.atmel.com/webdoc/avra...

 

but as it tries to work the same as the very well known pre-processor used in C programming you might be better off just finding a general text about the pre-processor in C for more in depth details/tutorials/etc.

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

Hi,

 

This link is very good.

 

www.cplusplus.com/doc/tutorial/p...

 

 

- Lenin Chakravarthy

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

Thanks you for providing the information.. I will refer those c-preprocessor material.

 

Have a nice day,

 

-

Lenin

- Lenin Chakravarthy