Pic 16F628 ile yapilmis saat parmakladikca calisiyor.

Başlatan vedo35, 10 Ağustos 2013, 22:55:28

vedo35

#15
Evet cok haklisiniz. Sirf bu saat egom icin odeyip almistim.  Kirmizi renkli olanini  bir kahve makinasinda gormustum. Ayni displayi kullanmislar inanin cok estetik ve hos duruyor. Bunlar cok kucuk led board gibi. Kucuk kucuk ledcikler. Tabi bu display benim gibi amatorler icin fazla pahali ama  yanlizce bir tane alip denemek istedim. Ayni displayin agilent marka olanida var ama arada ne kadar fiyat farki var arastirmadim. Displayin datasheeti burada:

http://search.datasheetcatalog.net/key/page8831/AGILENT

http://pdf.datasheetcatalog.com/datasheet2/d/0jdpyuwrz6g5xdj7gedg6d4086yy.pdf
Biliyormusun dedi, ben ne yaptiysam kader icabi yaptim dedi. Ben gene sustum.... Kimbilir sende belki kaderin memurusun vazifeni yapiyorsun dedi.

vedo35

Arkadaslar tekrar selam. size bahsettigim o SCE5782 yi SDA5708 ile degistirerek kullandim. displayde saatin gorunmesine sevindim. SDA5708 e oranla kucuk olsada en azindan SDA5708 i bulmak cok zor oldugundan SCE5782 ye uyarlamak istedim, oldu. ancak kaynak kodunda ufak bir degisiklik istiyor yanilmiyorsam. Cunku saat, dakika, yada saniye kisminda rakamlar bir kac saniyede bir bir sira asagiya kayip tekrar normale donuyor yada birkac saniyede bir rakamlarda bozulma oluyor ben datasheetini detayli okuyamadim sda5798 ile karsilstirma yapmak gerekiyor saniyorum.  Adam bu arada kaynak kodunuda koymus sizinle paylasirsam bana yardimci olmaniz mumkunmu? Birde bu saat amerikan usulu yani a.m - p.m olarak gosteriyor ben 24 ssat usulune gore nerede degisiklik yapmama lazim? simdiden cok tesekkurler. Bu arada resimlerini upload ettim link burada.

http://imageshack.us/f/600/jhwa.jpg/

Kaynak kodu 16f84 ve 16f628 ile birlikte:

; File Dated (6-8-09)
; Clock Using SDA5708-24 DS1307 PIC16F84A Or PIC16f628
; With Display DIM with LDR On PORTB,3
;
;
; To Do   -;
; To Do   -;
; To Do   -; Calender To Show On Every 10th Sec For 2 Sec
; To Do   -; Auto Out From Setup If No Keys Pressed In 15 Secs
;
; ----------------- New And Old Fixes And Updates --------------------
; Timer (Incase If Stuck) To Read RTC   (6-8-09)
; Display SH And SM On Setup Mode   (4-8-09)
; + - Values For Hour And Min      (4-8-09)
; AM PM added
;#################################################################################
;###################     SDA5708 Display Settings     ############################
;#################################################################################
; pin connections from right (BackSide View)
; 1-vcc,2-load,3-data,4-clock,5-reset,6-Gnd
; brightness "D2-D1-D0"
; 000-100%,001-53%,010-40%,011-27%,100-20%,101-13%,110-6.6%,111-0%
;
;   ALL Ok.
;#################################################################################
;#################################################################################
;   LIST   p=16F84a      ;tell assembler what chip we are using
;   include "P16F84a.inc"      ;include the defaults for the chip
;   __CONFIG _XT_OSC & _WDT_OFF & _CP_OFF & _PWRTE_ON ; 16F84 Set up config bits
;#######   And Also Remove 2 Lines In "START"    ############################
;#################################################################################
;#################################################################################
   LIST   p=16F628      ;tell assembler what chip we are using
   include "P16F628.inc"      ;include the defaults for the chip
   __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _BODEN_OFF & _LVP_OFF & _MCLRE_ON & _PWRTE_ON
; 16F628 Set up config bits
;#######   And Also Include 2 Lines In "START"    ############################
;#################################################################################
;#################################################################################
   ERRORLEVEL   0,-302   ;suppress bank selection messages
;#################################################################################
;#################################################################################
      cblock   0x20       ;0x20(pic16f628) ;start of general purpose registers
;      cblock   0x0C      ;0x0c(pic16f84a) ;start of general purpose registers
         count         ;used in looping routines
         count1         ;used in delay routine
         counta         ;used in delay routine
         countb         ;used in delay routine
         temp_w
         temp_stat
         Adr_Lo         ; EEPROM memory address to be accessed
         DAT_VAL
         _N
         N
         InputByte      ; byte read from EEPROM is stored in this register
         Data_Page      ; EEPROM page, 0-7
         OutputByte      ; used for holding byte to be output to EEPROM
         I2Cflags      ; flag bit register
         buf         ; seconds
         buf1         ; Min's
         buf2         ; Hour's # am/pm # 12h/24h
         hourten
         hourone
         minOne
         minten
;   Temp's For SDA5708-24 Display
         SDA_tmp   ; See Below
; Bit0   0 = no update   1 = Update
; Bit1   0 = Bright   1 = DIM
; Bit2   0 = AM      1 = PM
; Bit3   0 = NorMal   1 = Setup
; Bit4   0 = Set Hour   1 = Set Min
         digit
         row0
         row1
         row2
         row3
         row4
         row5
         row6
         vfdsend
         countsda
         counter1
         counter2
