Hi
I am measuring the accessing time for SRAM on MSP430FR5969. According to the datasheet, the address is from 001C00h-0023FFh. So I use this code to write to SRAM.
#define OUTPIN BIT5
/*
* main.c
*/
void SRAM_write(void);
unsigned int data=0x11;
#define SRAM_TEST_START 0x1D00
int main(void) {
int i=5;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1OUT &= ~OUTPIN;
P1DIR |= OUTPIN;
PM5CTL0 &= ~LOCKLPM5;
while(1)
{
for (i=0;i<200;i++)
SRAM_write();
P1OUT ^= OUTPIN;
}
}
void SRAM_write(void)
{
int i;
SRAM_ptr_write = (unsigned int *)SRAM_TEST_START;
for(i=0;i<256;i++)
{
*SRAM_ptr_write=data;
SRAM_ptr_write++;
}
}
But the accessing time (when measuring, it's the time writing to ram 256*200 times) is equal to the FRAM, which means I am accessing to the FRAM.
Then I use the following code, using a vector instead of the pointer. And the time is 3/4 of previous time.
#define OUTPIN BIT5
/*
* main.c
*/
void SRAM_write(void);
unsigned int data=0x11;
#pragma DATA_SECTION(SRAM_ptr_write, ".sram")
volatile unsigned int SRAM_ptr_write[257];
int main(void) {
int i=5;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1OUT &= ~OUTPIN;
P1DIR |= OUTPIN;
PM5CTL0 &= ~LOCKLPM5;
while(1)
{
//P1OUT ^= OUTPIN;
for (i=0;i<200;i++)
SRAM_write();
P1OUT ^= OUTPIN;
}
}
void SRAM_write(void)
{
int i;
for(i=0;i<256;i++)
{
SRAM_ptr_write[i]=data;
}
}
So what's the problem with my first code? Why can't I access to the SRAM using the pointer?
Thanks!
Yin