PDA

View Full Version : PIC16f876 writing recieved serial data to eeprom



Woobie
- 27th July 2005, 23:07
Howdy all,

Pretty new at this stuff but having fun. This one has got me.
I have a little code that basically echos what I type on my terminal, works great . Now I want to save what I type to my EEPROM (in future need to save gps data that I specify) however the eeadr incr to the next addr, the code recieved from the terminal is saved to RxHold, when I write RxHold to EEDATA as below, it writes the same incorrect data to every inc position no matter what I type. if I MOVF RxHold,w and write it to my LCD the data is correct, somewhere in the write cycle it is getting all messed up.

below is my write cycle (as per the datasheet)

sorry not in C or Basic (still to new for that and have no compiler) use MPASM


Thanks all



write
MOVLW EEWRITE ;INC EEWRITE ADDR
MOVWF FSR
BSF STATUS,RP1 ;
BSF STATUS,RP0 ;BANK 3
BTFSC EECON1,WR ;WAIT FOR WRITE TO FINNISH
GOTO $-1 ;GO BACK ONE IF NOT
BCF STATUS,RP0 ;BANK 2
MOVF INDF,w ;MOVE NEXT ADDR TO W
MOVWF EEADR ;WRITE TO EEADR
MOVF RxHold,w
MOVWF EEDATA ;WRITE TO EEDATA
BSF STATUS,RP0 ;BANK 3
BCF EECON1,EEPGD ;POINT TO DATA MEMORY
BSF EECON1,WREN ;WRITE ENABLE
; ********* NEXT ONLY IF USING INTERUPTS ******
; BCF INTCON,GIE ;DISABLE INTERUPTS
MOVLW 0x55 ;REQUIRED
MOVWF EECON2 ;EECON2
MOVLW 0xAA ;REQUIRED
MOVWF EECON2 ;EECON2
BSF EECON1,WR ;START WRITE OPERATION
; ********* NEXT ONLY IF USING INTERUPTS ******
; BSF INTCON,GIE ;ENABLE INTERUPTS
BCF EECON1,WREN ;WRITE DISABLE

BCF STATUS,RP1 ;
BCF STATUS,RP0 ;BANK 0
INCF EEWRITE,f

return

mister_e
- 28th July 2005, 01:56
I hate to say that but i must...

Assembler, MBasic, MikroBasic, PROTON, Microchip C, HI-Tech C,Pascal, Fortran, Cobol, Qbasic,VisualBasic, Foxpro, C++, Visual C, Java and i forget some to save space, must be asked on their specific forum...

Microchip have their own forum and a great tech support.

I'm sorry for those who know the solution for the above but, rules are rules...