This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USBMem example : changing the contents of readme.txt file

Hi,

I am playing around with the USBMem example for the MCB214x Board.
Using a hex editor I found the offset (0x800) of the data area on the RAM and wrote the following code to change the data in the readme.txt file.

I created a counter variable and it increments when I press switch sw1. I want to store its value into the file every time I push the switch.

class variables


U8 * offset = &Memory[0x800];
int counter=0;

now inside main function I wrote following code


PINSEL0 = PINSEL0|(0<<15);
IO0DIR = (0<<15);


  while (1){
        if(!SW1){
          counter = counter+1;
          LED_On(1<<16);

          *offset = counter;         //line 1
          offset +=4;                // line 2
        } else {LED_Off(1<<16);}
};

The problem is that when I run the code on the board the led remains on after I have pressed the switch!
However When I comment out the lines "line 1" and "line 2" and run the code the led switches on and off perfectly fine!

can anybody explain me whats going on wrong here ?

  • Why are you stepping forward the offset?

    Another thing here is that you don't have any logic to perform each state only once and then wait until the switch toggles. So your loop can do counter++ filling the memory with an increasing numeric series while overwriting lots of other data.