;   end of SDA5708-24 Display
      endc
;#################################################################################
; PIC16F628      |----U----|         
;      RA2   |1   18|   RA1      
;      RA3   |2   17|   RA0      
;      RA4   |3   16|   RA7      
;      RA5   |4   15|   RA6      
;      GND   |5   14|   VCC      
;      RB0   |6   13|   RB7      
;      RB1   |7   12|   RB6      
;      RB2   |8   11|   RB5      
;      RB3   |9   10|   RB4      
;         |---------|         
;#################################################################################
#define   SCL      1
#define   SDA       2

#define   vfdsdrst   PORTA,0
#define   vfdsdclk   PORTA,1
#define   vfddata      PORTA,2
#define   vfdload      PORTA,3

#define   LDR      PORTB,3
#define   DownKey      PORTB,4
#define   UpKey      PORTB,5
#define   SetupKey   PORTB,6
;#################################################################################
;#################################################################################
I2C_PORT   Equ   PORTB
I2C_TRIS   Equ   TRISB

ErrFlag      Equ   0x00
StartFlag   Equ   0x01         ;flags used for received bit
One      Equ   0x02
Zero      Equ   0x03
Time      Equ   0x04         ;flag for setting time, line1 or line2

Chip_Read   Equ   0xD1         ;DS1307 address values
Chip_Write   Equ   0xD0

Buf_Size   Equ   0x03         ;buffer 3 bytes long
;#################################################################################
;    .d8888b. 88888888888     d8888 8888888b. 88888888888
;   d88P  Y88b    888        d88888 888   Y88b    888     
;   Y88b.         888       d88P888 888    888    888     
;    "Y888b.      888      d88P 888 888   d88P    888     
;       "Y88b.    888     d88P  888 8888888P"     888     
;         "888    888    d88P   888 888 T88b      888     
;   Y88b  d88P    888   d8888888888 888  T88b     888     
;    "Y8888P"     888  d88P     888 888   T88b    888     
;#################################################################################
      org   0x0000
      goto   Start
;################## INTERUPT ROUTINES ############################################
               org     0x0004
      movwf    temp_w
      swapf    STATUS,W
      bcf    STATUS,RP0
      movwf    temp_stat
      bsf   SDA_tmp,0
      clrf   counter1
      clrf   counter2
      bcf   intcon,intf
      swapf    temp_stat,W
      movwf    STATUS
      swapf    temp_w,F
      swapf    temp_w,W
               retfie
;###########
Num2rows   addwf   PCL,F
      goto   zero0
      goto   one1
      goto   two
      goto   three
      goto   four
      goto   five
      goto   six
      goto   seven
      goto   eight
      goto   nine
      retlw   0x00
;#################################################################################
;   888b     d888        d8888 8888888 888b    888
;   8888b   d8888       d88888   888   8888b   888
;   88888b.d88888      d88P888   888   88888b  888
;   888Y88888P888     d88P 888   888   888Y88b 888
;   888 Y888P 888    d88P  888   888   888 Y88b888
;   888  Y8P  888   d88P   888   888   888  Y88888
;   888   "   888  d8888888888   888   888   Y8888
;   888       888 d88P     888 8888888 888    Y888
;#################################################################################
Start
;#################################################################################
;#############   Remove  For PIC16F84A  ###########################################
      movlw   0x07   ; This And Next Line Not Needed For PIC16F84A
      movwf   CMCON   ;turn comparators off (make it like a 16F84)
;#############   Remove  For PIC16F84A  ###########################################
;#################################################################################
Initialise   clrf   count
      clrf   PORTA
      clrf   PORTB   
SetPorts   bsf    STATUS,RP0      ;select bank 1
;      movlw   0x00         ;make all LCD pins outputs
      clrf   TRISA
      movlw   b'11111111'      ;make all I2C port pins inputs
      movwf   TRISB
      clrf   OPTION_REG      ;,INTEDG , RB0 Interupt On Rising Edge
      bcf    STATUS,RP0      ;select bank 0
      movlw   0xff
      movwf   PORTA
      call   Long_Delay
      clrf   SDA_tmp
      bsf   SDA_tmp,0
      movlw   b'11100011'
      call   Init_SDA5708_Bri
;      call   Init_Colon
      call    seq_out
      movlw    B'10010000'       ;enable rb0 interrupt
      movwf    INTCON   
      goto   Main         ;main;comment out to set clock
                  ;using values loaded in fill_buf
;#################################################################################
;############# Inisialize SDA5708 In Bright Or Dimm ##############################
;#################################################################################
Init_SDA5708_Dim
      movwf   vfdsend
      call   datasend
      bsf   SDA_tmp,1
      return
Init_SDA5708_Bri
      movwf   vfdsend
      call   datasend
      bcf   SDA_tmp,1
      return
;#################################################################################
;################### CHECK DS1307 Running If Running #############################
;################### Then Read Else Setup Time And Settings ######################
;#################################################################################
; write 8 byte buffer to EEPROM
seq_out   ;   movlw   0x00
      clrf   Data_Page      ;check if ds1307 already initialized
      movlw   0x07
      movwf   Adr_Lo         ;
      call   Read_EEPROM
      movwf   count
      btfsc   count,4
      return            ; if yes return
      call   delay10
;      movlw   0x00         ;if not then initialize
      clrf   Data_Page      ;
