Hi, A real silly problem. I am currently learning how to program this guy, ATMEL 89C51. I had a LED on Port 1 pin 0. 4MHz crystal with 30pF caps to ground, resent to ground, grounded the uC, 5v to Vcc. And the my program can't compile. ========== #include <AT89X51.H> #include <stdio.h> int main() { int x,led; sbit led = P1 ^ 0; while(1) { led = 1; for (x=0;x<10000;x++); ; led = 0; for (x=0;x<10000;x++); } return(0); } /* ..\test.C(7): error C141: syntax error near 'sbit' Target not created */ Someone tell me wats wrong? Do I have to configure the Ports ie. CWR? Like wat I have to do programming a 8255 PPI chip? Thank you, hengkc.geo@yahoo.com
Heng, Since you already have a led sbit declaration you don't need other variable with the same name. Your sbit declaration shoud be in a global area.
#include <reg51.h> #include <stdio.h> sbit led = P1 ^ 0; //compilation time definition, //it must be in the global area int main(void) { int x; while(1) { led = 1; for (x=0;x<10000;x++); led = 0; for (x=0;x<10000;x++); } return(0); }
Hi Alex, Thank you for your reply. I got the program to complie, but now a another problem. When I try to download into the uC, it prompts me Address out of range. I've seleceted the "Use on-chip ROM 0x0-0xFFF" option and everything could not complie again. ??? Thank you in advance, Heng
Maybe you're using a Demo version... The Demo version will start your code at C:0x4000.:
C:0x0000 024000 LJMP C:4000 C:0x3FFF 00 NOP C:0x4000 787F MOV R0,#0x7F ...