Autor Tema: EEPROM INTERNA DEL PIC  (Leído 3222 veces)

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

Desconectado KALLITOS

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1256
EEPROM INTERNA DEL PIC
« en: 22 de Junio de 2006, 18:22:58 »
Buenas muchachos, mi consulta es como grabar en la eeprom interna del pic en tiempo de diseño.

de antemano gracias por la ayuda que me puedan brindar.
A un microcontrolador hay que sacarle hasta el ultimo byte....(YO)

Cómo puede ser que un pic24EP512 me quede corto de memoria, señores de MICROCHIP saquen pics con más memoria flash

Más de 45 mil lineas de codigo y aun no termino el equipo, asu mare!!

S34ML08G1TFI200 no necesito mas memoria externa.

Desconectado Mario

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 873
Re: EEPROM INTERNA DEL PIC
« Respuesta #1 en: 22 de Junio de 2006, 20:43:45 »
Hola.

Bueno....... no entiendo muy bien tu pregunta "a la hora de diseño".

Creo que lo que quieres decir es cuando apena vas a programar el µicro.

Si es asi pues no es tan complicado, solo utiliza la instrucción DATA.

Aquí te va el manual:

5.11. DATA

{Label} DATA {@Location,}Constant{,Constant...}

Store constants in on-chip non-volatile EEPROM when the device is first
programmed. If the optional Location value is omitted, the first DATA
statement starts storing at address 0 and subsequent statements store at
the following locations. If the Location value is specified, it denotes the
starting location where these values are stored. An optional Label (not
followed by a colon) can be assigned to the starting EEPROM address
for later reference by the program.

Constant can be a numeric constant or a string constant. Only the
least significant byte of numeric values are stored unless the WORD
modifier is used. Strings are stored as consecutive bytes of ASCII
values. No length or terminator is automatically added.

DATA only works with microcontrollers with on-chip EEPROM such as the
PIC12F675, 16F84, PIC16C84 and the PIC16F87x series. It will not work
on devices with on-chip I2C interfaced serial EEPROM like the 12CE67x
and 16CE62x parts. Since EEPROM is non-volatile memory, the data
will remain intact even if the power is turned off.

The data is stored in the EEPROM space only once at the time the
microcontroller is programmed, not each time the program is run. WRITE
can be used to set the values of the on-chip EEPROM at runtime. READ
is used to retrieve these stored DATA values at runtime.

‘ Store 10, 20 and 30 starting at location 4
DATA @4,10,20,30

‘ Assign a label to a word at the next location
dlabel DATA word $1234 ‘ Stores $34, $12

‘ Skip 4 locations and store 10 0s
DATA (4),0(10)



Como ves no es tan difícil.

Además el manual recomienda que una ves corriendo el programa ("tiempo real") utilices las instrucciones read y write. Bueno, read la usas para leer lo que escribiste con DATA.

Aqui te va un ejemplo que utilicé alguna ves:

 Read 0,SPPISTON.BYTE0                                   ' LEE LA LOCALIDAD DE MEMORIA O
 Read 1,SPPISTON.BYTE1                                   ' LEE LA LOCALIDAD DE MEMORIA 1
 Read 2,SPTIEMPO.BYTE0                                  ' LEE LA LOCALIDAD DE MEMORIA 2
 Read 3,SPTIEMPO.BYTE1                                  ' LEE LA LOCALIDAD DE MEMORIA 3


IF ENTER=1 Then DAT
                                           
                                           Write 0,SPPISTON.BYTE0
                                           Write 1,SPPISTON.BYTE1
                                           
                                           IF REGRESAR=1 Then INICIO
                                           GoTo SPDISTANCIA
                                             
                                           
                               PRODUCT1:   LCDOut $FE,1, "TIEMPO DE EJECUCION"
                                           LCDOut $fe,$C0,#SPTIEMPO
                                           Pause 50
                                           
                                           High HABTIEMPO
                                           DATO1:
                                             SerIn2 INDATOS2,16780,100,loop6,[DEC5 SPTIEMPO]         
                                           IF ENTER=1 Then DATO1
                                         
                                           Write 2,SPTIEMPO.BYTE0   
                                           Write 3,SPTIEMPO.BYTE1
                                         
                                           IF REGRESAR=1 Then INICIO
                                           GoTo PRODUCT1



En el ejemplo no utilizo DATA porque es un sistema que el usuario puede configurar según sus necesidades, asi que no era necesario grabarle nada al µicro puesto que se calibraría después.

PD: el código quizá no te diga nada porque es un "copy paste" de secciones del programa utilizado asi que no tienen mucho sentido.

Lo de read pistón está al comienzo y lo de write va al último del programa.



Espero te sirva

d--(^_^)--b
La buena administración es utilizar el sentido común y la regla de oro; aunque el sentido común no es tan común como quisiéramos que fuera y, quien tiene el oro, hace las reglas.
George Terry

"A loser will defeat a genius with hard work"
Rock Lee

Desconectado LordLafebre

  • Moderador Global
  • DsPIC30
  • *****
  • Mensajes: 3529
    • Micros & micros
Re: EEPROM INTERNA DEL PIC
« Respuesta #2 en: 23 de Junio de 2006, 00:26:13 »
Hola:

Lo mas facil siempre es consultar la ayuda, alli te describe:

Código: [Seleccionar]
READ Address,Var

Read the on-chip EEPROM at the specified Address and stores the result in Var. This instruction may only be used with a PICmicro that has an on-chip EEPROM data area such as the PIC16F84, PIC16C84 and the PIC16F87x series. READ will not work on devices with on-chip I2C interfaced serial EEPROM like the 12CE67x and 16CE62x parts. Use the I2CREAD instruction instead.

