- This topic has 2 replies, 3 voices, and was last updated 10 years, 3 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › 8051.h error in Keil, simple C blink-LED code
This may be a rediculously simple/obvious problem, but I have tried everything.
I’m trying to set up and test an 8051 development board. I’m using Keil uVision 4, with some code examples included with the dev board. The included hex file examples upload to the 8051 and work perfectly.
My problem is in Keil, when I try to build a new hex file from the C code, there is an error with the 8051.h library. I have placed the 8051.h file in the same folder as is holding the LED.c file, and where the hex file is stored.
Error text:
Here is the original blink LED code:
<code>
/**********
Blink LED
***********/
#include "8051.h"
sbit led=P2^0;
void delay(unsigned int time);
void main(void)
{
while(1)
{
led = led;
delay(40000);
delay(20000);
delay(20000);
delay(20000);
/*
led=1;
delay(20000);
led=0;
delay(20000);
*/
}
}
void delay(unsigned int time)
{
while(time--);
}
</code>
Do I have bad 8051.h files I’m testing, or what fix may be necessary to correct this? I have tried multiple 8051.h files and an STC_8051.h with the same problem. The examples were created in Keil uVision 3, I’m using 4 if that matters.
Any guidance appreciated.
Hi,
Are you sure you have the “8051.h” header file in the same folder where your main code is kept?
in keil just include reg51.h
why to include 8051.h externally?
just write
#include <reg51.h>