Clock speed and writing to internal EEPROM.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Clock speed and writing to internal EEPROM.

364 Views
jpetersen
Contributor I

I'm using the MC9S08EL32.

I've got two questions:

1.  To get the fastest processing, should I use the internal oscillator or an external crystal?

2.  My program is stored in onboard flash and we now want to store a couple dozen bytes of data.  How do I read/write data to the internal eeprom? Is there a published routine for this?

   Thanks,   Sitichon

Labels (1)
0 Kudos
1 Reply

240 Views
bigmac
Specialist III

Hello Sitchon, and welcome to the forum.


Sitichon wrote:

1.  To get the fastest processing, should I use the internal oscillator or an external crystal?


You can always specifically trim the internal reference to achieve the highest allowable bus speed.  A trimmed reference frequency of 39.0625kHz will achieve a DCO frequency of 40MHz (1024 multiplier), which gives a maximum bus frequency of 20MHz.

 

Using an external crystal, the upper limit of  the bus frequency will be determined by the crystal frequency.  For example, a 4.0MHz crystal would give a bus frequency of 16MHz maximum, (with sub-multiples using RFD).  By contrast, a crystal frequency of 2.4576MHz would give a bus frequency of 19.66MHz maximum.  These examples assume that you are using FEE mode for the Internal Clock Source (ICS) module.

 

It is sometimes necessary to choose a trimmed reference frequency, or crystal frequency, to give less than the maximum allowable bus frequency.  One reason would be to provide better baud rate accuracy for the SCI module.


Sitichon wrote:

2.  My program is stored in onboard flash and we now want to store a couple dozen bytes of data.  How do I read/write data to the internal eeprom? Is there a published routine for this?


It appears that the program flash and the EEPROM flash may be separate arrays for this particular device.  This is significant because it means that the program flash array is accessible whilst the EEPROM is being programmed, and vice versa.  Therefore, the EEPROM programming code can be executed from a flash memory location.  The flow diagrams for erasing a flash or EEPROM sector, and for programming one or more bytes, are given ing the Memory section 4.5 of the datasheet.

 

There are numerous code examples contained in this forum (these can be accessed using forum search engine), but the majority are more complex than you need because they apply to MCU types that have only a single flash array.  In this situation, some of the code needs to be placed in RAM, and executed from there.

 

One aspect to keep in mind - the sector size for EEPROM is eight bytes, and for program flash it is 512 bytes.  Storing 24 bytes of date to EEPROM will require three sectors to be erased (60-80ms).  If the same data were instead to be stored in a program flash sector, this would require erasure of a single sector (20-27ms).  If the latter approach were to be adopted, for faster processing, the erase and programming functions can be programmed into the EEPROM array, to again avoid the need for RAM resident code.

 

Regards,

Mac

 

0 Kudos