ahmed100
Newbie level 2
- Joined
- Dec 17, 2012
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,309
hi
can anyone tell me what is wrong with this code and circuit digram.maybe you think the are alot of unnecessary line,i know but this code for test.
can anyone tell me what is wrong with this code and circuit digram.maybe you think the are alot of unnecessary line,i know but this code for test.
Code ASM - [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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 port equ p2 ;lcd port en equ p2.7 ;lcd en rs equ p2.5 ;lcd rs dr equ p3.4 ;ADC RD rw equ p3.3 ;ADC RW intr equ p3.5 ;ADC intr temp equ 90h adc equ p1 ;ADC port adc_val equ 91h temp_unit equ 92h temp_ten equ 93h temp_hund equ 94h org 00h main: call lcd_init mov r0,#01d call delay_ms mov a,#'T' call lcd_dat mov a,#'a' call lcd_dat mov a,#'m' call lcd_dat mov a,#'r' call lcd_dat mov a,#'a' call lcd_dat mov a,#'t' call lcd_dat mov a,#'u' call lcd_dat mov a,#'r' call lcd_dat mov a,#'e' call lcd_dat mov a,#'=' mov a,#0c0h call lcd_cmd call read_temp call binary_decimal call decimal_ascii mov a,temp_hund call lcd_dat mov a,temp_ten call lcd_dat mov a,temp_unit call lcd_dat sjmp $ ;***************************************************** ;********************SUBROUTINE*********************** ;***************************************************** lcd_reset: mov port,#0ffh mov r0,#20d call delay_ms ;20ms delay mov port,#83h mov port,#03h mov r0,#15d call delay_ms ;15ms delay mov port,#83h mov port,#03h mov r0,#05d call delay_ms ;5ms delay mov port,#83h mov port,#03h mov r0,#05d ;5ms delay call delay_ms mov port,#82h mov port,#02h mov r0,#05d ;5ms delay call delay_ms ret lcd_init: call lcd_reset mov a,#28h call lcd_cmd mov a,#0ch call lcd_cmd mov a,#06h call lcd_cmd mov a,#80h call lcd_cmd ret lcd_cmd: mov temp,a swap a anl a,#0fh add a,#80h mov port,a anl a,#0fh mov port,a mov a,temp anl a,#0fh add a,#80h mov port,a anl a,#0fh mov port,a mov r0,#01d call delay_ms ret lcd_dat: mov temp,a swap a anl a,#0fh add a,#0a0h mov port,a nop clr en mov a,temp anl a,#0fh add a,#0a0h mov port,a nop clr en mov r0,#01d call delay_ms ret delay_ms: mov r5,00h x:MOV R6,#250D MOV R7,#250D LABEL1: DJNZ R6,LABEL1 LABEL2: DJNZ R7,LABEL2 djnz r5,x ret read_temp: setb dr clr rw nop setb rw wait:jb intr,wait clr rw clr dr mov a,adc mov adc_val,a ret binary_decimal: mov a,adc_val mov b,#10d div ab mov temp_unit,b mov b,#10d div ab mov temp_ten,b mov b,#10d div ab mov temp_hund,b ret decimal_ascii: mov a,temp_hund anl a,#0fh add a,#30h mov temp_hund,a mov a,temp_ten anl a,#0fh add a,#30h mov temp_ten,a mov a,temp_unit anl a,#0fh add a,#30h mov temp_unit,a ret end
Attachments
Last edited by a moderator: