Autor Tema: Problema al escribir EEPROM  (Leído 1933 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado PerriPic

  • PIC10
  • *
  • Mensajes: 24
Problema al escribir EEPROM
« en: 04 de Febrero de 2008, 11:35:14 »
A ver, estoy utilizando el 18f2550 y cuando simulo con MPLAB no tengo problema ya q el registro EECON1 vale 0x00 al iniciar el programa, pero cuando utilizo el proteus y llega a la funcion de escribir en la eeprom me sale inicializado como 0x48, con lo q me da un error de escritura(WEERR a uno) y habilitacion de registros de configuracion de accesos(CFGS a uno) q no sé lo q es, pero la cosa es q yo aun no he llegado a escribir nada ahí...Esta es la funcion q utilizo para escrbir:
 
Código: [Seleccionar]
void escribir_eeprom (void)
{
for(CONTADOR_DATOS_EEPROM=0;CONTADOR_DATOS_EEPROM<MAXIMO_DATOS_EEPROM;CONTADOR_DATOS_EEPROM++)
{

INTCONbits.INT0IF = 1;

EECON1bits.EEPGD = 0;  /* WRITE step #1 */
    EECON1bits.WREN = 1;  /* WRITE step #2 */
EEADR = CONTADOR_DATOS_EEPROM; /* WRITE step #3 */
EEDATA = output_buffer_eeprom[CONTADOR_DATOS_EEPROM]; /* WRITE step #4 */
EECON2 = 0x55;          /* WRITE step #5 */
EECON2 = 0xaa;         /* WRITE step #6 */
EECON1bits.WR = 1;     /* WRITE step #7 */
while (!PIR2bits.EEIF) /* WRITE step #8 */
    ;
  PIR2bits.EEIF = 0;     /* WRITE step #9 */

/* clear the interrupt flag */
    INTCONbits.INT0IF = 0;
}

}

Pero ya digo q el problema es q llega el registro eecon1 con un valor erróneo y x lo tanto nunca me deja poner WR a 1 y el programa se queda bloqueado en el while!!!Espero vuestra ayuda!!!


 

anything