Jump to content

jet

Members
  • Content Count

    6
  • Joined

  • Last visited

  • Days Won

    1
  1. jet

    Server help needed

    You could use nagios to monitor the server and find the issue, it's what we do at my work place. Here is a link to host based tools http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
  2. jet

    Energia MspFlash storing Intergers

    Thanks for the help with the library.
  3. jet

    Energia MspFlash storing Intergers

    #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 // int x = -5; int pos = 0; // store in the 1st integer sized position 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(x); Serial.println(x, HEX); Serial.println(sizeof(int)); Serial.println("."); Serial.println("Read:"); Flash.read(flash+(pos * sizeof(int)), &p, sizeof(int)); Serial.println(p, HEX); Serial.println(p); Serial.println("."); } void doErase() { Serial.println("Erase"); Flash.erase(flash); Serial.println("Done."); } void doWrite() { Serial.println("Write"); Flash.write(flash + (pos * sizeof(int)), (unsigned char*)&x, sizeof(int)); Serial.println("Done."); } Run and compare the output
  4. jet

    Energia MspFlash storing Intergers

    Integer values do not write and read correctly. My change is a quick fix that works for writing a single int. Edit: A unsigned char cannot hold an integer over 255 or that is negitve. The code below can be used to write upto 32 integer value in a segment and by overloading the write function it does not add to the code size if you do not use the function. If you use both versions of the function it adds 94 bytes to the code size. void MspFlashClass::write(unsigned char *flash, int src, int pos) { if( pos <=31 ) { disableWatchDog(); // Disable WDT FCTL2 = FWKEY+FLASHCLOCK; // SMCLK/2 FCTL3 = FWKEY; // Clear LOCK FCTL1 = FWKEY+WRT; // Enable write *(flash+(2 * pos)) = src; FCTL1 = FWKEY; //Done. Clear WRT FCTL3 = FWKEY+LOCK; // Set LOCK enableWatchDog(); // Enable WDT } }
  5. jet

    Energia MspFlash storing Intergers

    I Solved it my self by adding this function to the MspFlash class. void MspFlashClass::write(unsigned char *flash, int src, int len) { disableWatchDog(); // Disable WDT FCTL2 = FWKEY+FLASHCLOCK; // SMCLK/2 FCTL3 = FWKEY; // Clear LOCK FCTL1 = FWKEY+WRT; // Enable write *flash = src; FCTL1 = FWKEY; //Done. Clear WRT FCTL3 = FWKEY+LOCK; // Set LOCK enableWatchDog(); // Enable WDT }
  6. I'm using a LaunchPad MSP430G2 revision 1.4 with a MSP430G2553 chip and Energia release 0101E0011. I can not figure out how to store and retrieve an interger value to Flash Segment D using the MspFlash library.
×