Debugging Atmel Studio在我的源文件之外执行指令

Debugging Atmel Studio在我的源文件之外执行指令,debugging,simulator,disassembly,atmel,program-counter,Debugging,Simulator,Disassembly,Atmel,Program Counter,我正在尝试使用Atmel Studio模拟器为ATMega8设备编写和调试一个C程序 例如,假设我正在调试这段代码: int main(void) { while(1) { SPI_transaction(0xFF); } } uint8_t SPI_transaction(unsigned char byte_to_send){ value = byte_to_send; SPDR = byte_to_send;

我正在尝试使用Atmel Studio模拟器为ATMega8设备编写和调试一个C程序

例如,假设我正在调试这段代码:

int main(void)
{
    while(1)
    {
        SPI_transaction(0xFF);
    }
}



uint8_t SPI_transaction(unsigned char byte_to_send){


    value = byte_to_send;   
    SPDR = byte_to_send;                        //Sends command
    while (checkBitStatus(SPSR,SPIF) == 0){};   //Do nothing until transfer is completed
    value = SPDR;                       //Receives command

    CLEARBIT(SPSR, SPIF);
    return value;

}

unsigned char checkBitStatus(unsigned char byte, unsigned char bit){

    unsigned char bit_status;

    if ((byte & (1 << bit)) == 0){

        bit_status = 0;
    }

    else{

        bit_status = 1;
    }

    return bit_status;
}
然后再次转到CheckBitStatus()函数

任何帮助都将不胜感激


Alex

在源代码之外执行的代码很可能是由atmel或c标准库处理的硬件中断的中断服务例程。对于必须异步处理的USB事件之类的事件,通常会发生这种情况。

调试器显示程序集视图和消息“找不到源文件”的另一个简单原因是,如果您试图在configuration manager(在构建中点击)设置了要发布的配置选项时使用调试器,程序编译将转到发布目录,而不是调试目录。

我在当前正在进行的特定项目中看到了一些非常类似的情况。您使用什么选项进行编译?
00000024  PUSH R28      Push register on stack 
00000025  PUSH R29      Push register on stack 
00000026  IN R28,0x3D       In from I/O location 
00000027  IN R29,0x3E       In from I/O location 
    SPI_transaction(0xFF);
00000028  SER R24       Set Register 
00000029  RCALL PC+0x0002       Relative call subroutine

    uint8_t SPI_transaction(unsigned char byte_to_send){
0000002B  PUSH R28      Push register on stack 
0000002C  PUSH R29      Push register on stack 
0000002D  PUSH R1       Push register on stack 
0000002E  IN R28,0x3D       In from I/O location 
0000002F  IN R29,0x3E       In from I/O location 
00000030  STD Y+1,R24       Store indirect with displacement 

while (checkBitStatus(SPSR,SPIF) == 0){};   //Do nothing until transfer is completed
00000039  NOP       No operation 
--- No source file -------------------------------------------------------------
0000003A  LDI R24,0x2E      Load immediate 
0000003B  LDI R25,0x00      Load immediate 
0000003C  MOVW R30,R24      Copy register pair 
--- No source file -------------------------------------------------------------
0000003D  LDD R24,Z+0       Load indirect with displacement 
0000003E  LDI R22,0x07      Load immediate 
0000003F  RCALL PC+0x0018       Relative call subroutine 

From that it jumps here:

    unsigned char checkBitStatus(unsigned char byte, unsigned char bit){
00000057  PUSH R28      Push register on stack 
00000058  PUSH R29      Push register on stack 
00000059  RCALL PC+0x0001       Relative call subroutine 
0000005A  PUSH R1       Push register on stack 
0000005B  IN R28,0x3D       In from I/O location 
0000005C  IN R29,0x3E       In from I/O location 
0000005D  STD Y+2,R24       Store indirect with displacement 
0000005E  STD Y+3,R22       Store indirect with displacement 
   if ((byte & (1 << bit)) == 0){
0000005F  LDD R24,Y+2       Load indirect with displacement 
00000060  MOV R24,R24       Copy register 
00000061  LDI R25,0x00      Load immediate 
00000062  LDD R18,Y+3       Load indirect with displacement 
00000063  MOV R18,R18       Copy register 
00000064  LDI R19,0x00      Load immediate 
00000065  MOV R0,R18        Copy register 
00000066  RJMP PC+0x0003        Relative jump 
00000067  ASR R25       Arithmetic shift right 
00000068  ROR R24       Rotate right through carry 
00000069  DEC R0        Decrement 
0000006A  BRPL PC-0x03      Branch if plus 
0000006B  ANDI R24,0x01     Logical AND with immediate 
0000006C  CLR R25       Clear Register 
0000006D  SBIW R24,0x00     Subtract immediate from word 
0000006E  BRNE PC+0x03      Branch if not equal 

            bit_status = 0;
0000006F  STD Y+1,R1        Store indirect with displacement 
00000070  RJMP PC+0x0003        Relative jump 
    bit_status = 1;
00000071  LDI R24,0x01      Load immediate 
00000072  STD Y+1,R24       Store indirect with displacement 
       return bit_status;
00000073  LDD R24,Y+1       Load indirect with displacement 
}
00000074  POP R0        Pop register from stack 
00000075  POP R0        Pop register from stack 
00000076  POP R0        Pop register from stack 
00000077  POP R29       Pop register from stack 
00000078  POP R28       Pop register from stack 
00000079  RET       Subroutine return 
--- No source file -------------------------------------------------------------
00000040  TST R24       Test for Zero or Minus 
00000041  BREQ PC-0x07      Branch if equal
0000003A  LDI R24,0x2E      Load immediate 
0000003B  LDI R25,0x00      Load immediate 
0000003C  MOVW R30,R24      Copy register pair 
0000003D  LDD R24,Z+0       Load indirect with displacement 
0000003E  LDI R22,0x07      Load immediate 
0000003F  RCALL PC+0x0018       Relative call subroutine