Senin, 29 September 2008

Writing "Hello World" to LCD Character in the Upper Left firs Line.


In this lesson, you can try to write word " Hello World " in first line of LCD Character.

Step 1st
Build the circuit as shown in figure 2.11. As you seen on figure 2.11. P0.0 trough P0.7 is connected to DB0 - DB7,and P2.0- P2.1. is connected to RS and EN each. Remember, that all we want to do with this lesson is write " Hello World ", in the first line of LCD Character, below the schematic


Step 2nd
In this step, you must tipe the assembly program to make your LCD Character shown the word, we assume that you have already known the editor, we used RIDE-51 to edit the program.

       org 0h
start: call init_LCD
mov R1,#80h
call write_inst
mov R1,#'H'
call write_data
mov R1,#'e'
call write_data
mov R1,#'l'
call write_data
mov R1,#'l'
call write_data
mov R1,#'o'
call write_data
mov R1,#' '
call write_data
mov R1,#'W'
call write_data
mov R1,#'o'
call write_data
mov R1,#'r'
call write_data
mov R1,#'l'
call write_data
mov R1,#'d'
call write_data
EndChar:
sjmp Endchar

Init_lcd:
mov r1,#00000001b ;Display clear
acall write_inst ;
mov r1,#00111000b ;Function set,
;Data 8 bit,2 line font 5x7
acall write_inst ;
mov r1,#00001100b ;Display on,
;cursor off,cursor blink off
acall write_inst
mov r1,#00000110b ;Entry mode, Set increment
acall write_inst
ret
;
Write_inst:
clr P2.0 ; RS = P2.0 = 0, write mode instruction
mov P0,R1 ; D7 s/d D0 = P0 = R1
setb P2.1 ; EN = 1 = P2.1
call delay; call delay time
clr P2.1 ; EN = 0 = P2.1
ret
;
Write_data:
setb P2.0 ; RS = P2.0 = 1, write mode data
mov P0,R1 ; D7 s/d D0 = P0 = R1
setb P2.1 ; EN = 1 = P2.1
call delay; call delay time
clr p2.1 ; EN = 0 = P2.1
ret
;
delay: mov R0,#0
delay1:mov R7,#0fh
djnz R7,$
djnz R0,delay1
ret
;
end

Step 3rd

Safe your assembly program above, and name it with lcd1.asm (for example)
Compile the program that you have been save by using RIDE-51, see the
software instruction.
Step 4th
Download your hex file ( lcd1.hex ) into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of the 7 segmen ( of course if your cable connection and your program are corrected ).

Moving Display


In this lesson, we are going to drive 8 x7 segmen, in this way you can write eight character on multi 7 segmen. We used a multiplexing methode to transfer data for driver transistor consequtively.

Step 1st
Build the circuit as shown in figure 2.3.5. As you seen on figure 2.3.5. P2.0 trough P2.7 is connected to driver transistor, and all eight 7 segment is connected to P0.0 trough P0.6 parallelly. Remember, that all we want to do with this lesson is to write ( k-O-n-P-U-t-E-r ) to 1st, 2nd, 3rd, 4th, 5th, 6th, 7th and 8th 7 segmen each sifting the word to the left.

Step 2nd
In this step, you must tipe the assembly program to make your 7 segmen shown some number on 7 segmen, we assume that you have already known the editor, we used RIDE-51 to edit the program.

       org 0h
