Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] [Moved] My first program for LED Blinking

Status
Not open for further replies.

maxim10373

Advanced Member level 4
Joined
Feb 26, 2010
Messages
115
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Activity points
2,063
I am trying to make a program for AT89c2051 LED blinking.
I download a sample program I attaching here.I used MIDE
Studio.I pasted the C program on new window and save
.asm mode.but there are more than 48 errors showing.
please help me for making a true program

Maxim.

Sample c
----------------------------------------------------------------------------
Test your board with myfirst.c, a simple c program
that makes LED blink every 0.5 second.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* 
           * myfirst.c 
           * First C program for 2051 experiment 
           * complement P1.7 every 0.5 sec 
           * Copyright (C) 1999 Wichit Sirichote 
           * compiled with Dunfield Micro-C for 8051 Release 3.2
           */ 
 
#include c:\mc\8051io.h /* include i/o header file */
           #include c:\mc\8051reg.h 
 
extern register char cputick; 
// cputick was incremented every 10ms            
   register unsigned char sec100,flag1; 
 
#define n 50 
 
task1(); // functions declarations 
           task2(); 
 
main() 
{ 
 flag1 = 0; 
 sec100 = 0; 
 serinit(9600); // set timer0 to be 16 bit counter 
 while(1){ 
 
 while(cputick == 0) 
 ; 
 cputick = 0; 
 task1(); 
 task2(); 
 } 
} 
 
task1() // set bit 0 of flag1 every n*10ms 
{ 
 sec100++; // increment sec100 
 if (sec100 >= n) 
 {sec100 = 0; // clear sec100 
 flag1 |= 0x01; // set bit 0 of flag1 
 } 
} 
 
task2() 
{ 
 if ((flag1 & 0x01) != 0) // execute below if bit 0 of flag1 is set
{ 
  // P1 ^= 0x80; // exclusive or the latch bit 7 with 0x80 
  asm " CPL P1.7"; // complement P1.7 
  flag1 &= ~0x01; // clear bit 0 of flag1 
 } 
}

 
Last edited by a moderator:

The error is of Header file.
Go through the below link, check the section of header files in it and download the file reg2051.h at where your set up files of the software is.
https://www.keil.com/dd/chip/2984.htm

If it doesn't work then post your errors here.
 
Sir,
It's Done!!

Thanks a lot


Ajitkumar
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top