We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi i wrote the code below for a T89C51CC01 atmel's controller.When i tried to build it, it gives the following error message:(Build target 'Target 1' compiling xixi.c... XIXI.C(7): error C231: 'P1': redefinition XIXI.C(8): error C231: 'P3': redefinition Target not created) These errors are caused by the 2 first lines after the include statements(sfr P1 = 0x90; sfr P3 = 0xB0;) Can anyone help me? The code: #include <absacc.h> #include <string.h> #include <stdio.h> #include <REG51CC01.H> sfr P1 = 0x90; sfr P3 = 0xB0; sbit DIPswitch = P1^4; sbit greenLED = P1^5; void main (void) { unsigned char inval; inval = 0; // initial value for inval while (1) { if (DIPswitch == 1) { // check if input P1.4 is high inval = P1 & 0x0F; // read bit 0 .. 3 from P1 greenLED = 0; // set output P1.5 to low } else { // if input P1.4 is low greenLED = 1; // set output P1.5 to high } P3 = (P3 & 0xF0) | inval; // output inval to P3.0 .. P3.3 } }
Don't get me wrong - there's nothing wrong with not knowing these things per se, but we need to know your level of understanding to be able to give answers that you can understand!