This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Redefinition

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
}
}

Parents
  • Hello David,

    within the header file for your target (e.g. REG51CC01.H) all sfr's are defined. You can either include this header or define the used sfr's in your code, but never try both. I recommend to use the header file after you have checked it, because sometimes the names for the registers are different from those used in the manuals for the target device.

    Tim

Reply
  • Hello David,

    within the header file for your target (e.g. REG51CC01.H) all sfr's are defined. You can either include this header or define the used sfr's in your code, but never try both. I recommend to use the header file after you have checked it, because sometimes the names for the registers are different from those used in the manuals for the target device.

    Tim

Children