;      movlw   0x00
      clrf   Adr_Lo         ;
      movlw   0x00
      call   Write_EEPROM      ; Seconds :00
      movlw   0x01
      movwf   Adr_Lo         ;
      movlw   0x00
      call   Write_EEPROM      ; Minutes :00
      movlw   0x02
      movwf   Adr_Lo         ;
      movlw   0x72
      call   Write_EEPROM      ; am/pm set hour 12:00
      movlw   0x07
      movwf   Adr_Lo         ;
      movlw   0x10
      call   Write_EEPROM      ; Square Wave Enable.
      return
;#################################################################################
;######## Display Routine Will Be Here Almost All Time's ########################
;#################################################################################
Main
      btfss   SetupKey
      goto   Set_key
      call   Delay10
      btfss   SDA_tmp,0
      goto   CounterZ
      clrf   Data_Page      ;set EEPROM page
      clrf   Adr_Lo         ;set EEPROM address      
      call   Seq_Read_EEPROM      ;read data in to buffer
      call   DispLED
      bcf   SDA_tmp,0
      goto   Main   ;loop

CounterZ;   call   Delay255
      incfsz   counter1,F
      goto   Main
;      incf   counter2,F
;      btfss   status,Z
;      goto   Main
      bsf   SDA_tmp,0
      goto   Main

;#################################################################################
;####################### Time Adjust Routines ####################################
;#################################################################################
Set_key      bcf    INTCON,INTE   ; Setup Key Has Been Pressed
      bsf   SDA_tmp,3
      Call   DispLED
      btfss   SetupKey   ; Wait Till Key Released
      goto   $-1
;##############
loopkeyHour   call   Delay100   ; Main Routine In Setup Hour Mode.
      btfss   UpKey
      goto   Hourplus
      call   Delay100
      btfss   DownKey
      goto   HourMinus
      call   Delay100
      btfss   SetupKey
      goto   loopkeyMin1
      goto   loopkeyHour
;##############
loopkeyMin1   bsf   SDA_tmp,4   ; Main Routine In Setup Minute Mode.
      Call   DispLED
      btfss   SetupKey
      goto   $-1
loopkeyMin   call   Delay100
      btfss   UpKey
      goto   Minplus
      call   Delay100
      btfss   DownKey
      goto   MinMinus
      call   Delay100
      btfss   SetupKey
      goto   editdone   ; Edit Done And Save The Values To RTC And Display
      goto   loopkeyMin
;##############
Hourplus
;      btfss   UpKey
;      goto   $-1
      swapf   buf2,W
      andlw   0x01
      movwf   hourten
      movf   buf2,W
      andlw   0x0F
      movwf   hourOne
      btfss   hourten,0   ; hour10 if 1 then See Update h1
      goto   h10_0      ; If Not 1 then Update h1 and see if >=10
h10_1      incf   hourOne,F   ; and if h1 >= 2 then set h10=0, h1=1
      movf   hourone,W
      xorlw   0x02
      btfsc   status,Z   ; If H1 = 2 then (h10 is already 1) Time Is 12 so set AM/PM
      goto   H_AP
      movf   hourone,W
      xorlw   0x03
      btfss   status,Z   ; skip if hour1 more than 3 then Set Time to h10=0 h1=1
      goto   okhr
      movlw   0x01      ; Set Time to h10=0 h1=1
      movwf   hourone
      clrf   hourten
      goto   okhr
H_AP      btfss   buf2,5      ; Time Is 12 so set AM/PM
      goto   $+3
      bcf   SDA_tmp,2
      goto   $+2
      bsf   SDA_tmp,2
      goto   okhr
h10_0      incf   hourOne,F   ; Inc H1 and if h1 >= 9 then set h10=1, h1=0
      movf   hourone,W
      xorlw   0x0A
      btfss   status,Z   ; if h1 >=10 then Update H10
      goto   okhr
      clrf   hourone
      movlw   0x01
      movwf   hourten
okhr      swapf   hourten,W
      iorwf   hourone,W
      movwf   buf2
      btfsc   SDA_tmp,2
      goto   $+4
      movlw   0x40      ; AM
      addwf   buf2,F
      goto   $+3
      movlw   0x60      ; PM
      addwf   buf2,F
      call   DispLED
      call   Delay255
      btfsc   UpKey
      goto   loopkeyHour
      goto   Hourplus
;##############
HourMinus
;      btfss   DownKey      ; Wait For Key Release
;      GoTo   $-1
      swapf   buf2,W
      andlw   0x01
      movwf   hourten
      movf   buf2,W
      andlw   0x0F
      movwf   hourOne
      btfss   HourTen,0   ; skip if HourTen = 1
      GoTo   h10_0_minus
      movf   HourOne,W   ; if HourTen = 0 and see If HourOne is 0
      btfsc   status,Z   ; Then Skip to ---> h10_1_mi
      GoTo   h10_1_mi
h10_1_minus   decf   HourOne,F   ; If HourOne Not 0 Then decrement HourOne And Return
      GoTo   okhr_minus
h10_1_mi   movlw   0x09      ; If HourTen And HourOne is 0 then -
      movwf   HourOne      ; Clear HourTen and 9 -> HourOne [so hour is 09]
      clrf   HourTen
      GoTo   okhr_minus
h10_0_minus   decfsz   HourOne,F   ; if HourTen = 1 then decrement HourOne And Skip If Zero
      GoTo   okhr_minus   ; If Else return to keys
      movlw   0x02      ; If HourOne 0 Then Move 2 -> HourOne & 1 -> HourTen -
      movwf   HourOne      ; [so hour is 12] And Return
      movlw   0x01
      movwf   HourTen
      btfss   buf2,5
      goto   $+3
      bcf   SDA_tmp,2
      goto   $+2
      bsf   SDA_tmp,2
