Author Topic: fsee EEprom Routines....  (Read 7609 times)

OmarZ

  • Hero Member
  • *****
  • Posts: 243
    • View Profile
fsee EEprom Routines....
« on: February 26, 2006, 07:07:55 AM »
Hi.
I want implemet data logging on my SBC SBC65EC board. According documentation there is a set of functions that can access external EEPROM files.
fseeInit , fseeOpen , fseeClose , fseeRelease, fseeGetByte, fseePutByte and so on.
My idea is to download from FTP empty files of fixed size (like 4k) and than by PIC access this files and store data. On TCP or RS232 Request, PIC will send this file or better all samples.
So I was looking about these functions, but i see that fseePutByte is not implemented yet. I think it should be exactly like fseeGetByte function, but instead read byte write a write. Is this true?
My idea is to use fseeOpen function to identify address location of data and than use a fseePutByte function at that address incremented every time till the end of file size.At this time it will restart from the begin as a circular buffer. The first locations of this file will be reserved to indicate actual index.
My question at the end is:
1) why these functions are not complete (fseePutBye and also file flush)?

I saw that there is another solution: to shift begin of web pages area and reserve data at begin of EEPROM. Ok, but this way should be better.Think about possibility to use 2 or 3 files and make much more better datalogging.

I wait for Modtronix and also SBC users some answer.

Bye

Administrator

  • Hero Member
  • *****
  • Posts: 171
    • View Profile
    • http://www.modtronix.com
Re: fsee EEprom Routines....
« Reply #1 on: February 26, 2006, 11:04:43 PM »
Hello Omar

Yes, these functions have not been implemented yet, but will be in a future release. They have not been needed for any of the current code up till now. For the FSEE file system, you are correct, you will have to download some empty files (4k for example), and write to these files with the fseeXxx functions. The fseeWrite() implementation will be very similar to the fseePutByteImage() implementation. The fseeFlush() function will not be required, except it you for some reason want to flush the write buffer at a specific time. So, you actually only have to implement the fseeWrite() function.

Alternatively you could use the XEEWrite functions to write to the EEPROM, just declare a reserved block in the EEPROM with the "Modtronix Network Bootloader" utility when creating the file system image. You can then use this reserved area for your own data. For example, you can reserve 12K in your EEPROM, and then use that (for 3 x 4K areas for example) memory to write data to via the XEEWrite function.
*** Modtronix Engineering Support ***

OmarZ

  • Hero Member
  • *****
  • Posts: 243
    • View Profile
Re: fsee EEprom Routines....
« Reply #2 on: February 27, 2006, 12:27:20 PM »
Quote
The fseeWrite() implementation will be very similar to the fseePutByteImage() implementation.
I think can be exactly the same code of  fseePutByteImage() with this change:

insted to use
   pFileInfo = &getFCB(0) ,

i will use
   pFileInfo = &getFCB(fhandle); // where fhandle is result of  FSEE_FILE fseeOpen(BYTE* filename, BYTE mode)

and everywhere in  fseePutByteImage() function it's used getFCB(0) i will use pFileInfo->

Is it correct? In this way instead point Image file i will point handle file.

About this ...
Quote
Alternatively you could use the XEEWrite functions to write to the EEPROM, just declare a reserved block in the EEPROM with the "Modtronix Network Bootloader" utility when creating the file system image. You can then use this reserved area for your own data. For example, you can reserve 12K in your EEPROM, and then use that (for 3 x 4K areas for example) memory to write data to via the XEEWrite function.
So, if I use Reserved block in bytes (12K = 12288 bytes) i will use fisrt 12288 to store my data?
I think i must also change something in projdefs.h or not?
I see in one old post that someone speak about MPFS_RESERVE_BLOCK, but i can't find it in actual project. And also that first 64 bytes are reserved for system. Is it about an old version of project? Actually i see that first 64 bytes of FlashEEprom are reserved. Maybe in this new version you move all system data inside PIC.

Anyway in my opinion it's better first solution but maybe second one is faster. Tell me what you think.

OmarZ

  • Hero Member
  • *****
  • Posts: 243
    • View Profile
Re: fsee EEprom Routines....
« Reply #3 on: February 27, 2006, 03:07:36 PM »
/**
 * Writes a byte to the given file.
 */
