[英]How can I use scanf using the debugger in Atmel Studio?
當我逐行調試程序直到達到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;
}
}
}
拆卸可能是因為你正在步入而不是在庫函數。 在這種情況下,庫函數源不可用於調試器,因此除了向您顯示程序集之外別無選擇。
使用步進,函數將正常運行並接受輸入和控制將在函數返回后返回調試器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.