; ----------------lcd_asm-------------------- ; LCD_port EQU 01 ; ; ; dip_switch EQU 01 button EQU 00 lcddata EQU s3 startbyte EQU s4 counter EQU s5 ausgabe EQU s6 ; /\ -> MOSI ; || -> SCLK ; || -> CS ; || -> MISO ; || -> RESET temp_0 EQU s7 ;eint load ausgabe, 0x06 ; zu begin des programms cs und sclk out ausgabe, LCD_port ; high setzen call delay_50ms begin: in temp_0, button ; warten auf knopfdruck test temp_0, 0x01 jump NC, begin load ausgabe, 0x06 ; reset auf low out ausgabe, LCD_port call delay_50ms load ausgabe, 0x16 ; reset auf high out ausgabe, LCD_port call delay_50ms LCD_INIT: load ausgabe, 0x02 ; cs auf high ; ; function set bit re=1 "00110100" ; startbyte load counter, 0x08 load lcddata, 0x5F ; startbyte 01011111 call LCD_COMMAND ; function set 1.teil load counter, 0x08 load lcddata, 0x04 call LCD_COMMAND ; function set 2.teil load counter, 0x08 load lcddata, 0x03 call LCD_COMMAND ; load ausgabe, 0x02 ; stoppe sclk, aber behalte cs auf low out ausgabe, LCD_port ; call delay_2500ns ; fuer den fall, dass cs nach jedem byte high werden muss call delay_2ms ; wartezeit zwischen datenbytes ; ; load ausgabe, 0x02 ; ext. function set "00001001" ; startbyte load counter, 0x08 load lcddata, 0x5F call LCD_COMMAND ; ext. function set 1.teil load counter, 0x08 load lcddata, 0x09 call LCD_COMMAND ; ext. function set 2.teil load counter, 0x08 load lcddata, 0x00 call LCD_COMMAND ; load ausgabe, 0x02 out ausgabe, LCD_port ; call delay_2500ns call delay_2ms ; ; load ausgabe, 0x02 ; function set bit re=0 "00110000" ; startbyte load counter, 0x08 load lcddata, 0x5F call LCD_COMMAND ; function set 1.teil load counter, 0x08 load lcddata, 0x00 call LCD_COMMAND ; function set 2.teil load counter, 0x08 load lcddata, 0x03 call LCD_COMMAND ; load ausgabe, 0x02 out ausgabe, LCD_port ; call delay_2500ns call delay_2ms ; load ausgabe, 0x02 ; display on/off "00001111" ; startbyte load counter, 0x08 load lcddata, 0x5F call LCD_COMMAND ; display on/off 1.teil load counter, 0x08 load lcddata, 0x0F call LCD_COMMAND ; display on/off 2.teil load counter, 0x08 load lcddata, 0x00 call LCD_COMMAND ; load ausgabe, 0x02 out ausgabe, LCD_port ; call delay_2500ns call delay_2ms ; load ausgabe, 0x02 ; clear display "00000001" ; ; startbyte load counter, 0x08 load lcddata, 0x5F call LCD_COMMAND ; clear display 1.teil load counter, 0x08 load lcddata, 0x01 call LCD_COMMAND ; clear display 2.teil load counter, 0x08 load lcddata, 0x00 call LCD_COMMAND ; load ausgabe, 0x02 out ausgabe, LCD_port ; call delay_2500ns call delay_2ms ; ; load ausgabe, 0x02 ; ; entry mode set "00000110" ; ; startbyte load counter, 0x08 load lcddata, 0x5F call LCD_COMMAND ; entry mode set 1.teil load counter, 0x08 load lcddata, 0x06 call LCD_COMMAND ; entry mode set 2.teil load counter, 0x08 load lcddata, 0x00 call LCD_COMMAND ; ; load ausgabe, 0x02 ; out ausgabe, LCD_port call delay_2us ; cs einen halben takt nach letztem byte high setzen load ausgabe, 0x06 out ausgabe, LCD_port ; ; send "S" "01010011" ; ; startbyte ; load counter, 0x08 ; load lcddata, 0x5F ; call LCD_COMMAND ; ; "S" 1.teil ; load counter, 0x08 ; load lcddata, 0x03 ; call LCD_COMMAND ; ; "S" 2.teil ; load counter, 0x08 ; load lcddata, 0x05 ; call LCD_COMMAND ; ; load ausgabe, 0x02 ; out ausgabe, LCD_port ; call delay_2500ns ; call delay_2ms jump begin LCD_COMMAND: out ausgabe, LCD_port call delay_2us SR0 lcddata jump NC, null_carry load ausgabe, 0x01 out ausgabe, LCD_port call delay_2us ; sub ausgabe, 0x02 ; out ausgabe, LCD_port ; call delay_2us add ausgabe, 0x02 sub counter, 0x01 comp counter, 0x00 jump Z, fertig jump LCD_COMMAND null_carry: load ausgabe, 0x00 out ausgabe, LCD_port call delay_2us ; sub ausgabe, 0x02 ; out ausgabe, LCD_port ; call delay_2us add ausgabe, 0x02 sub counter, 0x01 comp counter, 0x00 jump Z, fertig jump LCD_COMMAND fertig: ret delay_2us: LOAD s2, 0x00 ; 2.5us -> 200kHz LOAD s1, 0x00 LOAD s0, 0x19 JUMP software_delay delay_2ms: LOAD s2, 0x00 ; 2ms LOAD s1, 0x4E LOAD s0, 0x20 JUMP software_delay ; ; ; 50ms is 500,000 x 100ns ; delay_50ms: LOAD s2, 0x07 ; 50ms LOAD s1, 0xA1 LOAD s0, 0x20 JUMP software_delay ; ; The delay loop decrements [s2,s1,s0] until it reaches zero ; Each decrement cycle is 5 instructions which is 10 clock cycles (100ns at 100MHz) ; software_delay: LOAD s0, s0 ;pad loop to make it 10 clock cycles (5 instructions) SUB s0, 1 SUBC s1, 0 SUBC s2, 0 JUMP NZ, software_delay RET