bool fseePutByte(FSEE_FILE fhandle, BYTE dataByte) {
    FSEE_FILE_INFO * pFileInfo;
   
    pFileInfo = &getFCB(fhandle);

    //We currently ARE writing (in EEPROM Sequencial write mode)
    if (pFileInfo->flags & FSEEFILE_WRITING) {
        //If we have reached our page limit with the current sequencial write, end it and start new sequencial write
        if (pageWrite >= FSEE_WRITE_PAGE_SIZE) {
            //Removes this FILE from "currently writing" mode. Ends any sequencial page write cycle that might
            //be in progress, and waits for internal write operation to complete.
            fseeRelease(0);
        }
    }

    //We currently are NOT writing (EEPROM Sequencial write) - initiate sequencial write sequence
    if ( (pFileInfo->flags & FSEEFILE_WRITING) == 0) {
        //Check if the File System is not currently busy reading or writing from another open file
        //Only needed when more then one FILE. When only one file, use FSEEFILE_READING and FSEEFILE_WRITING of FCB[0].flags
        #if (FSEE_MAX_FILES > 1)
        if (fseeFlags & FSEEFLAG_READING_WRITING) {
            pFileInfo->flags |= FSEEFILE_ERROR;    //Set error condition
            #if (DEBUG_FSEE >= LOG_ERROR)
            debugPutMsg(12);     //Currently busy reading or writing from another open file, can not open file
            #endif
            return FALSE;
        }
        #endif
       
        //Successfully placed EEPROM into sequencial write mode
        if ( XEEBeginWrite(EEPROM_CONTROL, (XEE_ADDR)(pFileInfo->address.Val)) == XEE_SUCCESS)
        {
            pFileInfo->flags |= FSEEFILE_WRITING;    //Indicate that this FILE is currently in Writing mode

            //Indicate that the File System is currently Writing an open file
            //Only needed when more then one FILE. When only one file, use FSEEFILE_READING and FSEEFILE_WRITING of FCB[0].flags
            #if (FSEE_MAX_FILES > 1)
            fseeFlags |= FSEEFLAG_READING_WRITING;
            #endif
           
            //pageWrite = 0;  //Keep track of how many bytes have been written in sequencial page write mode
        }
        //Error!
        else {
            #if (DEBUG_FSEE >= LOG_ERROR)
            debugPutMsg(11);    //Err in fseePutByte() while trying to place EEPROM in seq write mode
            #endif
            return FALSE;
        }
    }

    //Write given byte
    XEEWrite(dataByte);

    //Keep track of how many bytes have been written in sequencial page write
    //pageWrite++;
   
    //Increment address
    pFileInfo->address.Val++;

    return TRUE;
}

/**
 * Writes an integer to the given file.
 */
bool fseePutInt(FSEE_FILE fhandle, int dataInt) {
    FSEE_FILE_INFO * pFileInfo;
     struct
      {
       unsigned char LSB;
       unsigned char MSB;
       } dataByte;

    pFileInfo = &getFCB(fhandle);

    //We currently ARE writing (in EEPROM Sequencial write mode)
    if (pFileInfo->flags & FSEEFILE_WRITING) {
        //If we have reached our page limit with the current sequencial write, end it and start new sequencial write
        if (pageWrite >= FSEE_WRITE_PAGE_SIZE) {
            //Removes this FILE from "currently writing" mode. Ends any sequencial page write cycle that might
            //be in progress, and waits for internal write operation to complete.
            fseeRelease(0);
        }
    }

    //We currently are NOT writing (EEPROM Sequencial write) - initiate sequencial write sequence
    if ( (pFileInfo->flags & FSEEFILE_WRITING) == 0) {
        //Check if the File System is not currently busy reading or writing from another open file
        //Only needed when more then one FILE. When only one file, use FSEEFILE_READING and FSEEFILE_WRITING of FCB[0].flags
        #if (FSEE_MAX_FILES > 1)
        if (fseeFlags & FSEEFLAG_READING_WRITING) {
            pFileInfo->flags |= FSEEFILE_ERROR;    //Set error condition
            #if (DEBUG_FSEE >= LOG_ERROR)
            debugPutMsg(12);     //Currently busy reading or writing from another open file, can not open file
            #endif
            return FALSE;
        }
        #endif
       
        //Successfully placed EEPROM into sequencial write mode
        if ( XEEBeginWrite(EEPROM_CONTROL, (XEE_ADDR)(pFileInfo->address.Val)) == XEE_SUCCESS)&&
           ( XEEBeginWrite(EEPROM_CONTROL, (XEE_ADDR)((pFileInfo->address.Val) + 1)) == XEE_SUCCESS)
        {
            pFileInfo->flags |= FSEEFILE_WRITING;    //Indicate that this FILE is currently in Writing mode

            //Indicate that the File System is currently Writing an open file
            //Only needed when more then one FILE. When only one file, use FSEEFILE_READING and FSEEFILE_WRITING of FCB[0].flags
            #if (FSEE_MAX_FILES > 1)
            fseeFlags |= FSEEFLAG_READING_WRITING;
            #endif

           //pageWrite = 0;  //Keep track of how many bytes have been written in sequencial page write mode
        }
        //Error!
        else {
            #if (DEBUG_FSEE >= LOG_ERROR)
            debugPutMsg(11);    //Err in fseePutByte() while trying to place EEPROM in seq write mode
            #endif
            return FALSE;
        }
    }

    //Write given byte

    //dataByte.LSB = (dataInt & 0xFF);
    //dataByte.MSB = (dataInt >> 0x08);

    dataByte.LSB = (dataInt % 256);
    dataByte.MSB = (dataInt / 256);

    XEEWrite(dataByte.LSB);
    //Keep track of how many bytes have been written in sequencial page write
    //pageWrite++;
    //Increment address
    pFileInfo->address.Val++;

    XEEWrite(dataByte.MSB);
    //Keep track of how many bytes have been written in sequencial page write
    //pageWrite++;
    //Increment address
    pFileInfo->address.Val++;


    return TRUE;
}

