So in my code I set split up the RAM into two sections, the section I am concerned about holds two 128 byte arrays. To place them in that specific RAM section (referred to ".ram_data") I used the `#pragma LOCATION` and set their contents with `memset`. Next, I wanted to copy the data from one array to the other, which can be done with `memcpy`, but then move the initial data array to a new location in the `.ram_data` section. Can this be done when the LOCATION pragma is already used in the program? Another option I read about was using `#pragma DATA_SECTION`, but then I run into problems where the size of `.bss` section is not big enough, even though I am not place the arrays in the `.bss` section, rather my created `.ram_data` section.
My question can be summarized by asking how I can change the memory address of the the data arrays after they have been set using #pragma directives. A partial listing of my code is below. Thank you!
#include <msp430.h>
#include <string.h>
#include <stdint.h>
#include "ram_data_ccs_mem.h"
#define INTERRUPT_VALUE 0x0A // counter for interrupts (see above for calculations)
#define ARRAY_STEP 0x80 // increase/decrease movement of data (128 bytes)
#define ARRAY_SIZE 0x80 // size of data (128 bytes)
/* function declarations */
void configWDT(void); // halts the watchdog timer
void configClocks(void); // selects ACLK/8 as frequency
void configGPIO(void); // disables/enables GPIO pins
void configTimerA(void); // configures TimerA for interrupt counter
uint32_t *memory_copy(uint32_t *, uint32_t *, char); // moves data around RAM and clears previous location
/* global variables */
static volatile unsigned char toggle_LED; // toggles red LED (used for debugging)
static volatile unsigned short intrp_flg; // counts number of interrupts of TimerA
/* forces processor to place data arrays in RAM */
//#pragma DATA_SECTION(dest_loc, ".ram_data")
//char cur_loc[128]; // current location of array in RAM
//char dest_loc[128]; // next memory location in RAM for array
#pragma LOCATION(cur_loc, 0x220)
char cur_loc[128];
#pragma LOCATION(dest_loc, 0x2A0)
char dest_loc[128];
int main(void)
{
/* initalize globals */
toggle_LED = 0;
intrp_flg = 0;
//static char reverse_dataflow = 0;
/* configure watchdog timer, clocks, GPIO pins, and TimerA of processor */
configWDT();
configClocks();
configGPIO();
configTimerA();
/* initialize data arrays to be moved throughout RAM */
int dest = RAM_DATA_START_ADDR + ARRAY_STEP; // starting position is beginning of available RAM
memset(cur_loc, '#', ARRAY_SIZE); // fill memory with arbitrary data (used for debugging)
memset(dest_loc, '\0', RAM_DATA_END_ADDR - RAM_DATA_START_ADDR + ARRAY_STEP); // clear remaining RAM_DATA sapce
__no_operation(); // (used for debugging)
...
}