AS V1.41r8 - source file lcdclock.asm - page 1 - 2/20/2004 23:01:12 1/ 0 : ;$Id: lcdclock.asm,v 1.2 2004/02/19 12:31:50 runner Exp $ 2/ 0 : 3/ 0 : ; SHIFT LEFT on 10 bit. every second 4/ 0 : ; 7seg LED Dp on/off every half second 5/ 0 : ; short beep every double second 6/ 0 : ; long beep every hour 7/ 0 : ; 8/ 0 : ; P20-P23 uPD7228 D0-D3 9/ 0 : ; P24 ~CS 10/ 0 : ; P26 C/~D 11/ 0 : ; P27 RESET 12/ 0 : ; ALE CLOCK 13/ 0 : ; PROG ~STB 14/ 0 : ; T1 ~BUSY 15/ 0 : ; 16/ 0 : ; P25 - CrystalBuzzer - GND 17/ 0 : ; 18/ 0 : ; P17 P16 P15 P14 P13 P12 P11 P10 - LED - V+ 19/ 0 : ; ------------------------------- 20/ 0 : ; 1 1 1 1 1 1 1 0 21/ 0 : ; 1 1 1 1 1 1 0 1 22/ 0 : ; 1 1 1 1 1 0 1 1 23/ 0 : ; . 24/ 0 : ; 0 1 1 1 1 1 1 1 25/ 0 : ; 26/ 0 : ; osc 6MHz 27/ 0 : ; clock 2Mhz 28/ 0 : ; ALE 400KHz 2.5us 29/ 0 : ; timer 12.5KHz 80us 30/ 0 : 31/ 0 : cpu 8048 32/ 0 : 33/ 0 : =80H LCD_RST equ (1<<7) ;P27 H=RESET 34/ 0 : =40H LCD_CD equ (1<<6) ;P26 H=Control/L=Data 35/ 0 : =10H LCD_CS equ (1<<4) ;P24 L=ChipSelected 36/ 0 : 37/ 0 : =20H _P25ON equ (1<<5) ;P25=H(OR bit pattern) 38/ 0 : =DFH _P25OFF equ (0ffH ! _P25ON) 39/ 0 : 40/ 0 : =0H RSTVCT equ 0 41/ 0 : =3H INTVCT equ 3 42/ 0 : =7H TMRVCT equ 7 43/ 0 : 44/ 0 : =83H PRESET equ (256-125) ; up count timer preset value. 45/ 0 : 46/ 0 : =20H RAMWORK equ 020h ; internal work area. top address 47/ 0 : 48/ 20 : org RAMWORK 49/ 20 : ICOUNT ds 1 ; interrupt counter.(0-255) 50/ 21 : V10MS ds 1 ; 10ms value(BCD) 51/ 22 : V1S ds 1 ; 1second value(BCD) 52/ 23 : V1M ds 1 ; 1minuts value(BCD) 53/ 24 : V1H ds 1 ; 1hour value(BCD) 54/ 25 : 55/ 25 : ; 56/ 25 : ; reset vecor 57/ 25 : ; 58/ 0 : org RSTVCT 59/ 0 : 04 45 jmp init 60/ 2 : ; AS V1.41r8 - source file lcdclock.asm - page 2 - 2/20/2004 23:01:12 61/ 2 : ; interupt vector 62/ 2 : ; 63/ 3 : org INTVCT 64/ 3 : 04 09 jmp int_exec 65/ 5 : ; 66/ 5 : ; timer/counter vector 67/ 5 : ; if preset, every 10ms interval. 68/ 5 : ; 69/ 7 : org TMRVCT 70/ 7 : 04 11 jmp timer_exec 71/ 9 : int_exec 72/ 9 : D5 sel rb1 73/ A : B8 20 mov R0,#ICOUNT 74/ C : 23 01 mov a,#1 75/ E : 60 add a,@R0 76/ F : A0 mov @R0,a 77/ 10 : 93 retr 78/ 11 : 79/ 11 : timer_exec 80/ 11 : D5 sel rb1 81/ 12 : 82/ 12 : 23 83 mov a,#PRESET ; preset 83/ 14 : 62 mov t,a 84/ 15 : 85/ 15 : B8 21 mov R0,#V10MS ;@R0 = V10MS 86/ 17 : 23 01 mov a,#1 87/ 19 : 60 add a,@R0 88/ 1A : 57 da a 89/ 1B : A0 mov @R0,a 90/ 1C : E6 44 jnc tmrvct0 91/ 1E : 27 clr a 92/ 1F : A0 mov @R0,a 93/ 20 : 94/ 20 : 18 inc R0 ;@R0 = V1S 95/ 21 : 23 01 mov a,#1 96/ 23 : 60 add a,@R0 97/ 24 : 57 da a 98/ 25 : A0 mov @R0,a 99/ 26 : 03 A0 add a,#(256-60h) ; check over 60(second) 100/ 28 : E6 44 jnc tmrvct0 101/ 2A : 27 clr a 102/ 2B : A0 mov @R0,a 103/ 2C : 104/ 2C : 18 inc R0 ;@R0 = V1M 105/ 2D : 23 01 mov a,#1 106/ 2F : 60 add a,@R0 107/ 30 : 57 da a 108/ 31 : A0 mov @R0,a 109/ 32 : 03 A0 add a,#(256-60h) ; check over 60(minuts) 110/ 34 : E6 44 jnc tmrvct0 111/ 36 : 27 clr a 112/ 37 : A0 mov @R0,a 113/ 38 : 114/ 38 : 18 inc R0 ;@R0 = V1H 115/ 39 : 23 01 mov a,#1 116/ 3B : 60 add a,@R0 117/ 3C : 57 da a 118/ 3D : A0 mov @R0,a 119/ 3E : 03 DC add a,#(256-24h) ; check over 24(hour) 120/ 40 : E6 44 jnc tmrvct0 AS V1.41r8 - source file lcdclock.asm - page 3 - 2/20/2004 23:01:12 121/ 42 : 27 clr a 122/ 43 : A0 mov @R0,a 123/ 44 : tmrvct0 124/ 44 : 93 retr 125/ 45 : 126/ 45 : init 127/ 45 : ; clear interrupt counter 128/ 45 : 27 clr a 129/ 46 : B8 20 mov R0,#ICOUNT 130/ 48 : A0 mov @R0,a 131/ 49 : ; clear clock work area 132/ 49 : 27 clr a 133/ 4A : B8 21 mov R0,#V10MS 134/ 4C : A0 mov @R0,a ;10ms 135/ 4D : 18 inc R0 136/ 4E : A0 mov @R0,a ;1s 137/ 4F : 18 inc R0 138/ 50 : A0 mov @R0,a ;1h 139/ 51 : 18 inc r0 140/ 52 : A0 mov @R0,a ;1h 141/ 53 : ; LCD Hard Reset 142/ 53 : 23 FF mov a,#0ffh 143/ 55 : 3A outl P2,a ;RESET=H, D1=H --> uPD7228 Parallel Mode 144/ 56 : 00 nop 145/ 57 : 00 nop 146/ 58 : 00 nop 147/ 59 : 00 nop 148/ 5A : 9A 7F anl P2,#(0ffh ! LCD_RST) ;uPD7228 RESET=OFF and keep 4us 149/ 5C : 00 nop 150/ 5D : 00 nop 151/ 5E : 00 nop 152/ 5F : 00 nop 153/ 60 : ; T0 2MHz output 154/ 60 : 75 ent0 clk 155/ 61 : ; timer preset 156/ 61 : 23 83 mov a,#PRESET 157/ 63 : 62 mov t,a 158/ 64 : 55 strt t 159/ 65 : ; enable timer,external interrupt 160/ 65 : 05 en i 161/ 66 : 25 en tcnti 162/ 67 : 163/ 67 : lcdinit 164/ 67 : 23 14 mov a,#14h ;Set Frame Frequency = Fcl/2^10 165/ 69 : 34 54 call l_cmd 166/ 6B : 34 30 call r_cmd 167/ 6D : 23 1A mov a,#1ah ;8 Sync=Out bank=0 168/ 6F : 34 54 call l_cmd 169/ 71 : 34 30 call r_cmd 170/ 73 : 23 09 mov a,#09h ;LEFT-LCD ON 171/ 75 : 34 54 call l_cmd 172/ 77 : 23 08 mov a,#08h ;RIGHT-LCD OFF 173/ 79 : 34 30 call r_cmd 174/ 7B : 175/ 7B : ;L-channel dot clear 176/ 7B : 23 64 mov a,#64h ;set write auto inc 177/ 7D : 34 54 call l_cmd 178/ 7F : 23 80 mov a,#80h ;Colum pointer=0 179/ 81 : 34 54 call l_cmd 180/ 83 : BA 32 mov R2,#50 AS V1.41r8 - source file lcdclock.asm - page 4 - 2/20/2004 23:01:12 181/ 85 : 27 clr a 182/ 86 : 34 66 lcdt0 call l_out 183/ 88 : EA 86 djnz R2,lcdt0 184/ 8A : 185/ 8A : ;L-channel '0'-'9' 186/ 8A : 23 B1 mov a,#80h+31h ;Colum pointer=31H(bank0,last) 187/ 8C : 34 54 call l_cmd 188/ 8E : 23 71 mov a,#71h ;left charactor mode 189/ 90 : 34 54 call l_cmd 190/ 92 : BA 0A mov R2,#10 191/ 94 : 23 30 mov A,#'0' 192/ 96 : 34 66 lcd1 call l_out 193/ 98 : 17 inc a 194/ 99 : EA 96 djnz R2,lcd1 195/ 9B : 196/ 9B : ; R7 = P10-P17 197/ 9B : start 198/ 9B : BF FE mov R7,#0feh ; 1111 1110 = P17-P10 199/ 9D : ledout 200/ 9D : FF mov a,R7 201/ 9E : 39 outl P1,a 202/ 9F : 34 00 call lcddisp ; display LCD 203/ A1 : 204/ A1 : ;check beep timing. 205/ A1 : B9 22 mov R1,#V1S 206/ A3 : F1 mov a,@R1 207/ A4 : ;every just 0second. 208/ A4 : C6 BE jz longbeep 209/ A6 : ;every double second intrval 210/ A6 : 53 01 anl a,#1 211/ A8 : 96 AC jnz shortbeep 212/ AA : 04 CE jmp delay 213/ AC : 214/ AC : ;short beep 215/ AC : shortbeep: 216/ AC : BC 0E mov R4,#14 ;10ms(10.57ms) 217/ AE : sbeepLoop 218/ AE : ; Total 755us=1324.5Hz 219/ AE : 8A 20 orl P2,#_P25ON ; P25=H 220/ B0 : BD 48 mov R5,#72 ; 375us (1320Hz=378.7878us*2) 221/ B2 : ED B2 djnz R5,$ ; 222/ B4 : 9A DF anl P2,#_P25OFF ; P25=L 223/ B6 : BD 48 mov R5,#72 ; 375us 224/ B8 : ED B8 djnz R5,$ ; 225/ BA : ;beep 226/ BA : EC AE djnz R4,sbeepLoop 227/ BC : 04 CE jmp delay 228/ BE : 229/ BE : ;long beep 230/ BE : longbeep: 231/ BE : BC DB mov R4,#219 ;500ms(498.225ms) 232/ C0 : lbeepLoop 233/ C0 : ; Total 2275us=439.56Hz 234/ C0 : 8A 20 orl P2,#_P25ON ; P25=H 235/ C2 : BD E0 mov R5,#224 ; 1135us (440Hz=1136.36us*2) 236/ C4 : ED C4 djnz R5,$ ; 237/ C6 : 9A DF anl P2,#_P25OFF ; P25=L 238/ C8 : BD E0 mov R5,#224 ; 1135us 239/ CA : ED CA djnz R5,$ ; 240/ CC : ;beep AS V1.41r8 - source file lcdclock.asm - page 5 - 2/20/2004 23:01:12 241/ CC : EC C0 djnz R4,lbeepLoop 242/ CE : 243/ CE : ;1sec delay 244/ CE : B8 21 delay mov R0,#V10MS 245/ D0 : F0 mov a,@R0 246/ D1 : 96 D0 jnz $-1 ; check every 0(1/100) 247/ D3 : F0 mov a,@R0 248/ D4 : C6 D3 jz $-1 ; check next 10ms time. 249/ D6 : 250/ D6 : ;LED pattern shift 251/ D6 : shift 252/ D6 : 97 clr c 253/ D7 : A7 cpl c 254/ D8 : FF mov a,R7 255/ D9 : F7 rlc a 256/ DA : AF mov R7,a 257/ DB : F6 9D jc ledout 258/ DD : 04 9B jmp start 259/ DF : 260/ DF : ;--------------------------------Subroutine Bank 1 261/ 100 : org 0100h 262/ 100 : 263/ 100 : lcddisp ; A,R1,R2 notsave 264/ 100 : ; 265/ 100 : 23 B1 mov a,#80h+31h ;Colum pointer=31H(bank0,last) 266/ 102 : 34 54 call l_cmd 267/ 104 : 23 71 mov a,#71h ;left charactor mode 268/ 106 : 34 54 call l_cmd 269/ 108 : B9 24 mov R1,#V1H 270/ 10A : 34 21 call lcd_full_number 271/ 10C : 23 3A mov a,#':' 272/ 10E : 34 66 call l_out 273/ 110 : C9 dec R1 274/ 111 : 34 21 call lcd_full_number 275/ 113 : 23 3A mov a,#':' 276/ 115 : 34 66 call l_out 277/ 117 : C9 dec R1 278/ 118 : 34 21 call lcd_full_number 279/ 11A : 23 20 mov a,#' '; 280/ 11C : 34 66 call l_out 281/ 11E : 34 66 call l_out 282/ 120 : 83 ret 283/ 121 : 284/ 121 : lcd_full_number 285/ 121 : F1 mov a,@R1 286/ 122 : 47 swap a 287/ 123 : 34 29 call lcd_half_number 288/ 125 : F1 mov a,@R1 289/ 126 : 34 29 call lcd_half_number 290/ 128 : 83 ret 291/ 129 : lcd_half_number 292/ 129 : 53 0F anl a,#0fh 293/ 12B : 03 30 add a,#'0' 294/ 12D : 34 66 call l_out 295/ 12F : 83 ret 296/ 130 : 297/ 130 : 298/ 130 : 299/ 130 : 300/ 130 : r_cmd ; output command to LCD AS V1.41r8 - source file lcdclock.asm - page 6 - 2/20/2004 23:01:12 301/ 130 : ; IN Acc 302/ 130 : 9A EF anl P2,#(0ffh ! LCD_CS) ;CS=L and wait 2us 303/ 132 : 00 nop 304/ 133 : 46 33 jnt1 $ ;repeat BUSY 305/ 135 : 8A 40 orl P2,#(LCD_CD) ;C/~D=H 306/ 137 : ;upper 4bit out and lower 4bit out 307/ 137 : 47 swap a 308/ 138 : 3C movd P4,a 309/ 139 : 47 swap a 310/ 13A : 3C movd P4,a 311/ 13B : ;3us wait 312/ 13B : 00 nop 313/ 13C : 00 nop 314/ 13D : 46 3D jnt1 $ ;repeat BUSY 315/ 13F : 8A 10 orl P2,#(LCD_CS) ;CS=H 316/ 141 : 83 ret 317/ 142 : 318/ 142 : r_out ; output data to LCD 319/ 142 : ; in acc 320/ 142 : 9A EF anl P2,#(0ffh ! LCD_CS) ;CS=L and wait 2us 321/ 144 : 00 nop 322/ 145 : 46 45 jnt1 $ ;repeat BUSY 323/ 147 : 9A BF anl P2,#(0ffh ! LCD_CD) ;C/~D=L 324/ 149 : ;upper 4bit out and lower 4bit out 325/ 149 : 47 swap a 326/ 14A : 3C movd P4,a 327/ 14B : 47 swap a 328/ 14C : 3C movd P4,a 329/ 14D : ;3us wait 330/ 14D : 00 nop 331/ 14E : 00 nop 332/ 14F : 46 4F jnt1 $ ;repeat BUSY 333/ 151 : 8A 10 orl P2,#(LCD_CS) ;CS=H 334/ 153 : 83 ret 335/ 154 : 336/ 154 : l_cmd ; output command to LCD 337/ 154 : ; IN Acc 338/ 154 : 9A EF anl P2,#(0ffh ! LCD_CS) ;CS=L and wait 2us 339/ 156 : 00 nop 340/ 157 : 46 57 jnt1 $ ;repeat BUSY 341/ 159 : 8A 40 orl P2,#(LCD_CD) ;C/~D=H 342/ 15B : ;upper 4bit out and lower 4bit out 343/ 15B : 47 swap a 344/ 15C : 3F movd P7,a 345/ 15D : 47 swap a 346/ 15E : 3F movd P7,a 347/ 15F : ;3us wait 348/ 15F : 00 nop 349/ 160 : 00 nop 350/ 161 : 46 61 jnt1 $ ;repeat BUSY 351/ 163 : 8A 10 orl P2,#(LCD_CS) ;CS=H 352/ 165 : 83 ret 353/ 166 : 354/ 166 : l_out ; output data to LCD 355/ 166 : ; in acc 356/ 166 : 9A EF anl P2,#(0ffh ! LCD_CS) ;CS=L and wait 2us 357/ 168 : 00 nop 358/ 169 : 00 nop 359/ 16A : 46 6A jnt1 $ ;repeat BUSY 360/ 16C : 9A BF anl P2,#(0ffh ! LCD_CD) ;C/~D=L AS V1.41r8 - source file lcdclock.asm - page 7 - 2/20/2004 23:01:12 361/ 16E : ;upper 4bit out and lower 4bit out 362/ 16E : 47 swap a 363/ 16F : 3F movd P7,a 364/ 170 : 47 swap a 365/ 171 : 3F movd P7,a 366/ 172 : ;3us wait 367/ 172 : 00 nop 368/ 173 : 00 nop 369/ 174 : 00 nop 370/ 175 : 46 75 jnt1 $ ;repeat BUSY 371/ 177 : 8A 10 orl P2,#(LCD_CS) ;CS=H 372/ 179 : 83 ret 373/ 17A : 374/ 17A : end AS V1.41r8 - source file lcdclock.asm - page 8 - 2/20/2004 23:01:12 symbol table (* = unused): ------------------------ *ARCHITECTURE : i386-unknown-freebsd - | *BIGENDIAN : 0 - | *BRANCHEXT : 0 - | *CASESENSITIVE : 0 - | *CONSTPI : 3.141592653589793 - | *DATE : 2/20/2004 - | DELAY : CE C | *FALSE : 0 - | *FULLPMMU : 1 - | *HAS64 : 1 - | *HASFPU : 0 - | *HASPMMU : 0 - | ICOUNT : 20 C | *INEXTMODE : 0 - | INIT : 45 C | *INLWORDMODE : 0 - | *INMAXMODE : 0 - | *INSRCMODE : 0 - | *INSUPMODE : 0 - | INTVCT : 3 - | INT_EXEC : 9 C | LBEEPLOOP : C0 C | LCD1 : 96 C | LCDDISP : 100 C | *LCDINIT : 67 C | LCDT0 : 86 C | LCD_CD : 40 - | LCD_CS : 10 - | LCD_FULL_NUMBER : 121 C | LCD_HALF_NUMBER : 129 C | LCD_RST : 80 - | LEDOUT : 9D C | *LISTON : 1 - | LONGBEEP : BE C | L_CMD : 154 C | L_OUT : 166 C | *MACEXP : 1 - | *MOMCPU : 8048 - | *MOMCPUNAME : 8048 - | *PADDING : 1 - | PRESET : 83 - | RAMWORK : 20 - | *RELAXED : 0 - | RSTVCT : 0 - | R_CMD : 130 C | *R_OUT : 142 C | SBEEPLOOP : AE C | *SHIFT : D6 C | SHORTBEEP : AC C | START : 9B C | *TIME : 23:01:12 - | TIMER_EXEC : 11 C | TMRVCT : 7 - | TMRVCT0 : 44 C | *TRUE : 1 - | V10MS : 21 C | V1H : 24 C | *V1M : 23 C | V1S : 22 C | *VERSION : 1418 - | _P25OFF : DF - | _P25ON : 20 - | 62 symbols 29 unused symbols AS V1.41r8 - source file lcdclock.asm - page 9 - 2/20/2004 23:01:12 codepages: ---------- STANDARD (0 changed characters) 0.13 seconds assembly time 376 lines source file 2 passes 0 errors 0 warnings