okhr_minus   swapf   hourten,W
      iorwf   hourone,W
      movwf   buf2
      btfsc   SDA_tmp,2
      goto   $+4
      movlw   0x40      ; AM
      addwf   buf2,F
      goto   $+3
      movlw   0x60      ; PM
      addwf   buf2,F
      call   DispLED
      call   Delay255
      btfsc   DownKey
      goto   loopkeyHour
      goto   HourMinus
;##############
Minplus
;      btfss   UpKey
;      goto   $-1
      swapf   buf1,W
      andlw   0x0F
      movwf   minten
      movf   buf1,W
      andlw   0x0F
      movwf   minOne
      incf   minOne,F
      movf   minOne,W
      xorlw   0x0A
      btfss   status,Z   ; if min1 >= 10 then increment min10
      goto   okmin
      clrf   minOne
      incf   minten,F
      movf   minten,W
      xorlw   0x06
      btfss   status,Z   ; if min10 >= 6 then Clear min10
      goto   okmin
      clrf   minten
okmin      swapf   minten,W
      iorwf   minOne,W
      movwf   buf1
      call   DispLED
      call   Delay255
      btfsc   UpKey
      goto   loopkeyMin
      goto   Minplus
;##############
MinMinus
;      btfss   DownKey      ; Wait For Key Release
;      GoTo   $-1
      swapf   buf1,W
      andlw   0x0F
      movwf   minten
      movf   buf1,W
      andlw   0x0F
      movwf   minOne
      movf   MinOne,W   ; Check If MinOne = 0
      btfss   status,Z   ; If 0 Then Skip
      GoTo   MinusMin2   ; If Not 0 Then GoTo ---> MinusMin2
      movf   MinTen,W   ; Check If MinTen = 0 (Already Checked MinOne = 0)
      btfsc   status,Z
      GoTo   MinusMin3
MinusMin4   movlw   0x09      ; If MinOne = 0 & MinTen Not 0 Then Set 9 ->MinOne And -
      movwf   MinOne      ; decrement MinTen And Return
      decf   MinTen,F
      GoTo   okminMinus
MinusMin3   movlw   0x05      ; If MinOne And MinTen = 0 Then Set 5 ->MinTen & 9 ->MinOne
      movwf   MinTen      ; [so Mins is 59]
      movlw   0x09
      movwf   MinOne
      GoTo   okminMinus
MinusMin2   decf   MinOne,F
okminMinus   swapf   minten,W
      iorwf   minOne,W
      movwf   buf1
      call   DispLED
      call   Delay255
      btfsc   UpKey
      goto   loopkeyMin
      goto   MinMinus
;##############
EditDone
      btfss   SetupKey
      goto   $-1
      clrf   buf
;      movlw   0x00
      clrf   Data_Page      ;set EEPROM page
;      movlw   0x00         ;don't read control register
      clrf   Adr_Lo         ;set EEPROM address      
      call   Seq_Write_EEPROM
      bsf   SDA_tmp,0
      bcf   SDA_tmp,3
      bcf   SDA_tmp,4
      call   DispLED
      call   Long_Delay
      bsf    INTCON,INTE
      goto   Main
ExitSetup
      clrf   buf
      call   Seq_Read_EEPROM
      bsf   SDA_tmp,0
      bcf   SDA_tmp,3
      bcf   SDA_tmp,4
      bsf    INTCON,INTE
      call   DispLED
      goto   Main
;#################################################################################
;#################### CHECK FOR BRIGHTNESS AND DISPLAY ###########################
;#################################################################################
DispLED
   
      call   DimOrBright
      call   hour
;      call   min
;      call   sec
;      call   Init_Colon
      return
; Bit1   0 = Bright   1 = DIM
DimOrBright
      btfsc   SDA_tmp,3   ; If Setup Mode Then Bright
      goto   Bright
      btfsc   LDR      ;PORTB,3
      goto   Bright
Dimmm      btfsc   SDA_tmp,1
      return
      movlw   b'11100110'
      call   Init_SDA5708_Dim
      return
Bright      btfss   SDA_tmp,1
      return
      movlw   b'11100011'
      call   Init_SDA5708_Bri
      return
;#################################################################################
;################## SHOW TIME ON DISPLAY #########################################
;#################################################################################
Hour      ;   swap buf2>W and 'and' with 0x01 and call table and send to digit 0
      ;   'and' with 0x0f call table and send to digit 1
      movlw   b'10100000'   ;digit0
      movwf   digit
      swapf   buf2,W
      andlw   0x01
      btfsc   status,Z
      goto   $+3
      call   Num2rows
      goto   $+2
      call   Blank
      call   LedDispSend
      movlw   b'10100001'   ;digit1
      movwf   digit
      movf   buf2,W
      andlw   0x0f
      call   Num2rows
      call   LedDispSend
      movlw   b'10100010'   ;digit2
      movwf   digit
      call   Colon
      call   LedDispSend
;      return
;digi 2 and 5 send ":" on initiation
min      ;swap buf1>W and 'and' with 0x07 call table and send to digit 6
         ;   'and' with 0x0f call table and send to digit 7
      movlw   b'10100011'   ;digit3
      movwf   digit
      swapf   buf1,W
      andlw   0x07
      call   Num2rows
      call   LedDispSend
      movlw   b'10100100'   ;digit4
      movwf   digit
      movf   buf1,W
      andlw   0x0f
      call   Num2rows
      call   LedDispSend
      movlw   b'10100101'   ;digit5 "AM PM Goes Here"
      movwf   digit
      btfss   buf2,5      ;buf2,bit 5 holds AM=0 PM=1
      goto   $+3
      call   ColonPm
      goto   $+2
      call   ColonAm
      call   LedDispSend
