|
89C51 programmingNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Heng KC Posted 5-Sep-2001 09:32 Toolset C51 |  89C51 programming Heng KC 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 | | Read-Only Author Alex Ruiz Posted 6-Sep-2001 08:15 Toolset C51 |  RE: 89C51 programming Alex Ruiz 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);
}
This should work... | | Read-Only Author Heng Kc Posted 6-Sep-2001 22:33 Toolset C51 |  RE: 89C51 programming Heng Kc 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 | | Read-Only Author Alex Ruiz Posted 7-Sep-2001 08:17 Toolset C51 |  RE: 89C51 programming Alex Ruiz 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
...
Starting at 0x4000 your on chip ROM won't fit.
| |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|