The atmel recives data ,if data corect it saves it into an eeprom (fm24c256)the only problem i have is that when write is performed it adds at the end of the data string to be saved some trash. If there is someone willing to help plz mail me: geosan1638@yahoo.com
Hi, Please post your code so that we can have a look at it... Rgds Raj Shetgar
; $mod51 wena equ p3.3 sda equ p3.5 scl equ p3.4 DSEG AT 0020H ORG 0020H ; stack origin stack: DS 0020H ; stack depth scan1: ds 1 ;hold 1. scan oldkey: ds 1 ;hold old key CSEG ORG 0000H ; power on/reset vector jmp on_reset ORG 0003H ; external interrupt 0 vector reti ORG 000BH ; timer 0 overflow vector reti ; undefined ORG 0013H ; external interrupt 1 vector reti ORG 001BH ; timer 1 overflow vector reti ; undefined ORG 0023H ; serial I/O interrupt vector reti ; undefined ORG 0040H ; begin constant data space ;----------------------------------------PROGRAM START --------------- ORG 00E0H ; begin code space USING 0 ; register bank zero on_reset: lcall init START: clr p3.2 mov a,#'t' lcall putc MOV R1,#040h MOV R5,0 sr0: lcall serin lcall putc mov @R1,a INC R1 inc r5 cjne a,#'Y',sr1 ljmp start sr1: cjne a,#'N',sr2 ljmp start sr2: cjne a,#'.',sr3 ljmp sr5 sr3: mov a,r5 cjne a,#040h,sr0 ljmp start ;buffer overload sr5: LCALL SERIN CJNE A,#'L',SR6 LJMP START SR6: CJNE A,#'.',START ljmp savedate savedate: clr p3.2 mov @r1,a inc r1 mov dptr,#0000h sv0: lcall rdi2c cjne a,#0aah,sN1 LCALL ADD40 ljmp SV0 ;not empty sn1: mov r0,#0aah lcall wri2c inc dptr ;savebufer MOV R1,#040H mov r4,#03fh ssev: MOV a,@R1 lCALL PUTC mov r0,a LCALL wri2c inc dptr NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP INC R1 DJNZ R4,ssev ljmp start MOV A,DPH CJNE A,#0FFH,sv0 MOV A,DPL CJNE A,#0FFH,sv0 loop: ljmp loop ;full eep loop infinit ;=--------------------------------------
PUTC: JNB TI,$ CLR TI MOV SBUF,A RET SERIN: JNB RI,$ CLR RI MOV A,SBUF RET INIT: setb p3.2 CLR TR1 MOV SCON,#05ah MOV Tmod,#020h mov TH1,#0E8h mov tl1,th1 SETB TR1 MOV A,#0E9h DJNZ ACC,$ jb p3.7,notera ljmp erase_eep mov r1,#040h mov r7,#64 sterram: mov a,0 mov @r1,a inc r1 djnz r7,sterram notera: ljmp START erase_eep: mov dptr,#0000h era1: mov r0,#0ffh lcall wri2c nop nop nop nop inc dptr MOV A,DPH CJNE A,#080H,era1 MOV A,DPL CJNE A,#000H,era1 clr p3.2 ljmp start ;rec overun wri2c: clr wena MOV A,#0a0h LCALL OUTS1 MOV A,dph LCALL OUT1 MOV A,dpl LCALL OUT1 MOV A,R0 LCALL OUT1 LCALL STOP1 setb wena RET Rdi2c: MOV A,#0a0h LCALL OUTS1 MOV A,DPH LCALL OUT1 MOV A,DPL LCALL OUT1 MOV A,#0a1h LCALL CREAD1 RET CREAD1: LCALL OUTS1 LCALL IN1 LCALL STOP1 RET OUTS1: MOV R2,#8 SETB SDA SETB SCL NOP NOP NOP nop CLR SDA NOP NOP NOP nop CLR SCL OTSLP1: RLC A JNC BITSL1 SETB SDA LJMP OTSL11 BITSL1: CLR SDA OTSL11: SETB SCL NOP NOP NOP nop CLR SCL DJNZ R2,OTSLP1 SETB SDA NOP nop SETB SCL NOP NOP NOP nop CLR SCL RET OUT1: MOV R2,#8 OTLP1: RLC A JNC BITL1 SETB SDA LJMP OTL11 BITL1: CLR SDA OTL11: SETB SCL NOP NOP NOP nop CLR SCL DJNZ R2,OTLP1 SETB SDA NOP nop SETB SCL NOP NOP NOP nop CLR SCL RET IN1: MOV R2,#8 SETB SDA INLP1: CLR SCL NOP NOP NOP nop SETB SCL CLR C JNB SDA,INL11 CPL C INL11: RLC A DJNZ R2,INLP1 CLR SCL RET STOP1: CLR SDA NOP NOP NOP nop SETB SCL NOP NOP NOP nop SETB SDA RET add40: mov r3,#040h ad4: inc dptr djnz r3,ad4 ret end
Hi geo, Mean while I go through your code I guess you can try using the following code for you interface,its in assembly... http://www.keil.com/forum/docs/thread2328.asp Rgds Raj Shetgar
hi i have no problem writing in eeprom. the only thing is that after the data i wish to save i get some trash too, wich i don't understand.
Ok, This happens for every byte written or only at the end of some lengthy string written into the EEPROM. Rgds Raj Shetgar
IT HAPPENS IMIDIATLY AFTER INPUT STRING IS OVER. THE INPUT STRING IS WITTEN CORECTLY IN THE EEPROM.