;      return
      btfsc   SDA_tmp,3   ; If Setup Mode Then Show ST on 6th and 7th Digit
      goto   sec_Hmode
sec;      swap buf>W and 'and' with 0x07 call table and send to digit 3
;      'and' with 0x0f call table and send to digit 4
      movlw   b'10100110'   ;digit6
      movwf   digit
      swapf   buf,W
      andlw   0x07
      call   Num2rows
      call   LedDispSend
      movlw   b'10100111'   ;digit7
      movwf   digit
      movf   buf,W
      andlw   0x0f
      call   Num2rows
      call   LedDispSend
      return
sec_Hmode   ;   swap buf>W and 'and' with 0x07 call table and send to digit 3
;      'and' with 0x0f call table and send to digit 4
      btfsc   SDA_tmp,4   ; If Setup MinMode Then Bright
      goto   Sec_MinMode
      movlw   b'10100110'   ;digit6
      movwf   digit
      Movlw   b'01110'         ;S
      Movwf   row0
      Movlw   b'10001'
      Movwf   row1
      Movlw   b'11000'
      Movwf   row2
      Movlw   b'00100'
      Movwf   row3
      Movlw   b'00011'
      Movwf   row4
      Movlw   b'10001'
      Movwf   row5
      Movlw   b'01110'
      Movwf   row6
      call   LedDispSend
      movlw   b'10100111'   ;digit7
      movwf   digit
      Movlw   b'10001'         ;H
      Movwf   row0
      Movlw   b'10001'
      Movwf   row1
      Movlw   b'10001'
      Movwf   row2
      Movlw   b'11111'
      Movwf   row3
      Movlw   b'10001'
      Movwf   row4
      Movlw   b'10001'
      Movwf   row5
      Movlw   b'10001'
      Movwf   row6
      call   LedDispSend
      return
Sec_MinMode
      movlw   b'10100110'   ;digit6
      movwf   digit
      Movlw   b'01110'         ;S
      Movwf   row0
      Movlw   b'10001'
      Movwf   row1
      Movlw   b'11000'
      Movwf   row2
      Movlw   b'00100'
      Movwf   row3
      Movlw   b'00011'
      Movwf   row4
      Movlw   b'10001'
      Movwf   row5
      Movlw   b'01110'
      Movwf   row6
      call   LedDispSend
      movlw   b'10100111'   ;digit7
      movwf   digit
      Movlw   b'10001'         ;M
      Movwf   row0
      Movlw   b'11011'
      Movwf   row1
      Movlw   b'11011'
      Movwf   row2
      Movlw   b'10101'
      Movwf   row3
      Movlw   b'10001'
      Movwf   row4
      Movlw   b'10001'
      Movwf   row5
      Movlw   b'10001'
      Movwf   row6
      call   LedDispSend
      return
LedDispSend
      movf   digit,W      ; Digit
      movwf   vfdsend   
      call   datasend
      movf   row0,W      ; Row 0
      movwf   vfdsend   
      call   datasend
      movf   row1,W      ; Row 1
      movwf   vfdsend   
      call   datasend
      movf   row2,W      ; Row 2
      movwf   vfdsend
      call   datasend
      movf   row3,W      ; Row 3
      movwf   vfdsend   
      call   datasend
      movf   row4,W      ; Row 4
      movwf   vfdsend   
      call   datasend
      movf   row5,W      ; Row 5
      movwf   vfdsend
      call   datasend
      movf   row6,W      ; Row 6
      movwf   vfdsend   
      call   datasend
      Return

;#################################################################################
;   8888888  .d8888b.   .d8888b. 
;     888   d88P  Y88b d88P  Y88b
;     888          888 888    888
;     888        .d88P 888       
;     888    .od888P"  888       
;     888   d88P"      888    888
;     888   888"       Y88b  d88P
;   8888888 888888888   "Y8888P" 
;#################################################################################
;Start of I2C routines

Write_EEPROM               ; write W register to address Adr_Lo
      movwf   DAT_VAL         ; save W
      call   I2C_Start
      call   I2C_Set_Write
      btfsc   I2Cflags, 0
      call   Error_Routine
      call   I2C_Lo_Adr
      btfsc   I2Cflags, 0
      call   Error_Routine
           movf   DAT_VAL,    W   ; send the actual data
           movwf   OutputByte
           call   I2C_Out
           call   I2C_NAK
      btfsc   I2Cflags, 0
      call   Error_Routine
           call   I2C_Stop
      call   WaitForWrite
           return

Read_EEPROM               ; reads data at location specified in Adr_Lo
                  ; and page specified in Data_Page
                  ; returns result in W
      call    I2C_Start
      call   I2C_Set_Write
      btfsc   I2Cflags, 0
      call   Error_Routine
      call   I2C_Lo_Adr
      btfsc   I2Cflags, 0
      call   Error_Routine
           call    I2C_Start      ; note there is no STOP
      call   I2C_Set_Read
      btfsc   I2Cflags, 0
      call   Error_Routine
           call    I2C_Read      ; fetch the byte
           call    I2C_Send_NAK      ; send no acknowledgement
           call    I2C_Stop
      movf    InputByte,    W   ; return the byte in W
           return

