![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| I am trying to convert a program from the net that was designed for the 16C84 and I want to use it on the 16F84A. I have everything working but the EEprom updating. I would appreciate some help as I am in the dark when it comes to EEprom. The writing section doesn't seem wright because it goes to bank one but I don't see a return to bank zero and interupts are disabled but not reenabled. ;----------- EEPROM MODULE AT PIC16F84A ;Rev 1.00 ;d.27/07-95 ; note: use timer wadr equ 2Fh ; address in RAM 2F value equ 2Eh ; Data in RAM 2E WR_EEPROM ; write EEPROM (data in RAM 2E+adr in RAM 2E) movfw wadr,W ; w=adr movwf EEADR ; EEADR=w movfw value,W ; w=data movwf EEDATA ; EEDATA=w ; --- write sequnce bsf STATUS,5 ; EEPROM write enable bcf INTCON,GIE ; disable interupts movlw 0x55 ; w=55h movwf EECON2 ; EECON2=w movlw 0xAA ; w=AAh movwf EECON2 ; EECON2=w bsf EECON1,WR ; EECON1=write movlw .100 ; load time write movwf xms ; move w to xms call wait_xms ; wait in ms ; --- end ;return RD_EEPROM ; address in RAM 2F movfw wadr,W ; data in RAM 2E movwf EEADR ; EEADR=w bsf STATUS,5 ; bank 1 bsf EECON1,RD ; set RD bit bcf STATUS,5 ; bank 0 movfw EEDATA,W ; w=data movwf value ; data=w ; --- end return ;-------------- END EEPROM MODULE | |
| |
| | (permalink) |
| You are correct, it isn't right. Here is how I would modify it, Code: WR_EEPROM ; write EEPROM (data in RAM 2E+adr in RAM 2E)
movfw wadr,W ; w=adr
movwf EEADR ; EEADR=w
movfw value,W ; w=data
movwf EEDATA ; EEDATA=w
bsf STATUS,RP0 ; Bank 1
bsf EECON1,WREN ; Enable write
bcf INTCON,GIE ; disable interupts
movlw 0x55 ; w=55h
movwf EECON2 ; EECON2=w
movlw 0xAA ; w=AAh
movwf EECON2 ; EECON2=w
bsf EECON1,WR ; EECON1=write
WaitWR btfsc EECON1,WR ; Wait for write to complete
goto WaitWR
bcf EECON1,WREN ;stop spurious writes
bcf STATUS,RP0 ;back to bank 0
; bsf INTCON,GIE ;enable interrupts if used.
return
RD_EEPROM ; address in RAM 2F
movfw wadr,W ; data in RAM 2E
movwf EEADR ; EEADR=w
bsf STATUS,RP0 ; bank 1
bsf EECON1,RD ; set RD bit
bcf STATUS,RP0 ; bank 0
movfw EEDATA,W ; w=data
movwf value ; data=w
return Mike. | |
| |
| | (permalink) |
| Pommie I inputed the changes you suggested and everything ran perfectly. Thanks! | |
| |
| | (permalink) |
| Glad I could help. This is one area where the normal advise to switch to a 16F628 because they are compatible and cheaper, doesn't work. The above code will not work on a 628 and changing it is probably beyond most beginners abilities. Mike. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) | |
| Quote:
Are you telling me that after preaching how the 628 is the replacement for the 84, you didn't know this? Mike. | ||
| |
| | (permalink) | ||
| Quote:
Quote:
| |||
| |
| | (permalink) | |
| Quote:
You should apply that philosophy to your config values. Mike. P.S. I still haven't seen this mystical migration document. Last edited by Pommie; 14th December 2007 at 03:59 PM. | ||
| |
| | (permalink) | |
| Quote:
It certainly no longer seems to be available on the MicroChip website though?, if I ever find a copy I'll send it you - but it's probably far too many computers ago to be on my current HDD, or on the backups from the previous two or three (and I don't have any backups now from older machines). | ||
| |
| | (permalink) |
| We all have our styles of programming, I'm trying to adopt a style for the kit tutorial and online book that won't teach bad habbits that we ALL have. I remember when I first joined Electro-Tech I was using the SPASM (Tech-Tools) assembler. That got me some flack I still miss it like a bad habit. It was similar to the 8051 instruction set but for a PIC, Parallax wrote it initially. | |
| |
| | (permalink) |
| Sorry Bill, While style is fine, when I post something that is good advice to a beginners and a guru questions it (without reason) and then when shown that they are actually wrong they still defend their situation I get a little pissed. Nigel knows he is wrong, I know he is wrong, you know he is wrong and anyone that knows pics knows he is wrong. I really hate it when someone criticises me when I am correct. Mike. | |
| |
| | (permalink) | |
| Quote:
I then, again politely, queried your reply, why are you getting so over excited?. Regardless of what you don't remember, the 84 was replaced by the 628, the 84 was declared obselete, there was a migration document, and there was very little difference between them. | ||
| |
| | (permalink) | |
| Quote:
What I don't understand is why you are defending the 628 replacing the 84 when the EEPROM registers are in completely different banks!! And, the other thing I don't understand is why you had to post on this thread when there was no need? I haven't posted anything wrong. Do you have some sort of problem with me? Mike. | ||
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| So, you agree that the 628 is not a good replacement for the 84? Mike. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Simple EEPROM Programmer through Parallel Port | mr.lemarc | Electronic Projects Design/Ideas/Reviews | 18 | 9th December 2007 04:27 PM |
| Need some assistance with 28C64B EEPROM project. | Photometric Guy | Electronic Projects Design/Ideas/Reviews | 7 | 2nd November 2007 10:49 AM |
| working with eeprom pages? | justDIY | Micro Controllers | 1 | 7th October 2005 10:21 AM |
| problems programming a EEPROM 24c64 (inside a silver card) | nikaoj13 | Micro Controllers | 4 | 17th January 2005 04:32 PM |
| sequential read to AT24C01A serial EEPROM | giaracam | Micro Controllers | 2 | 26th October 2004 04:19 AM |