Jump to content

ElTita

Members
  • Content Count

    2
  • Joined

  • Last visited

About ElTita

  • Rank
    Noob Class

Profile Information

  • Location
    Argentina
  1. Thans to all! @@oPossum using a pointer in ram, well, it will be lost after a power off and I think power off the device About use a FRAM MSP430s, I think my launchad don't support these (anyway I don't have money for the moment, but I will consider it in the future) @@hmjswt Do you know if a external EEPROM can be used with a MSP430G2553? EDIT: ohhhhh , yeah, thanks for the link! Good point! After a erase, the segments will have all 1's, AND probably I will log 10 bits values in two bytes (the analog to digital converter have 10 bits) I think something like that: //called in power on, then this position is stored and updated in RAM int findEndOfDataPoisition() { unsigned char * init = FIRST_BYTE_OF_DATA_SEGMENTS; int position = 0; while ((position < MAX_POSITION && *(init+position)!=0xFF) { position +=2; } if (position < MAX_POSITION) return position; else return MAX_POSITION; //log full.... what to do? } Are you sure? If that is the case, well, documentation is very poor.... one thing is "data can be corrupted" o other very different "damage can occur" In any case (damage or corruption data) it must be pointed that example of use of library MspFlash is very dangerous (it allows multiples writes without erases....): #include "MspFlash.h" // Two options to use for flash: One of the info flash segments, or a part of the program memory // either define a bit of constant program memory, and pass a pointer to the start of a segment to the flash functions, //*** Option 1: use program memory, uncomment these lines and you have 512 bytes of flash available (1024 bytes allocated) **** //const unsigned char data[2*SEGMENT_SIZE] = {0}; //#define flash SEGPTR(data) // //*** Option 2: use one of the 64 byte info segments, uncomment this line. Use SEGMENT_B, SEGMENT_C or SEGMENT_D (each 64 bytes, 192 bytes in total) #define flash SEGMENT_D // void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: if ( Serial.available() ) { switch ( Serial.read() ) { case 'e': doErase(); break; case 'r': doRead(); break; case 'w': doWrite(); break; case 10: case 13: break; default: doHelp(); } } } void doRead() { unsigned char p = 0; int i=0; Serial.println("Read:"); do { Flash.read(flash+i, &p, 1); Serial.write(p); Serial.print(":"); Serial.println(p); } while ( p && (i++ < 16) ); Serial.println("."); } void doErase() { Serial.println("Erase"); Flash.erase(flash); Serial.println("Done."); } void doWrite() { Serial.println("Write"); Flash.write(flash, (unsigned char*) "Hello World!" ,13); Serial.println("Done."); } void doHelp() { int div = (F_CPU/400000L) & 63; Serial.println("flash test: e, r, w"); Serial.println(F_CPU); Serial.println(div); } About 10000 cycles write-erase per segment... well 10000*5/(60*24)= 34 days of time of life.... ouch.... (ok, i can store the end of array, say every hour and/or when it is externally ordered, but I don't see that very elegant...)
  2. Hi, it's my firts post, sorry by my English. I need make a temperature sensor that logs in flash memory sensed temperutes, say every 5 minutes. This logs, are read sensed by serial comunication. Something like this: int cantLogs = 0; //called repeatedly by a control routine void loopSensor() { int temp = readTemp(); cantLogs++; storeTemp(cantLogs, temp); sleep(5 minutes) } //storeTemp save temp in flash, and ALSO save position (that is, the last position used) void storeTemp (int position, int temp) { .... } //that fuction when is called read all temps and sends it by the serial line (it DON'T use variable //cantLogs, it needs know how much logs are here reading that info from memory flash) void readTemps() { .... } Ok, I think that I need is a data structure like this, using diferent flash segments; one for control data (last position used) and othes for the data itselft: <pre> ControlSegment = [lastPositionUsedInDataSegments,.........(maybe other info)....] DataSegments = [temp1, temp2.....tempN] [temPN+1,..... Temp2N-1][... and so on...] </pre> Well.... bytes in DataSegments are written sequentially, and lastPostionUsedInDataSegments in ControlSegment needs to be updated every time one temp is logged....So: - Do I need erase data segments previous the first write? And between writes in the same segment? (that is; i have logged temp1; now a I need log temp2, do I need do something special between these writes? - How to updates in lastPositionUsedInDataSegments must be implemented? (erase all segment and then write the first bytes?) - And finally.... reading 7.3.3 Writing Flash Memory in "MSP430x2xx Family User's Guide" I found that: WTF? If, for example, I write 3 times lastPositionUsedInDataSegments (firt bytes in a flash segment) without call "erase segment" fuction I can damage my flash memory????? guide: http://www.ti.com/lit/ug/slau144j/slau144j.pdf Thanks! P.S: if someone have some real code doing something similar (I think that it is a usual situation: log persistently sensed data for subsequent ) I will appreciate it.
×
×
  • Create New...