Seq_Write_EEPROM            ; write buffer to address Adr_Lo
      movwf   DAT_VAL         ; save W
      call   I2C_Start
      call   I2C_Set_Write
      btfsc   I2Cflags, 0
      call   Error_Routine
      call   I2C_Lo_Adr
      btfsc   I2Cflags,    0
      call   Error_Routine
      movlw    buf         ; now write Buff_Size bytes to EEPROM
      movwf    FSR      
      movlw    Buf_Size
      movwf    N

SEQ_WRITE_1:
      movf    INDF,       w   ; fetch the data byte from the buffer
           movwf   OutputByte
           call   I2C_Out
           call    I2C_NAK
      btfsc   I2Cflags, 0
      call   Error_Routine
      incf    FSR,       f
      decfsz    N,       f
      goto    SEQ_WRITE_1
           call   I2C_Stop
      call   WaitForWrite
           return

Seq_Read_EEPROM               ; reads data at location specified in Adr_Lo
                  ; and page specified in Data_Page
                  ; returns 4 byte result in buf
      call    I2C_Start
      call   I2C_Set_Write
      btfsc   I2Cflags, 0
      call   Error_Routine
      call   I2C_Lo_Adr
      btfsc   I2Cflags, 0
      call   Error_Routine
           call    I2C_Start      ; note there is no STOP
      call   I2C_Set_Read
      btfsc   I2Cflags, 0
      call   Error_Routine
      movlw    buf         ; now sequentially read bytes from EEPROM
      movwf    FSR      
      movlw    Buf_Size
      movwf    N
SEQ_READ_1:
      call    I2C_Read      ; fetch each byte from EEPROM
      movf    InputByte,W
      movwf    INDF         ; and save in data buffer
      incf    FSR,F
      decfsz    N,       f
      goto    SEQ_READ_2      ; not done
      goto    SEQ_READ_3
SEQ_READ_2:
      call    I2C_ACK         ; if not done, send an ACK and continue
      goto    SEQ_READ_1
SEQ_READ_3:
           call    I2C_Send_NAK      ; send no acknowledgement
           call    I2C_Stop
      movf    InputByte,    w   ; return the byte in W
           return

; The following routines are low level I2C routines applicable to most
; interfaces with I2C devices.

I2C_Read               ; read byte on i2c bus
      clrf    InputByte
      movlw    0x08
      movwf    _N         ; set index to 8   
      call   HIGH_SDA      ; be sure SDA is configured as input
In_Bit
      call    HIGH_SCL      ; clock high
      btfss    I2C_PORT,SDA   ; test SDA bit
      goto   In_Zero
      goto   In_One

In_Zero
      bcf    STATUS,    C   ; clear carry
      rlf    InputByte,    f   ; i_byte = i_byte << 1 | 0
      goto    Cont_In

In_One
      bsf   STATUS,    C   ; set carry
      rlf    InputByte,    f

Cont_In
      call   LOW_SCL         ; bring clock low
      decfsz    _N,    F      ; decrement index
      goto    In_Bit
      return

I2C_Out:               ; send w register on I2C bus
           movwf    OutputByte
      movlw    0x08
      movwf    _N
Out_Bit:
      bcf    STATUS,C   ; clear carry
      rlf    OutputByte,    f   ; left shift, most sig bit is now in carry
      btfss    STATUS,    C   ; if one, send a one
      goto    Out_Zero
      goto    Out_One

Out_Zero:
      call    LOW_SDA         ; SDA at zero
      call    Clock_Pulse   
      call    HIGH_SDA
      goto    Out_Cont

Out_One:
      call    HIGH_SDA      ; SDA at logic one
      call    Clock_Pulse
Out_Cont:
      decfsz    _N,F   ; decrement index
      goto    Out_Bit
      return   

;;;;;;

I2C_NAK:               ; bring SDA high and clock
      call    HIGH_SDA
      call    HIGH_SCL

      clrf   count         ; wait for ACK
WaitForACK   incf   count, f      ; increase timeout counter each time ACK is not received
      btfsc   STATUS, Z
      goto   No_ACK_Rec
      btfsc   I2C_PORT,SDA   ; test pin. If clear, EEPROM is pulling SDA low for ACK
      goto   WaitForACK      ; ...otherwise, continue to wait
      bcf   I2Cflags, 0      ; clear flag bit (ACK received)
      call    LOW_SCL
      return

I2C_Send_NAK:               ; bring SDA high and clock
      call    HIGH_SDA
      call    Clock_Pulse
      return

WaitForWrite               ; poll ACK for write timing
      call    I2C_Start
      call   I2C_Set_Write
      btfsc   I2Cflags, 0
      goto   WaitForWrite
      return

;------ No ACK received from slave (must use "return" from here)
;; Typically, set a flag bit to indicate failed write and check for it upon return.
No_ACK_Rec
      bsf   I2Cflags, 0      ; set flag bit
      retlw 0x00

;------ No ACK received from slave.  This is the error handler.

Error_Routine
      retlw 0x00

I2C_ACK:
      call    LOW_SDA
      call    Clock_Pulse
      return

I2C_Start:            
;      call    LOW_SCL
;      call    HIGH_SDA
      call    HIGH_SCL
      call    LOW_SDA         ; bring SDA low while SCL is high
      call    LOW_SCL
      return

I2C_Stop:
      call    LOW_SCL
      call    LOW_SDA
      call    HIGH_SCL
      call    HIGH_SDA      ; bring SDA high while SCL is high
