View previous topic :: View next topic |
Author |
Message |
sandropiovesana
Joined: 06 May 2008 Posts: 9
|
Write_eeprom() PIC12F519 Problem |
Posted: Tue May 06, 2008 7:02 am |
|
|
Hi,
i have a problem with CCS function write_eeprom() used on PIC12f519.
this is the c source:
Code: |
#include <12F519.h>
#FUSES NOMCLR, NOPROTECT, NOWDT, INTRC, NOPROTECTDF, IOSC4
//#FUSES NOMCLR, PROTECT, WDT, INTRC
#USE DELAY(CLOCK=4000000, RESTART_WDT)
#USE FAST_IO(B)
#define MOTOR_A 48 // PIN_GP0
#define MOTOR_B 49 // PIN_GP1
#define SWITCH_A 50 // PIN_GP2
#define SWITCH_B 51 // PIN_GP3
#define REMOTE_A 52 // PIN_GP4
#define REMOTE_B 53 // PIN_GP5
#define LOW 0
#define HIGH 1
unsigned int spcl_mode = 0;
unsigned int isa = 0;
#define Set_OPTION(value)
{
#ASM
MOVLW value
OPTION
#ENDASM }
void Hardware_Initialize()
{
Set_OPTION(RTCC_INTERNAL | RTCC_DIV_64 | DISABLE_PULLUPS | DISABLE_WAKEUP_ON_CHANGE);
Set_Tris_B(0b11111100);
}
void Software_StartUP(void)
{
Output_High(MOTOR_A);
Output_Low(MOTOR_B);
delay_ms( 1000 );
Output_Low(MOTOR_A);
}
void main(void)
{
Hardware_Initialize();
Software_StartUP();
while (TRUE)
{
isa = Input(SWITCH_A);
if (isa) {
Output_High(MOTOR_A);
write_eeprom(0x01, 0x01);
}
else {
Output_Low(MOTOR_A);
write_eeprom(0x01, 0x00);
}
spcl_mode = read_eeprom(0x01);
if (spcl_mode) Output_High(MOTOR_B);
else Output_Low(MOTOR_B);
}
}
|
Motor B never turn on, why?
How can i memorize a value on PIC internal eeprom?
Thanks |
|
|
sandropiovesana
Joined: 06 May 2008 Posts: 9
|
|
Posted: Tue May 06, 2008 7:05 am |
|
|
I use MPLAB 8.10, CCS 4.057 and ICD2. |
|
|
Ttelmah Guest
|
|
Posted: Tue May 06, 2008 8:40 am |
|
|
The reason is that the 519, doesn't have a normal 'internal EEPROM'!....
What it has is effectively a separate EEPROM 'chip', built inside (hence in the data sheet, the reference to an 'EEPROM peripheral'). This has to be accessed using the code to read/write an _external_ I2C EEPROM, using GPIO6, and GPIO7. The code is the library code, to access a 24L00, which you have to setup to use these 'pins' (no actual pin involved, but an internal connection only) - include '2401.c', and change the SDA/SCL definitions.
If you look at Figures 7-1, and 7-2 in the data sheet, you will see that it shows these internal connections to an 'internal' 24L00.
There are only about half a dozen chips that have the EEPROM implemented this way.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 06, 2008 8:43 am |
|
|
CCS has a driver file for this:
Quote: | c:\program files\picc\drivers\ce51x.c |
|
|
|
Matro Guest
|
|
Posted: Tue May 06, 2008 8:57 am |
|
|
I carefully look at the datasheet and see nothing like that.
This chip seems to have absolutely no EEPROM but only a flash data space.
The way of writing in this memory is very special.
I can't say if a driver exists for that, but the write_eeprom() function will never work.
Matro |
|
|
sandropiovesana
Joined: 06 May 2008 Posts: 9
|
|
Posted: Wed May 07, 2008 3:36 am |
|
|
Thanks, now i will work to find the right way. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 07, 2008 12:09 pm |
|
|
The reason for the confusion is that Microchip itself is confused about it.
The web page for the 12F519 mentions 64 bytes of data eeprom on the
left side of the page.
http://www.microchip.com/stellent/idcplgidcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en530188
But the data sheet for the 12F519 doesn't mention it, except that it
has an entry in the index for it.
Apparently, the data eeprom is only available in the "CE" version of
the chip (12CE519), not in the "F" (12F519) version. |
|
|
|