Begin: mov r1,#150
start1: mov dptr,#word1
mov r5,#8
mov r2,#01111111b
again1: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again1
djnz r1,start1
mov r1,#150
start2: mov dptr,#word2
mov r5,#8
mov r2,#01111111b
again2: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again2
djnz r1,start2
mov r1,#150
start3: mov dptr,#word3
mov r5,#8
mov r2,#01111111b
again3: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again3
djnz r1,start3
mov r1,#150
start4: mov dptr,#word4
mov r5,#8
mov r2,#01111111b
again4: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again4
djnz r1,start4
mov r1,#150
start5: mov dptr,#word5
mov r5,#8
mov r2,#01111111b
again5: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again5
djnz r1,start5
mov r1,#150
start6: mov dptr,#word6
mov r5,#8
mov r2,#01111111b
again6: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again6
djnz r1,start6
mov r1,#150
start7: mov dptr,#word7
mov r5,#8
mov r2,#01111111b
again7: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again7
djnz r1,start7
mov r1,#150
start8: mov dptr,#word8
mov r5,#8
mov r2,#01111111b
again8: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again8
djnz r1,start8
ljmp begin
;
delay: mov r3,#10
delay1: mov r4,#10
djnz r4,$
djnz r3,delay1
ret
;
word1: db 10001010b,11000000b,11001000b,10001100b
db 11000001b,10000111b,10000110b,11001110b
word2: db 11000000b,11001000b,10001100b,11000001b
db 10000111b,10000110b,11001110b,10001010b
word3: db 11001000b,10001100b,11000001b,10000111b
db 10000110b,11001110b,10001010b,11000000b
word4: db 10001100b,11000001b,10000111b,10000110b
db 11001110b,10001010b,11000000b,11001000b
word5: db 11000001b,10000111b,10000110b,11001110b
db 10001010b,11000000b,11001000b,10001100b
word6: db 10000111b,10000110b,11001110b,10001010b
db 11000000b,11001000b,10001100b,11000001b
word7: db 10000110b,11001110b,10001010b,11000000b
db 11001000b,10001100b,11000001b,10000111b
word8: db 11001110b,10001010b,11000000b,11001000b
db 10001100b,11000001b,10000111b,10000110b
end
end

Step 3rd
Safe your assembly program above, and name it with *.asm (for example) Compile the program that you have been save by using RIDE-51, see the software instruction.

Step 4th
Download your hex file ( *.hex ) into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of the 7 segmen( of course if your cable connection and your program are corrected ).

8 x 7 Segmen Multiplexing



Writing multi character on 8 x 7 segmen

In this lesson, we are going to drive more 7 segmen, in this way you can write eight character or number on multi 7 segmen. We used a multiplexing methode to transfer data for driver transistor consequtively.

Step 1st
Build the circuit as shown in figure 2.3.5. As you seen on figure 2.3.5. P2.0 trough P2.7 is connected to driver transistor, and all eight 7 segment is connected to P0.0 trough P0.6 parallelly. Remember, that all we want to do with this lesson is write multi number ( 1-2-3-4-5-6-7-8 ) to 1st, 2nd, 3rd, 4th, 5th, 6th, 7th and 8th 7 segmen each.

Step 2nd
In this step, you must tipe the assembly program to make your 7 segmen shown some number on 7 segmen, we assume that you have already known the editor, we used RIDE-51 to edit the program.Below the schematic of 8 seven segmen multiplexing.

       org 0h
start: mov P0,#11111001b;write a number '1'
clr P2.7 ;turn on 1st 7 segment
call delay ;call delay time
setb P2.7 ;turn off 1st 7 segment
;
mov P0,#11011011b;write a number '2'
clr P2.6 ;turn on 2nd 7 segment
call delay ;call delay time
setb P2.6 ;turn off 2nd 7 segment
;
mov P0,#10110000b;write a number '3'
clr P2.5 ;turn on 3rd 7 segment
call delay ;call delay time
setb P2.5 ;turn off 3rd 7 segment
;
mov P0,#10011001b;write a number '4'
clr P2.4 ;turn on 4th 7 segment
call delay ;call delay time
setb P2.4 ;turn off 4th 7 segment
;
mov P0,#10010010b;write a number '5'
clr P2.3 ;turn on 5th 7 segment
call delay ;call delay time
setb P2.3 ;turn off 5th 7 segment
;
mov P0,#10000010b;write a number '6'
clr P2.2 ;turn on 2nd 7 segment
call delay ;call delay time
setb P2.2 ;turn off 2nd 7 segment
;
mov P0,#11111000b;write a number '7'
clr P2.1 ;turn on 7th 7 segment
call delay ;call delay time
setb P2.1 ;turn off 7th 7 segment
;
mov P0,#10000000b;write a number '8'
clr P2.0 ;turn on 8th 7 segment
call delay ;call delay time
setb P2.0 ;turn off 8th 7 segment
sjmp start ;jump forever
;=============================================
;subroutine delay created to rise delay time
;=============================================
delay: mov R1,#255
del1: mov R2,#255
del2: djnz R2,del2
djnz R1,del1
ret
end

Step 3rd
Safe your assembly program above, and name it with 7seg3.asm (for example) Compile the program that you have been save by using RIDE-51, see the software instruction.

Step 4th
Download your hex file ( 7seg3.hex ) into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of the 7 segmen( of course if your cable connection and your program are corrected ).