;      call    LOW_SCL
      return

I2C_Set_Write   rlf    Data_Page,    W   ; shift device page
      andlw   b'00001110'      ; AND to make sure in range
           iorlw    Chip_Write
           call    I2C_Out
           call    I2C_NAK
      return

I2C_Set_Read   rlf    Data_Page,    W   ; shift device page
      andlw   b'00001110'      ; AND to make sure in range
           iorlw    Chip_Read
           call    I2C_Out
           call    I2C_NAK
      return

I2C_Lo_Adr      movf    Adr_Lo,    W   ; send low byte of address
           call    I2C_Out
           call    I2C_NAK
      return

Clock_Pulse:               ; SCL momentarily to logic one
      call    HIGH_SCL
      call    LOW_SCL
      nop
      nop
      nop
      nop
      return      

HIGH_SDA:               ; high impedance by making SDA an input
      bsf    STATUS,    RP0   ; bank 1
      bsf    I2C_TRIS,    SDA   ; make SDA pin an input
      bcf    STATUS,    RP0   ; back to bank 0
      nop
      nop
      nop
      nop
      return

LOW_SDA:
      bcf    I2C_PORT,    SDA   
      nop
      nop
      nop
      nop
      bsf    STATUS,    RP0   ; bank 1
      bcf    I2C_TRIS,    SDA   ; make SDA pin an output
      bcf    STATUS,    RP0   ; back to bank 0
      return

HIGH_SCL:
      bsf    STATUS,    RP0   ; bank 1
      bsf    I2C_TRIS,    SCL   ; make SCL pin an input
      bcf    STATUS,    RP0   ; back to bank 0
      nop
      nop
      nop
      nop
      return

LOW_SCL:
      bcf   I2C_PORT,    SCL
      bsf    STATUS,    RP0   ; bank 1
      bcf    I2C_TRIS,    SCL   ; make SCL pin an output
      bcf    STATUS,    RP0   ; back to bank 0
      nop
      nop
      nop
      nop
      return

; End of I2C routines
;#################################################################################
;    .d8888b.  8888888b.        d8888 888888888 8888888888  .d8888b.   .d8888b. 
;   d88P  Y88b 888  "Y88b      d88888 888             d88P d88P  Y88b d88P  Y88b
;   Y88b.      888    888     d88P888 888            d88P  888    888 Y88b. d88P
;    "Y888b.   888    888    d88P 888 8888888b.     d88P   888    888  "Y88888" 
;       "Y88b. 888    888   d88P  888      "Y88b 88888888  888    888 .d8P""Y8b.
;         "888 888    888  d88P   888        888  d88P     888    888 888    888
;   Y88b  d88P 888  .d88P d8888888888 Y88b  d88P d88P      Y88b  d88P Y88b  d88P
;    "Y8888P"  8888888P" d88P     888  "Y8888P" d88P        "Y8888P"   "Y8888P" 
;#################################################################################
datasend
   movlw   0x08
   movwf   countsda   
   bcf   vfdload   ; Load Low
   bcf   vfdsdclk
datasend1
   btfss   vfdsend,0
   bcf   vfddata
   btfsc   vfdsend,0
   bsf   vfddata
   RRF   vfdsend,1
   bsf   vfdsdclk
   bcf   vfdsdclk
   bsf   vfddata
   decfsz   countsda,F   ; Lösche ein bit von Count wenn Count = 0 dan F = 1
         ;und überspringe den nästen befehl
   goto   datasend1   ; Gehe zu WaitWait
   bcf   status,c
   bsf   vfdload   ; Load high
   return

Blank
   clrf   row0         ;" "
   clrf   row1
   clrf   row2
   clrf   row3
   clrf   row4
   clrf   row5
   clrf   row6
   Return

Zero0
   Movlw   b'01110'         ;0
   Movwf   row0
   Movlw   b'10001'
   Movwf   row1
   Movlw   b'10001'
   Movwf   row2
   Movlw   b'10001'
   Movwf   row3
   Movlw   b'10001'
   Movwf   row4
   Movlw   b'10001'
   Movwf   row5
   Movlw   b'01110'
   Movwf   row6
   Return

One1
   Movlw   b'00100'         ;1
   Movwf   row0
   Movlw   b'01100'
   Movwf   row1
   Movlw   b'00100'
   Movwf   row2
   Movlw   b'00100'
   Movwf   row3
   Movlw   b'00100'
   Movwf   row4
   Movlw   b'00100'
   Movwf   row5
   Movlw   b'01110'
   Movwf   row6
   Return

Two
   Movlw   b'01110'         ;2
   Movwf   row0
   Movlw   b'10001'
   Movwf   row1
   Movlw   b'00010'
   Movwf   row2
   Movlw   b'00100'
   Movwf   row3
   Movlw   b'01000'
   Movwf   row4
   Movlw   b'10000'
   Movwf   row5
   Movlw   b'11111'
   Movwf   row6
   Return

Three
   Movlw   b'11111'         ;3
   Movwf   row0
   Movlw   b'00001'
   Movwf   row1
   Movlw   b'00010'
   Movwf   row2
   Movlw   b'00110'
   Movwf   row3
   Movlw   b'00001'
   Movwf   row4
   Movlw   b'10001'
   Movwf   row5
   Movlw   b'01110'
   Movwf   row6
   Return

