How would I write to memory?
I am trying to write a simple test for RAM to check basic integrity of the memory on board an embedded device. This is what I want to be able to do:

Essentially write out certain patterns: "10101010101010" to a block of memory then write "01010101010" then re-write the first one and test to see if the pattern was written correctly.

I am trying to write this program in C. I was wondering how I would go about writing this pattern. I want to be able to flip certain bits  within the RAM memory cells on and off. 

Would I just get allocate a block of memory and then write do something like


    uint32 pattern = 0xaaaaaaaa;
    uint32 * mem_loc = malloc some memory;
    int i = 0;
    int offset = 1; 
    uint32 * location = &mem_loc;
    
    while ((&mem_loc)++ && (!int))  {
       &mem_loc = pattern;
       if (!(&(mem_loc+offet))) { 
          mem_loc = location;
          pattern = 0x55555555;
          i++;
       }
    }
  
    //Check to see if values written are consistent

Would the code above work?? Will writing out the hex patterns to memory turn the bits on in the pattern?

I know the code above is horribly mangled but I just want to get an idea if doing something like that with the correct logic will achieve the desired result.

Thanks
   
        
        
How would I write to memory?
===

I am trying to write a simple test for RAM to check basic integrity of the memory on board an embedded device. This is what I want to be able to do:

Essentially write out certain patterns: "10101010101010" to a block of memory then write "01010101010" then re-write the first one and test to see if the pattern was written correctly.

I am trying to write this program in C. I was wondering how I would go about writing this pattern. I want to be able to flip certain bits  within the RAM memory cells on and off. 

Would I just get allocate a block of memory and then write do something like


    uint32 pattern = 0xaaaaaaaa;
    uint32 * mem_loc = malloc some memory;
    int i = 0;
    int offset = 1; 
    uint32 * location = &mem_loc;
    
    while ((&mem_loc)++ && (!int))  {
       &mem_loc = pattern;
       if (!(&(mem_loc+offet))) { 
          mem_loc = location;
          pattern = 0x55555555;
          i++;
       }
    }
  
    //Check to see if values written are consistent

Would the code above work?? Will writing out the hex patterns to memory turn the bits on in the pattern?

I know the code above is horribly mangled but I just want to get an idea if doing something like that with the correct logic will achieve the desired result.

Thanks
   
        
        