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.

hi friends, can any one give some basic programs using AT89c2051

Status
Not open for further replies.

karthikeyan0758

Newbie level 1
Joined
Mar 5, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
some basic programs, so that i can know the syntax........
 

What do you mean by basic programs?
Basic as in BASIC?
or basic as in assembly like blink LED?
or basic as in C to blink an LED, debounce a switch etc?

for BASIC, download and install BASCOM AVR, there would be number of sample/examples in the install directory.
for C, download and install uVision for C51, there are tons of examples in the install directory as well.
 

I can give you some programs written in assembly. Most are interfacing progs written on 89s5x but should fit into the 2kb space of 2051.
 

Learn the controller and its instruction set and start yourself and post the problem here for help...... always do a search in google or in this forum and then ask for help......
 

this might help you
'---------------------------------------------------------------------------
' Description:
'
' Compiled by BASCOM 8051 Demo
'
' Home - MCS Electronics
'
'===========================================================================
$regfile = "REG51.DAT"
'---------------------------------------------------------------------------
' 7 Segment Pattern Data
Const Segpat0 = &B11000000 ' 0 ****A***
Const Segpat1 = &B11111001 ' 1 * *
Const Segpat2 = &B10100100 ' 2 F B
Const Segpat3 = &B10110000 ' 3 * *
Const Segpat4 = &B10011001 ' 4 ****G***
Const Segpat5 = &B10010010 ' 5 * *
Const Segpat6 = &B10000010 ' 6 E C
Const Segpat7 = &B11011000 ' 7 * *
Const Segpat8 = &B10000000 ' 8 ****D***
Const Segpat9 = &B10011000 ' 9
Const Segpblk = &B11111111 ' 10 BLANK
'---------------------------------------------------------------------------
Hour10 Alias P1.0
Led_am Alias P1.1
Led_pm Alias P1.2
Piezo Alias P1.3
Sw_alarm Alias P1.4
Sw_exit Alias P1.5
Sw_hour Alias P1.6
Sw_min Alias P1.7
'---------------------------------------------------------------------------
Dim Icount As Word
Dim Clock_cent As Byte
Dim Clock_second As Byte
Dim Clock_min As Byte
Dim Clock_hour As Byte
Dim Alarm_min As Byte
Dim Alarm_hour As Byte
Dim Data_min As Byte
Dim Data_hour As Byte
Dim Tempa As Byte
Dim Tempb As Byte
Dim Tempc As Byte
Dim Beep As Bit
Dim Dot_high As Bit
Dim Dot_low As Bit
Dim Dot_alarm As Bit
'===========================================================================
On Timer0 Timebase ' Timer0 Interrupt
'---------------------------------------------------------------------------
Config Timer0 = Timer , Gate = Internal , Mode = 2 ' Timer0 Auto Reload Timer Mode
Load Timer0 , 200 ' Auto Reload Constant 200 uSec
Start Timer0 ' Start Timer0
Enable Timer0 ' Enable Timer0
Enable Interrupts ' Enable All Interrupt
'===========================================================================
Icount = 0
Clock_cent = 0
Clock_second = 0
Clock_min = 0
Clock_hour = 0
Alarm_min = 0
Alarm_hour = 0
Beep = 0
Dot_alarm = 1
'---------------------------------------------------------------------------
Main_clock:
'
If Clock_cent > 99 Then
Clock_cent = 0
Incr Clock_second
End If
'
If Clock_second > 59 Then
Clock_second = 0
Incr Clock_min
End If
'
If Clock_min > 59 Then
Clock_min = 0
Incr Clock_hour
End If
'
If Clock_hour > 23 Then
Clock_hour = 0
End If
'
Data_min = Clock_min : Data_hour = Clock_hour
'
Gosub Dot_proc
Gosub Clock_disp
'
If Sw_alarm = 0 Then
Gosub Alarm_proc
End If
'
If Sw_min = 0 Then
Clock_second = 0
Incr Clock_min
If Clock_min > 59 Then
Clock_min = 0
End If
Waitms 100
End If
'
If Sw_hour = 0 Then
Incr Clock_hour
If Clock_hour > 23 Then
Clock_hour = 0
End If
Waitms 100
End If
'
If Dot_alarm = 0 Then
If Clock_hour = Alarm_hour Then
If Clock_min = Alarm_min Then
Set Beep
Else
Reset Beep
End If
Else
Reset Beep
End If
Else
Reset Beep
End If
'
Goto Main_clock
'===========================================================================
Clock_disp:
'
Tempa = Data_min Mod 10 : Gosub Patconv
If Dot_alarm = 0 Then
Tempb = Tempb And &H7F
End If
P3 = Tempb
'
Tempa = Data_min / 10 : Gosub Patconv
If Dot_high = 0 Then
Tempb = Tempb And &H7F
End If
P2 = Tempb
'
If Data_hour < 12 Then
Reset Led_am : Set Led_pm
Tempc = Data_hour
Else
Reset Led_pm : Set Led_am
Tempc = Data_hour - 12
End If
'
If Tempc = 0 Then
Tempc = 12
End If
'
Tempa = Tempc Mod 10 : Gosub Patconv
If Dot_low = 0 Then
Tempb = Tempb And &H7F
End If
P0 = Tempb
'
Tempa = Tempc / 10
'
If Tempa = 1 Then
Reset Hour10
Else
Set Hour10
End If
'
Return
'
'===========================================================================
Dot_proc:
'
If Clock_second < 30 Then
Reset Dot_low
If Clock_cent < 50 Then
Reset Dot_high
Else
Set Dot_high
End If
Else
Reset Dot_high
If Clock_cent < 50 Then
Reset Dot_low
Else
Set Dot_low
End If
End If
'
Return
'
'===========================================================================
Alarm_proc:
'
Set Dot_high : Set Dot_low
Data_min = Alarm_min : Data_hour = Alarm_hour
Gosub Clock_disp
Waitms 100
'
Alarm_loop:
Data_min = Alarm_min : Data_hour = Alarm_hour
Gosub Clock_disp
If Sw_min = 0 Then
Incr Alarm_min
If Alarm_min > 59 Then
Alarm_min = 0
End If
Waitms 50
End If
'
If Sw_hour = 0 Then
Incr Alarm_hour
If Alarm_hour > 23 Then
Alarm_hour = 0
End If
Waitms 50
End If
'
If Sw_alarm = 0 Then
Set Dot_alarm
Goto Alarm_ret
End If
'
If Sw_exit = 0 Then
Reset Dot_alarm
Goto Alarm_ret
End If
'
Goto Alarm_loop
'
Alarm_ret:
'
Waitms 500
'
Return
'===========================================================================
Patconv:
'
Tempa = Tempa And &H0F
Select Case Tempa
Case 0 : Tempb = Segpat0
Case 1 : Tempb = Segpat1
Case 2 : Tempb = Segpat2
Case 3 : Tempb = Segpat3
Case 4 : Tempb = Segpat4
Case 5 : Tempb = Segpat5
Case 6 : Tempb = Segpat6
Case 7 : Tempb = Segpat7
Case 8 : Tempb = Segpat8
Case 9 : Tempb = Segpat9
Case Else
End Select
'
Return
'===========================================================================
Timebase:
'
Incr Icount
'
If Icount > 49 Then ' 49
'
Icount = 0
Incr Clock_cent
End If
'
If Beep = 1 Then
If Piezo = 1 Then
Reset Piezo
Else
Set Piezo
End If
End If
'
Return
'---------------------------------------------------------------------------
'
'============================ END OF FILE ==================================
'
'
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top