11/29/2013

EXAMPLE 04 : LCD 1602

 EXAMPLE_04.bas

$regfile = "89s8252.dat"
$crystal = 11059200
Dim I As Byte
Dim X As Byte
Dim A As String * 1

Config Lcdpin = Pin , Db4 = P0.4 , Db5 = P0.5 , Db6 = P0.6 , Db7 = P0.7 , E = P2.2 , Rs = P2.0,
Config Lcd = 16 * 2

P2.1 = 0
Lcdinit
Cursor Off

Do

 Part0:
 Cls
 Restore Db
 Lcd "   Welcome To"
  For I = 3 To 15
  Read A
  Locate 2 , I
  Lcd A
  Waitms 500
 Next I
 Wait 1


Part1:
 Cls
 Wait 1
 Lcd "BASCOM-8051"
 Lowerline
 Wait 1
 Lcd "     BASCOM-8051"
 Wait 1

Part2:
 Cls
 Locate 1 , 6
 Wait 1
 Lcd "BASCOM-8051"
 Locate 2 , 1
 Wait 1
 Lcd "BASCOM-8051"
 Wait 1

Part3:
 Cls
 Lcd "BASCOM-8051"
 Lowerline
 Lcd "BASCOM-8051"

 Shiftlcd Right
 Wait 1
 Shiftlcd Right
 Wait 1

 Shiftlcd Left
 Wait 1
 Shiftlcd Left
 Wait 1

Part4:
 For I = 1 To 20
  Cls
  X = 1 + Rnd(6)
  Locate 1 , X
  Lcd "BASCOM-8051"
  Waitms 500
  Cls

  X = 1 + Rnd(6)
  Locate 2 , X
  Lcd "BASCOM-8051"
  Waitms 500
 Next I

Loop


Db:
Data "B" , "A" , "S" , "C" , "O" , "M" , "-" , "8" , "0" , "5" , "1" , " " , "!"

End





3/29/2013

EXAMPLE 03 : 2 Digits 7 Segments LED


EXAMPLE_03.bas

$regfile = "89s8252.dat"
$crystal = 11592000
Dim I As Byte
Dim J As Byte
Dim C As Byte
Dim D As Byte
Dim Number(10) As Byte


Restore Db
  For I = 1 To 10
  Read Number(i)
  Next


Do

For I = 1 To 100
    C = I \ 10
    D = I Mod 10
      For J = 1 To 20

       P2.5 = 1
       P2.6 = 0
       If D = 0 Then D = 10
       P0 = Number(d)
       Waitms 5


       P2.5 = 0
       P2.6 = 1
       If C = 0 Then C = 10
       P0 = Number(c)
       Waitms 5


     Next
Next

Loop


End


Db:                                                           '1234567890
Data &HF9 , &HA4 , &HB0 , &H99 , &H92 , &H83 , &HF8 , &H80 , &H90 , &HC0



1/30/2013

EXAMPLE 02 : 7 Segments LED

EXAMPLE_02.bas

$regfile = "89s8252.dat"
$crystal = 11592000
Dim I As Byte
Dim Number(10) As Byte


Restore Db
  For I = 1 To 10
  Read Number(i)
  Next

Do
 For I = 1 To 10
 P0 = Number(i)
 Waitms 200
 Next
Loop

End



Db:                                                                                                             '1234567890
Data &HF9 , &HA4 , &HB0 , &H99 , &H92 , &H83 , &HF8 , &H80 , &H98 , &HC0 



1/27/2013

EXAMPLE 01 : Flowing Water LED


EXAMPLE_01.bas

$regfile = "89s8252.dat"
$crystal = 12000000

Do
'=====================
 P0 = &B11111110
 Waitms 100
 P0 = &B11111101
 Waitms 100
 P0 = &B11111011
 Waitms 100
 P0 = &B11110111
 Waitms 100
 P0 = &B11101111
 Waitms 100
 P0 = &B11011111
 Waitms 100
 P0 = &B10111111
 Waitms 100
 P0 = &B01111111
 Waitms 100
'==========================
 P0 = &B10111111
 Waitms 100
 P0 = &B11011111
 Waitms 100
 P0 = &B11101111
 Waitms 100
 P0 = &B11110111
 Waitms 100
 P0 = &B11111011
 Waitms 100
 P0 = &B11111101
 Waitms 100
Loop

End 



EXAMPLE_01a.bas 


$regfile = "89s8252.dat"
$crystal = 12000000
Dim A As Byte
Dim I As Byte

A = &B11111110

Do
 For I = 1 To 7
  P0 = A
  Wait 1
  Rotate A , Left , 1
Next

 For I = 1 To 7
  P0 = A
  Wait 1
  Rotate A , Right , 1
 next
Loop

End




EXAMPLE 00 : Stared From Flash LED

EXAMPLE_00.bas

$regfile = "89s8252.dat"
$crystal = 12000000

Do
  P1.0 = 0
  Wait 1
  P1.0 = 1
  Wait 1
Loop

End





1/26/2013

AT89S52 Pin Configurations



Features
• Compatible with MCS®-51 Products
• 8K Bytes of In-System Programmable (ISP) Flash Memory
   – Endurance: 10,000 Write/Erase Cycles
• 4.0V to 5.5V Operating Range
• Fully Static Operation: 0 Hz to 33 MHz
• Three-level Program Memory Lock
• 256 x 8-bit Internal RAM
• 32 Programmable I/O Lines
• Three 16-bit Timer/Counters
• Eight Interrupt Sources
• Full Duplex UART Serial Channel
• Low-power Idle and Power-down Modes
• Interrupt Recovery from Power-down Mode
• Watchdog Timer
• Dual Data Pointer
• Power-off Flag
• Fast Programming Time
• Flexible ISP Programming (Byte and Page Mode)
• Green (Pb/Halide-free) Packaging Option