Example

READ 5,B2 ' Put the value at EEPROM location 5 into B2

Código: [Seleccionar]
WRITE Address,Value

Write Value to the on-chip EEPROM at the specified Address. This instruction may only be used with a PICmicro that has an on-chip EEPROM data area such as the PIC16F84, PIC16C84 and the PIC16F87x series. WRITE is used to set the values of the on-chip EEPROM at runtime. To set the values of the on-chip EEPROM at programming-time, use the DATA or EEPROM statement. Each WRITE is self-timed and takes about 10 milliseconds to execute on a PICmicro.

If interrupts are used in a program, they must be turned off (masked, not DISABLEd) before executing a WRITE, and turned back on (if desired) after the write instruction is complete. An interrupt occurring during a WRITE may cause it to fail. WRITE will not work on devices with on-chip I2C interfaced serial EEPROM like the 12CE67x and 16CE62x parts. Use the I2CWRITE instruction instead.

Example

WRITE 5,B0 ' Send value in B0 to EEPROM location 5

Con READ y WRITE escribes y lees la eeprom del microcontrolador.

Desconectado patolinec

  • Colaborador
  • PIC16
  • *****
  • Mensajes: 206
Re: EEPROM INTERNA DEL PIC
« Respuesta #3 en: 23 de Junio de 2006, 15:45:36 »
Exactamente como dice Lord la sintaxis para escribir y leer es:

Código: Visual Basic
  1. Read Direccion,Var
  2. ''Leer, donde Direccion es la direccion de la memoria interna y Var, es la variable donde deseas guardar ese dato
  3.  
  4. Write Direccion ,Var
  5. ''Escribir, donde Direccion es la direccion de la memoria EEPROM interna y Var es la variable con el valor que desea grabar en dicha direccion.

Ejemplo

Tu deseas cargar en PORTB lo que tienes almacenado en la direccion 0x08 de la memoria EEPROM de un micro cualquiera, inclusive los 18

Código: Visual Basic
  1. READ 8,variable
  2. PORTB=variable
  3.  
  4. [/code
  5.  
  6. Y si se dea hacer lo contrario lo que se tiene en el puerto B en la direccion 0x03 seria
  7.  
  8. [code=vb]
  9.  
  10. variable=PORTB
  11. WRITE 3,variable
[/code]
Casi me maté pero ahora estoy de nuevo vivo

Desconectado KALLITOS

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1256
Re: EEPROM INTERNA DEL PIC
« Respuesta #4 en: 24 de Junio de 2006, 11:45:06 »
Bueno jóvenes quiero agradecerles por la ayuda brindada....me funcionó a la perfección  :-/ :-/ :-/
gracias a los tres Mario, LordLafebre y Patolinec

aqui les dejo el codigo de prueba, gracias nuevamente

  Include "modedefs.bas"
DATA @0," ","C","A","R","L","O","S"
B0 VAR BYTE
B1 VAR BYTE
TRISA=0
INICIO:
FOR B0 = 0 TO 7
READ B0,B1
PAUSE 10
SEROUT porta.0,N9600,[B1]
PAUSE 500
NEXT
GOTO INICIO
END

saludos  :mrgreen:
« Última modificación: 24 de Junio de 2006, 11:50:01 por KALLITOS »
A un microcontrolador hay que sacarle hasta el ultimo byte....(YO)

Cómo puede ser que un pic24EP512 me quede corto de memoria, señores de MICROCHIP saquen pics con más memoria flash

Más de 45 mil lineas de codigo y aun no termino el equipo, asu mare!!

S34ML08G1TFI200 no necesito mas memoria externa.

Desconectado Mario

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 873
Re: EEPROM INTERNA DEL PIC
« Respuesta #5 en: 25 de Junio de 2006, 13:43:22 »
Que bien.  8)

Lo más sencillo es que busques en la opción "buscar"  aquí en el foro, estoy seguro que habrá mas programas y mejor detallados.

Al parecer ya habías preguntado algo por el estilo pero creo que era por I²C, creo, no lo recuerdo bien.

Lo de la buscada es para que puedas agilizar tu tiempo (no porque no se te quiera ayudar):
Si encuentras el ejemplo que buscas, no necesitas esperarte a que alguien te conteste.

Si no llegaras a encontrar nada o, no cumple con tus necesidades entonces si pregunta.

Te lo digo porque yo antes tenía otra cuenta aqui en Miarroba-Todo pic y preguntaba muuuuuuuuuuuuuuuchas cosas hasta que TODOPIC me sugirió utilizar la opción de busqueda, la cual ayuda mucho.

 :-/Bueno, que bien que te funcionó, de eso se trata. :-/
La buena administración es utilizar el sentido común y la regla de oro; aunque el sentido común no es tan común como quisiéramos que fuera y, quien tiene el oro, hace las reglas.
George Terry

"A loser will defeat a genius with hard work"
Rock Lee

Desconectado KALLITOS

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1256
Re: EEPROM INTERNA DEL PIC
« Respuesta #6 en: 26 de Junio de 2006, 16:46:38 »
Si busqué doctor pero como ""eeprom interna del pic" y nones pero de todas maneras anotado. :) :)
A un microcontrolador hay que sacarle hasta el ultimo byte....(YO)

Cómo puede ser que un pic24EP512 me quede corto de memoria, señores de MICROCHIP saquen pics con más memoria flash

Más de 45 mil lineas de codigo y aun no termino el equipo, asu mare!!

S34ML08G1TFI200 no necesito mas memoria externa.