cancel
Showing results for 
Search instead for 
Did you mean: 

Recalibration with RCCR: help!

marcosarti29
Associate II
Posted on July 27, 2007 at 05:53

Recalibration with RCCR: help!

5 REPLIES 5
marcosarti29
Associate II
Posted on July 25, 2007 at 14:33

Hi, I use ST7Lite19F.

In my program I read the factory value with:

EECSR = 0x00;

RCCR = ((EEPROM[0] & 0xFF00) >> 8);

I have delete the factory value write in EEPROM at zero-address!

I want re-write this value after check the frequency with oscilloscope!

With RCCR = 0x90 the micro work at correct frequency!

I have think at this code for re-write it:

EECSR |= BIT_1; /* E2LAT = 1 */

EEPROM[0] = 0x0090;

EECSR |= BIT_0;

while (EECSR & BIT_1) /* attesa termine programmazione */

{

RefreshWatchdog();

}

After this programmation I have re-write the initial code:

EECSR = 0x00;

RCCR = EEPROM[0];

but the frequency is alwais incorrect!

What's my error?

Thanks

fggnrc
Associate II
Posted on July 26, 2007 at 04:30

From your code, it seems that EEPROM[0] is a 16 bit quantity.

When you write RCCR = EEPROM[0] the compiler does an implicit cast, so the value that is stored in RCCR is the byte at address 0x1001, not the one at 0x1000...

Try using EEPROM[0] = 0x9000; instead of EEPROM[0] = 0x0090; I think that the error will disappear!

Regards,

EtaPhi

marcosarti29
Associate II
Posted on July 26, 2007 at 15:41

Thanks for your reply!

I have try to write this code:

//-----write in eeprom number 0x90

EECSR |= BIT_1; /* E2LAT = 1 */

EEPROM[0] = 0x0090;

EECSR |= BIT_0;

while (EECSR & BIT_1) /* attesa termine programmazione */

{

RefreshWatchdog();

}

//-----read from eeprom the number

EECSR = 0x00;

RCCR = EEPROM[0];

and work fine! :)

I dont understand why if I re-program with only:

EECSR = 0x00;

RCCR = EEPROM[0];

dont work!! :(

I suppose the problem is the protection code in read mode....

I don't undesrstand! :o

fggnrc
Associate II
Posted on July 27, 2007 at 04:57

marcomarco,

I do not understand why you write 0x00 to EECSR in your code that does not work.

When your code ir running, the EEPROM can be read as the ram or the flash and the EECSR does not need to be changed.

The read protection option bit is effective when the EEPROM and the Flash are programmed by an external tool, not when your code runs.

marcosarti29
Associate II
Posted on July 27, 2007 at 05:53

OK but...I have try to Setting Read Out Protection OFF and I have write:

//-----write in eeprom number 0x90

EECSR |= BIT_1; /* E2LAT = 1 */

EEPROM[0] = 0x0090;

EECSR |= BIT_0;

while (EECSR & BIT_1) /* attesa termine programmazione */

{

RefreshWatchdog();

}

Now when I do:

EECSR = 0x00;

RCCR = EEPROM[0];

WORK! :D

I don't understand why but for re-write the factory value in eeprom[0] I must before select Read Out Protection OFF and write in eeprom[0]. After I can select Read Out Protection and use:

EECSR = 0x00;

RCCR = EEPROM[0];

in start main.