C语言 无法解析标识符RBIE和RBIF,您猜对了吗?

hts6caw3  于 2023-04-19  发布在  其他
关注(0)|答案(1)|浏览(182)

试图编译一个代码,但不断给予建设失败,并检查红色标志只显示无法解决标识符在RBIE和RBIF。下面是代码,我有即时通讯使用它与pic18f45k50与液晶显示器和4x4键盘尝试互联网,但只显示RBIE功能,这一切和我的老师是没有太大的帮助,所以我自己的即时通讯。

#include <xc.h>
#include <stdio.h>
#include <String.h>

#pragma config FOSC = INTOSC_HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#define _XTAL_FREQ 8000000

#define time 10
#define CD 0x01
#define RH 0x02
#define EMS 0x06
#define DC 0x0F
#define DSr 0x1C
#define DSl 0x18
#define FS 0x38
#define RAW1 0x80
#define RAW2 0xC0
#define E LATEbits.LATE0
#define RS LATEbits.LATE1
void settings(void);
void __interrupt() KB(void);
int keyboard(void);
void entrada(void);
void calculo(void);
void dataLCD(void);
void settingsLCD(unsigned char word);
void LCD(unsigned char data);
void writeLCD(unsigned char word);
int i, j, key, keys[4][4] = {
 {7, 8, 9, 15},
 {4, 5, 6, 14},
 {1, 2, 3, 13},
 {10, 0, 11, 12}
};
float numa, numb, operacion, igual, k=0, resultado;
char text[12], text2[12] = {"R= "};
void main(void){
 settings();
 while(1){
 }
}
void settings(void){
 OSCCON = 0X72;
 ADCON1 = 0x0F;
 TRISD = 0;
 LATD = 0;
 TRISE = 0;
 LATE = 0;
 TRISB = 0xF0;
 LATB = 0x0F;
 GIE = 1;
 RBIE = 1;
 RBIF = 0;
 settingsLCD(CD);
 settingsLCD(EMS);
 settingsLCD(DC);
 settingsLCD(FS);
 dataLCD();
}
void settingsLCD(unsigned char word){
 RS = 0;
 LCD(word);
}
void LCD(unsigned char data){
 E = 1; __delay_ms(time);
 LATD = data;
 __delay_ms(time);
 E = 0;
}
void __interrupt() KB(void){
 if (RBIF){
 if ((PORTB & 0xF0) != 0){
 k++;
 calculo();
 if (key == 11 || key == 10) {
 settingsLCD(RAW1 + 11);
 sprintf(text,"%.2f", resultado);
 for (i = 0; i <= strlen(text); i++){
 writeLCD(text[i]); // CAMBIO
 __delay_ms(time);
 }
 }
 LATB = 0xF;
 }
 RBIF = 0;
 }
}
int keyboard(void){
 LATB = 0x01;
 for(i = 0; i <= 3; i++){ //CAMBIO
 if (PORTBbits.RB4){
 j = 0;
 break;
 } else if (PORTBbits.RB5){
 j = 1;
 break;
 } else if (PORTBbits.RB6){
 j = 2;
 break;
 }else if (PORTBbits.RB7){
 j = 3; break;
 }
 LATB = LATB << 1;
 }
 return keys[i][j]; //CAMBIO
}
void entrada(void){
 key = keyboard();
 if (k == 1){
 numa = key;
 } else if (k == 2){
 operacion = key;
 }else if (k == 3){
 numb = key;
 } else if (k == 4){
 igual = k;
 k= 0;
 }
}
void calculo(void){
 entrada();
 if(operacion == 15){
 resultado = numa / numb;
 } else if (operacion == 14){
 resultado = numa * numb;
 } else if (operacion == 13){
 resultado = numa - numb;
 } else if (operacion == 12){
 resultado = numa + numb;
 }
}
void dataLCD(void){
 settingsLCD(RAW1);
 for (i = 0; i<= strlen(text2); i++){
 writeLCD(text2[i]);
 __delay_ms(time);
 }}
void writeLCD(unsigned char word){
 RS = 1;
 LCD(word);
}
#pragma config DEBUG = ON
#pragma config F0SC = INT0SCI0
#pragma config WDTEN = OFF
#pragma config LVP = ON
#pragma config ICPRT = OFF
9njqaruj

9njqaruj1#

这些钻头没有植入!
PORTB<7:4>PORTC<2:0>上的输入变化设置INTCON寄存器的标志位IOCIF。可以通过设置/清除INTCON寄存器的使能位IOCIE来使能/禁用中断。还必须使用IOCB/IOCC寄存器单独使能引脚。
参见数据表第10.11节。
所以你不能使用RBIF标志,而是使用IOCIFRBIE标志也是一样,应该用IOCIE代替。

相关问题