Jump to content
ELFORUM - Forumul electronistilor
Guest FlorinBucuresti

Probleme cu EEPROM-ul interen al 16F628

Recommended Posts

Guest FlorinBucuresti

Salutare! Am urmatoarea problema: incerc sa scriu in memoria EEPROM a microcontrolerului 16F628, dar in momentul in care vreau sa citesc ce am citit, gaseste FF adica nimic. Secventa de cod este urmatoarea:writee macro addwrite ; la donnée se trouve dans W LOCAL loop ; étiquette locale movwf EEDATA ; placer data dans registre movlw addwrite ; charger adresse d'écriture movwf EEADR ; placer dans registreloop bcf INTCON , GIE ; interdire interruptions btfsc INTCON , GIE ; tester si GIE bien a 0 goto loop ; non, recommencer bsf STATUS , RP0 ; passer en banque1 bcf EECON1,EEIF ; effacer flag de fin d'écriture bsf EECON1,WREN ; autoriser acces écriture movlw 0x55 ; charger 0x55 movwf EECON2 ; envoyer commande movlw 0xAA ; charger 0xAA movwf EECON2 ; envoyer commande bsf EECON1 , WR ; lancer cycle d'écriture bcf EECON1,WREN ; verrouiller prochaine écriture bsf INTCON , GIE ; réautoriser interruptions bcf STATUS , RP0 ; repasser en banque0 endmam incercat si alte macro-uri (de la mikroelektronika) dar cu acelasi rezultat. Am incercat chiar si cu alte microcontrolere, tot cu acelasi rezultat. Poate imi spuneti voi unde este problema. Va multumesc.

Link to comment
Share on other sites

Problema pare sa fie la scriere: Trebuie ca in softul de scriere secventa de cod (hex) pe care vrei sa o scrii in EEPROM zona date sa o incarci in fereastra "bufferului" de date care de exemplu la ICPROG e separata de fereastra codului program aflandu-se sub fereastra acestuia . Daca vizualizezi in aceasta fereastra hexul si dupa ce ii dai "write all" dupa verificare va zice OK trebuie ca la citirea din PIC in fereastra de date sa iti apara ce ai scris.

Link to comment
Share on other sites

Guest FlorinBucuresti

Nu in IcProg este problema, stiu cum ar trebui sa vizualizez ce am scris, doar ca eu nu vreau prin programare sa adaug informatiile in EEPROM, pt ca asa merge, eu vreau ca in timpul rularii prin program sa scriu in EEPROM. In MPLAB, la simiulare, imi arata ca scrie, iar la citire arata ca ar citi ceea ce trebuie, doar ca atunci cand il scriu in microcontroler nu mai functioneaza. Atasez programul.eeprom.increadee macro adeeprom ; macro avec 1 parametre (argument) banksel EEADR movlw adeeprom ; charger adresse eeprom (argument reçu) movwf EEADR ; adresse a lire dans registre EEADR bsf STATUS , RP0 ; passer en banque1 banksel EECON1 bsf EECON1 , RD ; lancer la lecture EEPROM bcf STATUS , RP0 ; repasser en banque0 banksel EEDATA movf EEDATA , w ; charger valeur lue dans W banksel 0 endm writee macro addwrite ; la donnée se trouve dans W LOCAL loop ; étiquette locale banksel EEDATA movwf EEDATA ; placer data dans registre movlw addwrite ; charger adresse d'écriture banksel EEADR movwf EEADR ; placer dans registreloop bcf INTCON , GIE ; interdire interruptions btfsc INTCON , GIE ; tester si GIE bien a 0 goto loop ; non, recommencer bsf STATUS , RP0 ; passer en banque1 banksel EECON1 bcf EECON1,EEIF ; effacer flag de fin d'écriture bsf EECON1,WREN ; autoriser acces écriture movlw 0x55 ; charger 0x55 banksel EECON2 movwf EECON2 ; envoyer commande movlw 0xAA ; charger 0xAA movwf EECON2 ; envoyer commande banksel EECON1 bsf EECON1 , WR ; lancer cycle d'écriture bcf EECON1,WREN ; verrouiller prochaine écriture call Delay50 bcf STATUS , RP0 ; repasser en banque0 endm eeprom.asm LIST p=16F628A include "P16F628A.inc" __config 0x3F38 errorlevel -302,-205 cblock 0x20 count endcLCD_PORT Equ PORTBLCD_TRIS Equ TRISBLCD_RS Equ 0x04 ;LCD handshake linesLCD_RW Equ 0x06LCD_E Equ 0x07 org 0x00 goto main include "..\include\eeprom.inc" include "..\include\LCD.inc" include "..\include\delay.inc" main call Delay255 movlw 'F' writee 0x00 movlw 'l' writee 0x01 movlw 'o' writee 0x02 movlw 'r' writee 0x03 movlw 'i' writee 0x04 movlw 'n' writee 0x05 clrw banksel TRISB movlw b'00000000' movwf TRISB movlw b'00011100' movwf TRISA banksel PORTB call LCD_Init ;setup LCD readee 0x00 call LCD_Char readee 0x01 call LCD_Char readee 0x02 call LCD_Char readee 0x03 call LCD_Char readee 0x04 call LCD_Char readee 0x05 call LCD_Charloop goto loop end

Link to comment
Share on other sites

Uite aici eroarea:

bsf EECON1,WREN ; autoriser acces écrituremovlw 0x55 ; charger 0x55banksel EECON2movwf EECON2 ; envoyer commandemovlw 0xAA ; charger 0xAAmovwf EECON2 ; envoyer commandebanksel EECON1bsf EECON1 , WR ; lancer cycle d'écriture 

The write will not initiate if the write sequence is notexactly followed (write 55h to EECON2, write AAh toEECON2, then set WR bit) for each byte.

Tu introduci niste operatii de selectare a bancului in aceasta succesiune, care trebuie respectata INTOCMAI ca in datasheet. Operatiile respective sunt inutile si strica timing-ul necesar operatiei de scriere. Vezi ca ai in datasheet un exemplu complet pentru scrierea in memoria EEPROM.
Link to comment
Share on other sites

Guest FlorinBucuresti

Multumesc frumos pentru obesrvatie, imi scapase. Acum totul functioneaza. De fapt, problema initiala era ca nu exista nici o instructiune de selectare a bancului de memorie, asa ca am adaugat banksel pentru toti registrii folositi, doar ca nu trebuia chiar pentru toti. Cam asa trebuia sa arate:writee macro addwrite ; la donnée se trouve dans W LOCAL loop ; étiquette locale banksel EEDATA movwf EEDATA ; placer data dans registre movlw addwrite ; charger adresse d'écriture movwf EEADR ; placer dans registreloop bcf INTCON , GIE; interdire interruptions btfsc INTCON , GIE ; tester si GIE bien a 0 goto loop ; non, recommencer bsf STATUS , RP0 ; passer en banque1 bcf EECON1,EEIF ; effacer flag de fin d'écriture bsf EECON1,WREN ; autoriser acces écriture movlw 0x55 ; charger 0x55 movwf EECON2 ; envoyer commande movlw 0xAA ; charger 0xAA movwf EECON2 ; envoyer commande bsf EECON1 , WR ; lancer cycle d'écriture bcf EECON1,WREN ; verrouiller prochaine écriture call Delay100 bcf STATUS , RP0 ; repasser en banque0 endmAcum merge ca un vis, multumesc inca o data.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines