program Dump_2_2 dim delim as string[1] dim addr as word dim crlf as string[2] dim txt as string[10] dim k,l as byte dim m as word dim time_str as string[8] dim date_str as string[10] dim day,mon,yr as byte dim day_str,mon_str,yr_str as string[3] dim sec,min,hr as byte dim sec_str,min_str,hr_str as string[3] dim intv_str as string[3] dim intv as word sub procedure EEWrite(dim addr as word, dim himem as byte, dim data as byte) dim a as byte delay_ms(5) if himem<>0 then a=8 else a=0 end if soft_i2c_start() soft_i2c_write($A0+a) soft_i2c_write(hi(addr)) soft_i2c_write(lo(addr)) soft_i2c_write(data) soft_i2c_stop() end sub sub function EERead(dim addr as word, dim himem as byte) as byte dim a as byte if himem<>0 then a=8 else a=0 end if soft_i2c_start() soft_i2c_write($A0+a) soft_i2c_write(hi(addr)) soft_i2c_write(lo(addr)) soft_i2c_start() soft_i2c_write($A1+a) result=soft_i2c_Read(0) soft_i2c_stop() end sub sub procedure ClrProm() for k=$1d to $24 Usart_write(Eeprom_Read(k))'ESC [2J next k for l=$00 to $FF Usart_write(13) Usart_write_text("Erasing: /") for k=$00 to $3F addr=l*$100+k EEWrite(addr,0,$FF) delay_ms(5) next k Usart_write(13) Usart_write_text("Erasing: -") for k=$40 to $7F addr=l*$100+k EEWrite(addr,0,$FF) delay_ms(5) next k Usart_write(13) Usart_write_text("Erasing: \") for k=$80 to $AF addr=l*$100+k EEWrite(addr,0,$FF) delay_ms(5) next k Usart_write(13) Usart_write_text("Erasing: |") for k=$B0 to $FF addr=l*$100+k EEWrite(addr,0,$FF) delay_ms(5) next k next l EEWrite($FFF0,1,$00) delay_ms(5) EEWrite($FFF1,1,$00) delay_ms(5) Usart_Write_Text(crlf) Usart_Write_Text(crlf) end sub sub Procedure Get_Time() soft_i2c_start() soft_i2c_write($D0) soft_i2c_write($00) soft_i2c_stop soft_i2c_start soft_i2c_write($D1) sec=bcd2dec(soft_i2c_read(1)) min=bcd2dec(soft_i2c_read(1)) hr=bcd2dec(soft_i2c_read(0)) soft_i2c_stop bytetostr(hr,hr_str) bytetostr(hr,hr_str) bytetostr(min,min_str) bytetostr(sec,sec_str) time_str[0]=hr_str[1] time_str[1]=hr_str[2] if min < 10 then time_str[3]="0" else time_str[3]=min_str[1] end if time_str[4]=min_str[2] if sec < 10 then time_str[6]="0" else time_str[6]=sec_str[1] end if time_str[7]=sec_str[2] end sub sub procedure Set_Time() Usart_Write_Text(crlf) Usart_write_text("New Time ? ") do loop until Usart_Data_Ready() = 1 Usart_Read_Text(time_str,delim) sec_str[1]=time_str[6] sec_str[2]=time_str[7] min_str[1]=time_str[3] min_str[2]=time_str[4] hr_str[1]=time_str[0] hr_str[2]=time_str[1] sec=strtoint(sec_str) min=strtoint(min_str) hr=strtoint(hr_str) soft_i2c_start() soft_i2c_write($D0) soft_i2c_write($00) soft_i2c_write(dec2bcd(sec)) 'write Second soft_i2c_write(dec2bcd(min)) 'write Minute soft_i2c_write(dec2bcd(hr)) 'write Hour soft_i2c_stop end sub sub Procedure Get_Date() soft_i2c_start() soft_i2c_write($D0) soft_i2c_write($04) soft_i2c_stop soft_i2c_start soft_i2c_write($D1) day=bcd2dec(soft_i2c_read(1)) mon=bcd2dec(soft_i2c_read(1)) yr=bcd2dec(soft_i2c_read(0)) soft_i2c_stop bytetostr(yr,yr_str) bytetostr(yr,yr_str) bytetostr(mon,mon_str) bytetostr(day,day_str) date_str[8]=yr_str[1] date_str[9]=yr_str[2] if mon < 10 then date_str[0]="0" else date_str[0]=mon_str[1] end if date_str[1]=mon_str[2] if day < 10 then date_str[3]="0" else date_str[3]=day_str[1] end if date_str[4]=day_str[2] end sub sub procedure Set_Date() Usart_Write_Text(crlf) Usart_write_text("New Date ? ") do loop until Usart_Data_Ready() = 1 Usart_Read_Text(date_str,delim) day_str[1]=date_str[3] day_str[2]=date_str[4] mon_str[1]=date_str[0] mon_str[2]=date_str[1] yr_str[1]=date_str[8] yr_str[2]=date_str[9] day=strtoint(day_str) mon=strtoint(mon_str) yr=strtoint(yr_str) soft_i2c_start() soft_i2c_write($D0) soft_i2c_write($04) soft_i2c_write(dec2bcd(day)) 'write Second soft_i2c_write(dec2bcd(mon)) 'write Minute soft_i2c_write(dec2bcd(yr)) 'write Hour soft_i2c_stop end sub sub procedure Set_Intv() intv=eeread($FFF2,1) bytetostr(intv,intv_str) Usart_write_Text(crlf) Usart_write_Text(crlf) usart_write_text("Current Interval: ") Usart_write_Text(intv_str) Usart_write_Text(crlf) usart_write_text("Input New Interval: ") do loop until Usart_Data_Ready() = 1 Usart_Read_Text(intv_str,delim) Usart_write_Text(crlf) intv=strtoword(intv_str) eewrite($FFF2,1,lo(intv)) end sub sub procedure Title() dim addrh,addrl as byte dim addr_str as string[5] usart_write($1B) Usart_write_text("[2JDump 2.2") Usart_write_text(crlf) Usart_write_text(crlf) Get_Time usart_write_text("Time: ") Usart_write_text(Time_Str) Usart_write_text(crlf) Get_Date usart_write_text("Date: ") Usart_write_text(Date_Str) Usart_write_text(crlf) Usart_write_text(crlf) addrh=EERead($FFF0,1) addrl=EERead($FFF1,1) addr=addrh*$100+addrl intv=eeread($FFF2,1) bytetostr(intv,intv_str) usart_write_text("Interval: ") Usart_write_Text(intv_str) Usart_Write_Text(crlf) usart_write_text(" Pointer: ") wordtostr(addr,addr_str) usart_write_text(addr_str) Usart_Write_Text(crlf) Usart_Write_Text(crlf) for k=$10 to $D6 Usart_Write(eeprom_Read(k)) next k end sub main: usart_init (9600) OSCCON = 0x70 ANSEL = 0x03 TRISA=0x03 TXSTA = 0x24 RCSTA = 0x90 ADCON0=%11000001 ADCON1 = $80 time_str="00:00:00" date_str="00/00/2000" addr=$00 Soft_I2C_Config(PORTA, 2, 3) crlf=chr(13) + chr(10) 'Set RTC to output 1Hz signal soft_i2c_start() soft_i2c_write($D0) soft_i2c_write($07) soft_i2c_write(%00010000) soft_i2c_stop 'Send Header out to PC Title delim = "\" loop: If Usart_Data_Ready() = 1 Then Usart_Read_Text(txt,delim) Gosub Sort End If goto loop Sort: If STRCMP(txt,"dump")=0 Then Usart_write_text(crlf) Usart_write_text(crlf) for m=0 to addr Usart_Write(EERead(m,0)) next m End If If STRCMP(txt,"dump all")=0 Then Usart_write_text(crlf) Usart_write_text(crlf) for addr=$0000 to $FF00 Usart_Write(EERead(addr,0)) next addr End If If STRCMP(txt,"clr")=0 Then ClrProm End If If STRCMP(txt,"reset")=0 Then EEWrite($FFF0,1,$00) EEWrite($FFF1,1,$00) End If If STRCMP(txt,"set time")=0 Then Set_Time End If If STRCMP(txt,"set date")=0 Then Set_Date End If If STRCMP(txt,"set intv")=0 Then Set_Intv End If Title Return end.