|
INSTRUCTIONS
|
RS
|
R/W
|
DB7
|
DB6
|
DB5
|
DB4
|
DB3
|
DB2
|
DB1
|
DB0
|
DESCRIPTION
|
|
Clear display
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
Clear entire display
|
|
Return Home
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
-
|
Returns display to be shifted to original position
|
|
Entry mode set
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
1/D
|
S
|
Sets cursor move direction and specifies shift of
display. Performed during data write and read
|
|
Display On/Off control
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
D
|
C
|
B
|
D – sets on off entire display.
C – cursor on off
B – blink of cursor position character
|
|
Cursor or display shift
|
0
|
0
|
0
|
0
|
0
|
1
|
S/C
|
R/L
|
-
|
-
|
Moves cursor and shifts display without changing DD RAM
contents.
|
|
Function set
|
0
|
0
|
0
|
0
|
1
|
DL
|
N
|
F
|
-
|
-
|
DL – sets interface data length
L – number of display lines
F – character font
|
|
Set CG RAM Address
|
0
|
0
|
0
|
1
|
|
AGC
|
|
|
|
|
Sets CG RAM address. CG RAM data is sent and received after
this setting
|
|
Set DD RAM Address
|
0
|
0
|
1
|
|
|
ADD
|
|
|
|
|
Sets DD RAM address. DD RAM address is sent and received after this
setting
|
|
Read Busy Flag and address
|
0
|
1
|
BF
|
|
|
AC
|
|
|
|
|
Reads Busy Flag BF indicating internal operation is being
performed and reads address counter contents
|
|
Write data CG RAM or DD RAM
|
1
|
0
|
WRITE DATA
|
Writes data into DD or CG RAM
|
|||||||
|
Read data CG RAM or DD RAM
|
1
|
1
|
READ DATA
|
Reads data from DD or CG RAM
|
|||||||
The blog talks about variety of topics on Embedded System, 8085 microprocessor, 8051 microcontroller, ARM Architecture, C2000 Architecture, C28x, AVR and many many more. Also includes some projects that have been worked upon and also episodes to Embedded System Podcast.
Search This Blog
Wednesday, November 2, 2011
LCD instruction in detail
Tuesday, October 18, 2011
Simple LCD interfacing program with 8051 microcontroller
so we have three control pins to take care of.
so lets program using these 3 control pins.
; P2.0 EQU RS
; P2.1 EQU RW
; P2.2 EQU E
ORG 0000H ;
MOV A, #38H ; INITIATE LCD
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #0EH ; DISPLAY ON CURSOR ON
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #01H ; CLEAR LCD
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #84H ; CURSOR AT LINE 1 POSITION 4
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #'A' ; SEND ASCII DATA
ACALL DATAWRT ;
ACALL DELAY ;
AGAIN :
SJMP AGAIN ;
COMMWRT:
MOV P1, A ;
CLR P2.0 ; RS = 0 FOR COMMAND REGISTER
CLR P2.1 ; R/W = 0 FOR WRITE
SETB P2.2 ; E = 1 FOR HIGH PULSE
ACALL DELAY ;
CLR P2.2 ; E = 0 FOR LOW PULSE
RET
DATAWRT:
MOV P1, A ;
SETB P2.0 ; RS = 1 FOR DATA REGISTER
CLR P2.1 ; R/W = 0 FOR WRITE
SETB P2.2 ; E = 1 FOR HIGH PULSE
ACALL DELAY ;
CLR P2.2 ; E = 0 FOR LOW PULSE
RET
so lets program using these 3 control pins.
; P2.0 EQU RS
; P2.1 EQU RW
; P2.2 EQU E
ORG 0000H ;
MOV A, #38H ; INITIATE LCD
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #0EH ; DISPLAY ON CURSOR ON
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #01H ; CLEAR LCD
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #84H ; CURSOR AT LINE 1 POSITION 4
ACALL COMMWRT ;
ACALL DELAY ;
MOV A, #'A' ; SEND ASCII DATA
ACALL DATAWRT ;
ACALL DELAY ;
AGAIN :
SJMP AGAIN ;
COMMWRT:
MOV P1, A ;
CLR P2.0 ; RS = 0 FOR COMMAND REGISTER
CLR P2.1 ; R/W = 0 FOR WRITE
SETB P2.2 ; E = 1 FOR HIGH PULSE
ACALL DELAY ;
CLR P2.2 ; E = 0 FOR LOW PULSE
RET
DATAWRT:
MOV P1, A ;
SETB P2.0 ; RS = 1 FOR DATA REGISTER
CLR P2.1 ; R/W = 0 FOR WRITE
SETB P2.2 ; E = 1 FOR HIGH PULSE
ACALL DELAY ;
CLR P2.2 ; E = 0 FOR LOW PULSE
RET
DELAY :
MOV R3, #50H ;
BACK:
MOV R4, #255H ;
HERE:
DJNZ R4, HERE ;
DJNZ R3, BACK ;
RET
END
Terms used in LCD
|
Terms used in LCD
|
display data RAM
|
|
DD RAM
|
display data RAM
|
|
CG RAM
|
character generator RAM
|
|
ACC
|
CG RAM address
|
|
ADD
|
DD RAM address corresponding to cursor address
|
|
AC
|
address counter used for both CG and DD
|
|
1/D = 1 for increment
|
1/D = 0 for decrement
|
|
S = 1 accompanies display shift
|
|
|
S/C = 1 display shift
|
S/C = 0 for cursor shift
|
|
R/L = 1 shift to right
|
R/L = 0 shift to left
|
|
DL = 1 8 bits
|
DL = 0 4 bits
|
|
F = 1 5x10 dots
|
F = 0 5x7 dots
|
|
BF = 1 Internal operation
|
BF = 0 can accept instruction
|
Programming LCD (basics)
Few Points for programming LCD.
>> Rs register select pin.
If RS = 0 command code register is selected or opened allowing user to send commands.
If RS = 1 data register is selected or opened allowing user to send data.
>> As LCD runs on a lower clock speed therefore proper DELAY should be provided after every command write and data write.
Usually a 255D delay is more than enough.
>> Enable pin. E. when data is supplied to data pins a high to low pulse must be applied to pin in order to latch data to
LCD pin. This must be a minimum of 450nS wide.
Steps to send command and data.
38h initialize LCD
0Eh display on cursor on.
01h clear LCD
06h shift cursor right
84h position the cursor.
now send data.
>> Rs register select pin.
If RS = 0 command code register is selected or opened allowing user to send commands.
If RS = 1 data register is selected or opened allowing user to send data.
>> As LCD runs on a lower clock speed therefore proper DELAY should be provided after every command write and data write.
Usually a 255D delay is more than enough.
>> Enable pin. E. when data is supplied to data pins a high to low pulse must be applied to pin in order to latch data to
LCD pin. This must be a minimum of 450nS wide.
Steps to send command and data.
38h initialize LCD
0Eh display on cursor on.
01h clear LCD
06h shift cursor right
84h position the cursor.
now send data.
for LCD program see the next post
Friday, September 23, 2011
List of LCD instructions(ultra short)
Clear display
Return home
Entry mode set
Display On/off control
Cursor or Display shift
Function set
Set CG RAM address( CG = Character generator)
Set DD RAM address( DD = Display Data)
Read busy flag(BF) and address
Write data CG or DD RAM
Read data CG or DD RAM.
Return home
Entry mode set
Display On/off control
Cursor or Display shift
Function set
Set CG RAM address( CG = Character generator)
Set DD RAM address( DD = Display Data)
Read busy flag(BF) and address
Write data CG or DD RAM
Read data CG or DD RAM.
For further details of LCD stay connected.
MOVX dest-byte, source-byte
It moves external memory.
No flags are afffected.
This transfers data between external memory and register A.
this allows us to access external memory connected to the controller.
The address of external memory access can be either 8 bit or 16 bit.
For 16 bit
use DPTR.
like
MOVX A, @DPTR ;
moves data from external memory stored at address DPTR to accumulator.
External data is moved into the CPU.
MOVX @DPTR, A ;
moves data from Aaccumulator to address stored at DPTR.
data is moved from CPU to external memory.
For 8 bit
use R0 or R1 register.
like
MOVX A, @Ri ; WHERE i IS 0 OR 1
moves data from external memory stored at address Ri to accumulator.
External data is moved into the CPU.
MOVX @Ri, A ; WHERE i IS 0 OR 1
moves data from Aaccumulator to address stored at Ri.
data is moved from CPU to external memory.
The 16 bit is used for accessing external memory whereas 8 bit is used for accessing external I/O ports.
No flags are afffected.
This transfers data between external memory and register A.
this allows us to access external memory connected to the controller.
The address of external memory access can be either 8 bit or 16 bit.
For 16 bit
use DPTR.
like
MOVX A, @DPTR ;
moves data from external memory stored at address DPTR to accumulator.
External data is moved into the CPU.
MOVX @DPTR, A ;
moves data from Aaccumulator to address stored at DPTR.
data is moved from CPU to external memory.
For 8 bit
use R0 or R1 register.
like
MOVX A, @Ri ; WHERE i IS 0 OR 1
moves data from external memory stored at address Ri to accumulator.
External data is moved into the CPU.
MOVX @Ri, A ; WHERE i IS 0 OR 1
moves data from Aaccumulator to address stored at Ri.
data is moved from CPU to external memory.
The 16 bit is used for accessing external memory whereas 8 bit is used for accessing external I/O ports.
MOVC A, @A+DPTR
It moves code byte.
No flags are affected
This moves a byte of data located in program code ROM into Accumulator A.
This allows to create a lookup table of sorts in code space and read them into CPU.
The address of the desired byte in code space is formed by adding A + DPTR
Example:
ORG 0000
MOV DPTR, #200H ;
LOOP : CLR A ;
MOVC A,@A+DPTR ; MOVE DATA @A+DPTR IN A
JZ EXIT ;
MOV P1, A ;
INC DPTR ;
SJMP LOOP ;
EXIT :
-----
-----
ORG 200H
DB 'A','B','C',0;
END
another example can be finding square or square root of numbers.
This is strictly used for on chip ROM. for off chip memory we use MOVX.
MOVC A, @A+PC
It moves code byte.
No flags are affected
Same as above instruction inly difference is that the PC is used instead of DPTR.
Example:
MOV A, R3 ;
INC A ;
MOVC A, @A+PC ;
RET
DB 0,1,4,9,16,25;
The following should be noted:
The program counter, which is pointing to the RET is taken for addition.
Always remember that always the next code value is taken in PC before adding to Accumulator A.
This method is preferrable over "MOVC A, @A+DPTR" when we do not want to divide the program code space into 2 separate
areas of code and data. As a result we save considerable amount of space on chip
No flags are affected
This moves a byte of data located in program code ROM into Accumulator A.
This allows to create a lookup table of sorts in code space and read them into CPU.
The address of the desired byte in code space is formed by adding A + DPTR
Example:
ORG 0000
MOV DPTR, #200H ;
LOOP : CLR A ;
MOVC A,@A+DPTR ; MOVE DATA @A+DPTR IN A
JZ EXIT ;
MOV P1, A ;
INC DPTR ;
SJMP LOOP ;
EXIT :
-----
-----
ORG 200H
DB 'A','B','C',0;
END
another example can be finding square or square root of numbers.
This is strictly used for on chip ROM. for off chip memory we use MOVX.
MOVC A, @A+PC
It moves code byte.
No flags are affected
Same as above instruction inly difference is that the PC is used instead of DPTR.
Example:
MOV A, R3 ;
INC A ;
MOVC A, @A+PC ;
RET
DB 0,1,4,9,16,25;
The following should be noted:
The program counter, which is pointing to the RET is taken for addition.
Always remember that always the next code value is taken in PC before adding to Accumulator A.
This method is preferrable over "MOVC A, @A+DPTR" when we do not want to divide the program code space into 2 separate
areas of code and data. As a result we save considerable amount of space on chip
Differentiate between ADDC and SUBB
ADDC
Does addition with carry
changes OV, AC, CY flags
This does A = A + byte + CY
used in multibyte addition
example
addition of 3456H and 2345H
CLR C ;CY =0
MOV A, #56H ;
ADDC A, #45H ;
MOV R7, A ; STORE LOWER BYTE IN R7
MOV A, #34H ;
ADDC A, #23H ; UPPER BYTE
Result = 3456 + 2345 = 579B
Addressing modes
Immediate: ADDC A, #data
Register: ADDC A, Rn
Direct: ADDC A, 30H
Register-Indirect: ADDC A, @R0
ADDC A, @R1
SUBB
Does subtraction with borrow
Changes OV, Ac, CY flags
This subtracts source byte and carry flag from accumulator and puts result in accumulator.
The steps for subtraction:
Take 2's complement
Add to A
Invert carry.
CY
dest>source 0 result is positive
dest=source 0 result is 0
dest<source 1 result is negative in 2's complement
No SUB instruction in 8051
A = A - byte - CY
example:
MOV A, #45H
CLR C
SUBB A, #23H
Result 22H
Addressing modes
Immediate: SUBB A, #data
Register: SUBB A, Rn
Direct: SUBB A, 30H
Register-Indirect: SUBB A, @R0
SUBB A, @R1
Does addition with carry
changes OV, AC, CY flags
This does A = A + byte + CY
used in multibyte addition
example
addition of 3456H and 2345H
CLR C ;CY =0
MOV A, #56H ;
ADDC A, #45H ;
MOV R7, A ; STORE LOWER BYTE IN R7
MOV A, #34H ;
ADDC A, #23H ; UPPER BYTE
Result = 3456 + 2345 = 579B
Addressing modes
Immediate: ADDC A, #data
Register: ADDC A, Rn
Direct: ADDC A, 30H
Register-Indirect: ADDC A, @R0
ADDC A, @R1
SUBB
Does subtraction with borrow
Changes OV, Ac, CY flags
This subtracts source byte and carry flag from accumulator and puts result in accumulator.
The steps for subtraction:
Take 2's complement
Add to A
Invert carry.
CY
dest>source 0 result is positive
dest=source 0 result is 0
dest<source 1 result is negative in 2's complement
No SUB instruction in 8051
A = A - byte - CY
example:
MOV A, #45H
CLR C
SUBB A, #23H
Result 22H
Addressing modes
Immediate: SUBB A, #data
Register: SUBB A, Rn
Direct: SUBB A, 30H
Register-Indirect: SUBB A, @R0
SUBB A, @R1
Thursday, September 1, 2011
Atmel Product Based 8051 Architecture
Flash ISP single Core
The
Atmel® AT89LP family takes 8051 microcontroller power to a new
level. These high performance 8-bit microcontrollers execute most instructions
in a single clock cycle, compared to 12 clock cycles in the classic 8051 CPU.
At the same MIPS throughput as the classic 8051, existing applications can use
a much lower clock frequency, enabling power consumption reduction by up to 80
percent. Application performance can be boosted up to 20 MIPS throughput 12
times faster than the traditional 8051 core.
For
example AT89LP214, AT89LP215, AT89LP216 etc, etc.
Flash ISP (In system Programmable)
Atmel
offers a variety of high performance Flash 8051 microcontrollers featuring
in-system programming (ISP). Their integrated Flash memory can be programmed
either in parallel mode or in serial mode with the appropriate parallel/ISP
software, respectively.
They
feature a wide range of internal RAM configurations, plus rich features such as
interrupt controllers and timer/counters. Select models feature an A/D
converter, Boot Flash memory, and Programmable Counter Arrays. Their highly
efficient design can help reduce system power consumption by bringing the clock
frequency down to any value — even DC — without loss of data.
Software-selectable
modes of reduced activity and an 8 bit clock prescaler can further control
power consumption.
The
rich functionality and efficiency of Atmel 8051 Flash ISP microcontrollers make
them ideal for applications that need A/D conversion, pulse width modulation,
high speed I/O and counting capabilities such as industrial control, consumer
goods, alarms, motor control, and more.
For
example AT89C5115, AT89LS , AT89S series.
Flash Reprogrammable
Atmel
offers several 8051 reprogrammable Flash microcontrollers that can support a
variety of embedded applications. For example, the AT89C4051 is a low-voltage,
high-performance CMOS 8-bit microcontroller with 4K bytes of Flash programmable
and erasable read-only memory. The device is manufactured using Atmel's
high-density nonvolatile memory technology and is compatible with the
industry-standard MCS-51 instruction set.
For
Example AT89C2051, AT89C5051 etc.
CAN Networking MCU'S
Introduced
in 1986, Controller Area Network (CAN) technology was originally intended for
automotive engine control communication. It has rapidly gained popularity to
support a wide range of growing applications, including medical devices,
avionics, factory and industrial automation, and maritime environments.
Atmel
is well positioned to support CAN networking with a broad portfolio of 8051
microcontroller flash technology, together with extensive experience in CAN
networking.
For
example, the AT89C51CC01, AT89C51CC02, AT89C51CC03 deliver 5 MIPS at 5V, and
16KBytes to 64KBytes Flash. They can support a wide range of slave applications
such as proximity sensor, DeviceNet I/O, textile machine I/O, and many other
applications.
For
low voltage applications, the following controllers maintain up to 3.3MIPS down
to 2.7 volts.
The
AT89C51CC02 with 16Kbytes Flash and 0.5Kbytes RAM + a simple 4 message objects
CAN engine packaged into a Small Pin Count package is excellent for low end
applications where a minimum DeviceNet or CANopen slave stacks are used. It is
an ideal low cost product for a CAN controller push-button.
The
AT89C51CC01 features 32Kbytes Flash and 1.2 Kbytes RAM, and is well-positioned
for slave applications. It offers 2 Kbytes of Boot flash, with at least 3 MIPS
remaining for the application on top of a CANopen or DeviceNet stack. The chip
features an 8 channel 10 bit A/D converter, 3 timers, a 5-channel high speed
input/output timer units, and 32 I/Os. Its 15 message objects and the 1.2Kbytes
RAM make the chip suitable for complex I/O systems.
The
AT89C51CC03 provides 64Kbytes Flash for application programs and 2Kbytes RAM
for a larger object Dictionary. The built-in SPI port also assists
communication with other devices. It features 15 message objects as well as
2Kbytes Bootloader and 2Kbytes EEPROM.
USB MCU'S
Built
for today's increasingly connected applications, Atmel 8051 USB
microcontrollers offer powerful interface options that are ideal for devices
like Flash recorders, cameras, and cell phones. The AT89C5131A, a popular
device in this series, offers an efficient combination of features and
performance. It combines 32K bytes of Flash memory, 1.2K bytes RAM, 1K EEPROM,
7 USB Endpoints, TWI, SPI, UART, and Programmable Counter Array (PCA).
The
AT89C5132 is a mass storage device controlling data exchange between various
Flash modules, HDD and CD-ROM. It includes 64K Bytes of Flash memory and allows
In-System Programming through an embedded 4K Bytes of Boot Flash Memory.
This
versatile device provides all the necessary features for man-machine interface
including, timers, keyboard port, serial or parallel interface (USB, SPI, IDE),
ADC input, I2S output, and all external memory interface (NAND or NOR Flash,
SmartMedia, MultiMedia, and DataFlash cards).
LIGHTING MCU'S
Optimized
for lighting control applications, the Atmel AT83EB5114 is a high performance
version of the 80C51 8-bit microcontroller in a low pin count package. It has
all the features of the standard 80C51 with 4 Kbytes program memory, 256 bytes
of internal RAM, a 7-source, 4-level interrupt system, an on-chip oscillator,
and two timers/counters. The AT83EB5114 includes a serial two-wire interface
EEPROM housed together with the microcontroller die in the same package.
ROMLESS
Atmel
offers a powerful ROMless 8051 microcontroller suitable for existing ROMless
applications that require a combination of performance, flexibility, and power
efficiency. The AT80C51RD2 microcontroller retains all features of the Atmel
80C52, with 256 bytes of internal RAM, a 7- source 4-level interrupt
controller, and three timer/counters.
To
enhance system performance, this ROMless microcontroller features a
programmable counter array, an XRAM of 1024 bytes, a hardware watchdog timer,
and a keyboard interface. It also includes a versatile serial channel that
facilitates multiprocessor communication (EUART), and a speed improvement
mechanism (X2 mode).
Subscribe to:
Posts (Atom)