Hello. I am interfacing a 4x3 keypad with my 8-51 microcontroller. But i keep getting an this error:
temp.c(53): error C141: syntax error near '=' temp.c(55): error C141: syntax error near '='
Here's the code: Please help
#include <reg51.h>
sbit R1 = P1^0; sbit R2 = P1^1; sbit R3 = P1^2; sbit R4 = P1^3; sbit C1 = P1^4; sbit C2 = P1^5; sbit C3 = P1^6;
void main (void) { R1=1; R2=0; R3=0; R4=0; if (C1==1) {P0^0 = 1;} if (C2==1) {P0^1 = 1;} if (C3==1) {P0^2 = 1;}
R1=0; R2=1; R3=0; R4=0; if (C1==1) {P0^3 = 1;} if (C2==1) {P0^4 = 1;} if (C3==1) {P0^5 = 1;}
R1=0; R2=0; R3=1; R4=0; if (C1==1) {P0^6 = 1;} if (C2==1) {P0^7 = 1;} if (C3==1) {P2^0 = 1;}
R1=0; R2=0; R3=0; R4=1; if (C1==1) {P2^1 = 1;} if (C2==1) {P2^2 = 1;} if (C3==1) {P2^3 = 1;} }
When posting code PLEASE READ the posting notes so your code has some form. Highlight specific. line numbers
What on earth does
P0^0 = 1;
do, this isn't valid C syntax, and obviously the compile is going to reject it.
Quite a number of people jumps to the conclusion that Keil's extension to map bit variables to bits of the ports must mean that ^ can also be used inside functions to access individual bits.
When that assumption fails them, they don't take two steps back and reevaluates their assumption.
View all questions in Keil forum