AVR Studio debug problem

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

Hey,

i am using AVR Studio 4.15.623 (forking with atmega2561). I used a code wizard of codeVisionAVR to generate an initial code. this code (as a function) I used in start of my program.
when I debug the program step by step it goes to none code area, when I run the function as one step it works well.

Why is this?
how can I sove the problem?

thanks ahead

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

Are you debugging with JTAG or just the simulator?
Does CV know that you are using a mega2561?
More importantly, does Studio know?

Otherwise just check line # 43.
Please post your code.

David.

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

Hey,
I am debugging with JTAG.
yes, CV knows that I am using Atmega2561 it even add #include in the top of the file.
yes, studio knows that I am using Atmega2561 it even writes me ATMEGA2561 in status bar.

Quote:
Otherwise just check line # 43.

what does it mean?

void main(void)
{
char string[]="This is test string";
    #asm("cli");
    settings();
    power=1; 
    PORTA.0=1; //Green LED off
    putchar('\n');
    SendString(string,RS232);
    while(1) //for (i=0;i<=10;i++)
    {
        PORTA.0= !PORTA.0;
        delay_ms(1000);
    }
}

void settings(void)
{
// Declare your local variables here

// Crystal Oscillator division factor: 1
/*#pragma optsize-
CLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif*/
#asm("cli")
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=Out Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=T State1=0 State0=0
PORTA=0x00;
DDRA=0x03;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=Out Func3=In Func2=In Func1=Out Func0=Out
// State7=T State6=T State5=T State4=1 State3=T State2=T State1=1 State0=1
PORTD=0x13;
DDRD=0x13;

// Port E initialization
// Func7=In Func6=Out Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=1 State5=T State4=T State3=T State2=T State1=T State0=T
PORTE=0x40;
DDRE=0x40;

// Port F initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTF=0x00;
DDRF=0x00;

// Port G initialization
// Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State5=T State4=T State3=T State2=T State1=T State0=T
PORTG=0x00;
DDRG=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0A output: Disconnected
// OC0B output: Disconnected
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// OC1C output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
// Compare C Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
OCR1CH=0x00;
OCR1CL=0x00;
...}

after PORTF=0X00; command, the program stucks. when I press pause I getwhat is show in mem.jpg

thanks for help.

Attachment(s): 

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

I have no idea where or what your problem is.

You have not posted compilable code. So I cannot try it for myself. I assume from your post that you run-until line #65, and a subsequent single-step crashes.

I can see no reason for this at all. You are just writing the default values to regular GPIO ports.

If it is any help to you. Line #43 is:

// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In

David.

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

This may be unrelated to the OP's problem, but I see a similar thing with JTAG ICE2 since upgrading to 4.18 SP1. "Start Emulating" or "Build and Run" starts the target running at some arbitrary address, often in dead space. Break makes it stop, after thinking about it for a while, and pops up the disassembler screen. I have to close that screen, then reset, to get it back to address 0 in the proper source file so I can start things properly. It does this with old code that emulated perfectly before, so I believe there may be a bug in Studio 4.18, or maybe in the required JTAG ICE2 upgrade firmware.