About
 pageWrite //Keep track of how many bytes have been written in sequencial page write mode
i'm really not sure: What is the porpuse of this flag?
I see that there is a check at begin of function and if this value is greater that 64 it force a Release. I do not understand why, because actually will be anyway forced again to 0 inside  ( XEEBeginWrite(EEPROM_CONTROL, (XEE_ADDR)(pFileInfo->address.Val)) == XEE_SUCCESS) check.
I think was planned to make a Flush, but actually this function writes directly to EEPROM.

Can you quickly check this functions?
I made also one for fseePutInt values because it's much more faster than call two times the function if i want to save int data.
I think I will also make a fseeGetInt function for the same reason.

PS: I'm still waiting SBC board.... I hope "shipper" will arrive soon.

Regards


peters

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: fsee EEprom Routines....
« Reply #4 on: August 17, 2006, 04:53:54 PM »
I want to use the SBC65 for data logging also, but can someone tell me if this is a problem:  Say i log data once a second.  The data sheet for the 24LC256 shows 1,000,000 read/write cycles.  This will be used up after about 60*60*24*12>1e6, so I would get only twelve days for data logging  :? (I would be 'downloading' the data periodically in this time).

Am i missing something, or is it necessary to use the Ram or Fram for logging to avoid over-using the eeprom?

Has anyone got some code for using the ram for data logging?  My interest is in collecting data from an array of temperature sensors.  Thoughts on accessing the data include:  Just writing it to a webpage and having an external task collect the data.  Writing to a file and using the SMTP code to email the data to myself. What else?

"having a go for the fun of it"

peters

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: fsee EEprom Routines....
« Reply #5 on: August 21, 2006, 08:50:35 PM »
No comments to this post from anyone else?

I'm not an elec eng, but a spoke to one who ran into this problem with some Motorlla Eeprom, writing debug diagnostics.  After about 1/2 a year of writes every 15seconds his micro died :-(

Has anyone had experience with the eeprom dying from excessive writes?
 
"having a go for the fun of it"

Administrator

  • Hero Member
  • *****
  • Posts: 171
    • View Profile
    • http://www.modtronix.com
Re: fsee EEprom Routines....
« Reply #6 on: August 21, 2006, 10:01:24 PM »
Hi

As far as I know you can write each location of the EEPROM 1,000,000 times. For your application you will be writing different locations all the time, is that right? You should have no problem. For details, download Microchip's Endurance Calculation Software. See:
www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010003
*** Modtronix Engineering Support ***

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: fsee EEprom Routines....
« Reply #7 on: August 25, 2006, 02:42:31 AM »
Hi,

I had the same problem on with a project a while back, I over came it by simply using a circular buffer on the chip (eg each write is in a different location) and compressing the data as much as possible to allow for more write locations in the buffer.

---
Daniel
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)

nikosxan

  • Sr. Member
  • ****
  • Posts: 28
    • View Profile
fseePutByte error
« Reply #8 on: April 06, 2010, 09:15:56 AM »
Hello there.

I'm a new user or an SBC65C and i think it's a very nice product. Works well out of the box and has a lot of nice s/w to start with.

I used some fsee functions in order to save/read some parameters to EEPROM. Unfortunately i can only read from a file but not able to write. Every time i call fseeputbyte code fails and the board needs a reset.

I put some debug code right before the putbyte routine (just an fseegetbyte and works OK....

After that i saw in the code and some old thread that this was not tested by Modtron ix since
'...This implementation was written by OmarZ...'. However, this tread seems to be 2.5-3 years old, although this function is in the code.

Is there any progress ?

Has anybody else faced the same problem ? Is there a workaround ?
I thought at the beginning to write directly to EEPROM (internal, external) but took into account forum opinions not to.

Nick