如何在Atmel Studio中使用调试器来使用scanf?

问题描述 投票:0回答:1

当我逐行调试程序直到达到scanf语句时,IDE会打开一个Disassembly选项卡,它不会以任何方式改善这种情况。一旦调试程序到达scanf语句,如何在程序中输入密钥???

码:

#include <avr/io.h>
#include <stdio.h>

int main(void)
{
    DDRA = 0x00; //PORTA = 0x00;
    DDRB = 0xFF; //PORTB = 0x00;

    typedef enum {
        firstkey,
        secondkey,
        dooropens,
        }doorstate;

    doorstate state = firstkey;
    char secretkey;
    while (1) 
    {
        switch(state) 
        {
            case firstkey:
                scanf("%c", secretkey); //?????
                if (secretkey == '#')  {
                    PORTA == 0x01 << 3;
                    state = secondkey; 
                }
                else 
                    state = firstkey;  
                break;
            case secondkey:
                scanf("%c", secretkey);//?????
                if (secretkey == 'Y')  {
                    PORTA = PORTA | 0x02;
                    state = dooropens;
                }
                else 
                    state = firstkey;  
                break; 
            case dooropens:
                PORTB = 0x01;
                if (PORTA == 0x80) {
                    state = firstkey;
                    PORTB = 0x00;
                }
                break;
            default:
                state = firstkey;
        }
    }
}
c debugging embedded scanf atmelstudio
1个回答
0
投票

反汇编可能是因为你正在踩踏库函数而不是它。在这种情况下,库函数源不可用于调试器,因此除了向您显示程序集之外别无选择。

使用步进,函数将正常运行并接受输入和控制将在函数返回后返回调试器。

© www.soinside.com 2019 - 2024. All rights reserved.