【发布时间】:2021-02-26 10:22:58
【问题描述】:
这是我正在尝试构建的伪代码(ish)。
这是中断函数。按下开关 2 时,potval = 1。按下开关 3 时,potval = 2。每按下开关,potval 都会更新。
void interruptJ_function (void){ //if i change to int interruptJ_function, it says that it was expecting a void function
if(Pim.pifj.byte & 0x01) { //switch2 is pressed
potval = 1;
Pim.pifj.byte |= 0x01; //clear interrupt bit
//return potval; //doing this says the result is returned in void-result-function
}
else if(Pim.pifj.byte & 0x02) { //switch 3 is pressed
potval = 2;
Pim.pifj.byte |= 0x02; //clear interrupt bit
//return potval;
}
//return potval;
}
这是 main.c。
int potval;
unsigned int i;
void main ()
{
adt(potval); //Warning: Result of function call is ignored
for (;;); //recurring loop until interrupt initiated
}
int adt(int potval, unsigned int i) {
if(potval == 1){
//for (;;){
while(potval==1){ //breaks when potval =2
i= Atd0.atddr[0].d10; //ATD bits
light7segment(i); // ATD changes number on 7segment display
m_delay(50);
}
}
else if (potval == 2){
light7segment(10); //ATD turns off 7segment display
}
}
【问题讨论】:
-
试试这个教程:raywenderlich.com/…
-
However, its keep saying "result of function call is ignored" on CodeWarrior.和extern int 变量有什么关系并共享它?你是在问一些 XY 问题吗? -
您是否尝试过谷歌搜索,字面意思是“XY 问题”? google.com/search?q=XY+question
-
CodeWarrior 肯定会将诊断与特定的源代码行相关联吗?
-
还有:诊断与共享变量有什么关系?
标签: c extern microprocessors