Four
   Movlw   b'00010'         ;4
   Movwf   row0
   Movlw   b'00110'
   Movwf   row1
   Movlw   b'01010'
   Movwf   row2
   Movlw   b'10010'
   Movwf   row3
   Movlw   b'11111'
   Movwf   row4
   Movlw   b'00010'
   Movwf   row5
   Movlw   b'00010'
   Movwf   row6
   Return

Five
   Movlw   b'11111'         ;5
   Movwf   row0
   Movlw   b'10000'
   Movwf   row1
   Movlw   b'10000'
   Movwf   row2
   Movlw   b'11110'
   Movwf   row3
   Movlw   b'00001'
   Movwf   row4
   Movlw   b'10001'
   Movwf   row5
   Movlw   b'01110'
   Movwf   row6
   Return

Six
   Movlw   b'01111'         ;6
   Movwf   row0
   Movlw   b'10000'
   Movwf   row1
   Movlw   b'10000'
   Movwf   row2
   Movlw   b'11110'
   Movwf   row3
   Movlw   b'10001'
   Movwf   row4
   Movlw   b'10001'
   Movwf   row5
   Movlw   b'01110'
   Movwf   row6
   Return

Seven
   Movlw   b'11111'         ;7
   Movwf   row0
   Movlw   b'00001'
   Movwf   row1
   Movlw   b'00010'
   Movwf   row2
   Movlw   b'00100'
   Movwf   row3
   Movlw   b'00100'
   Movwf   row4
   Movlw   b'00100'
   Movwf   row5
   Movlw   b'00100'
   Movwf   row6
   Return

Eight
   Movlw   b'01110'         ;8
   Movwf   row0
   Movlw   b'10001'
   Movwf   row1
   Movlw   b'10001'
   Movwf   row2
   Movlw   b'01110'
   Movwf   row3
   Movlw   b'10001'
   Movwf   row4
   Movlw   b'10001'
   Movwf   row5
   Movlw   b'01110'
   Movwf   row6
   Return

Nine
   Movlw   b'01110'         ;9
   Movwf   row0
   Movlw   b'10001'
   Movwf   row1
   Movlw   b'10001'
   Movwf   row2
   Movlw   b'01111'
   Movwf   row3
   Movlw   b'00001'
   Movwf   row4
   Movlw   b'00001'
   Movwf   row5
   Movlw   b'11110'
   Movwf   row6
   Return

Colon
   Movlw   b'00000'         ;":"
   Movwf   row0
   Movlw   b'01100'
   Movwf   row1
   Movlw   b'01100'
   Movwf   row2
   Movlw   b'00000'
   Movwf   row3
   Movlw   b'01100'
   Movwf   row4
   Movlw   b'01100'
   Movwf   row5
   Movlw   b'00000'
   Movwf   row6
   Return

ColonAm
   Movlw   b'00100'         ;"am"
   Movwf   row0
   Movlw   b'01010'
   Movwf   row1
   Movlw   b'01110'
   Movwf   row2
   Movlw   b'01010'
   Movwf   row3
   Movlw   b'00000'
   Movwf   row4
   Movlw   b'01010'
   Movwf   row5
   Movlw   b'10101'
   Movwf   row6
   Return

ColonPm
   Movlw   b'01110'         ;"pm"
   Movwf   row0
   Movlw   b'01010'
   Movwf   row1
   Movlw   b'01110'
   Movwf   row2
   Movlw   b'01000'
   Movwf   row3
   Movlw   b'00000'
   Movwf   row4
   Movlw   b'01010'
   Movwf   row5
   Movlw   b'10101'
   Movwf   row6
   Return
;#################################################################################
;   8888888b.  8888888888 888             d8888 Y88b   d88P
;   888  "Y88b 888        888            d88888  Y88b d88P 
;   888    888 888        888           d88P888   Y88o88P   
;   888    888 8888888    888          d88P 888    Y888P   
;   888    888 888        888         d88P  888     888     
;   888    888 888        888        d88P   888     888     
;   888  .d88P 888        888       d8888888888     888     
;   8888888P"  8888888888 88888888 d88P     888     888     
;#################################################################################
;Delay routines

Long_Delay
      call   Delay255
      call   Delay255
      call   Delay255
      call   Delay255
      return

Delay255   movlw   0xff      ;delay 255 mS
      goto   d0
Delay100   movlw   d'100'      ;delay 100mS
      goto   d0
Delay50      movlw   d'50'      ;delay 50mS
      goto   d0
Delay20      movlw   d'20'      ;delay 20mS
      goto   d0
Delay10      movlw   d'10'      ;delay 10mS
      goto   d0
Delay5      movlw   0x05      ;delay 5.000 ms (4 MHz clock)
d0      movwf   count1
d1      movlw   0xC7
      movwf   counta
      movlw   0x01
      movwf   countb
Delay_0      decfsz   counta, f
      goto   $+2
      decfsz   countb, f
      goto   Delay_0

      decfsz   count1   ,F
      goto   d1
      retlw   0x00

;end of Delay routines

   end
;#################################################################################
;   8888888888 888b    888 8888888b. 
;   888        8888b   888 888  "Y88b
;   888        88888b  888 888    888
;   8888888    888Y88b 888 888    888
;   888        888 Y88b888 888    888
;   888        888  Y88888 888    888
;   888        888   Y8888 888  .d88P
;   8888888888 888    Y888 8888888P" 
;#################################################################################
Biliyormusun dedi, ben ne yaptiysam kader icabi yaptim dedi. Ben gene sustum.... Kimbilir sende belki kaderin memurusun vazifeni yapiyorsun dedi.