• Not Answered

MSP430FR5730: FRAM write issue

Part Number: MSP430FR5730

Hi,

I'm using MSP430FR5730 to store a camera flash counter in the FRAM. Both counter and start_flag are noinit variable, and are stored in the FRAM. Following code worked fine at simulation, however it does not work when a real camera flash fires. I toggled a pin to make sure the edge detection logic worked. When the flash fired, I could see the pin toggling on the oscilloscope every time. However, the counter never changed. 

Does this mean that the FRAM can not be used in a such environment that may be a little noise? Or am I missing something here?

thanks

Peng

////////////////////////////////////////////////////////////////////////

// in the .cmd file

//.TI.noinit  : {} > FRAM                /* For #pragma noinit                */

////////////////////////////////////////////////////////////////////////

/*
* ======== Standard MSP430 includes ========
*/
#include <msp430.h>

/*
* ======== Grace related includes ========
*/
#include <ti/mcu/msp430/Grace.h>
#include "stdint.h"
#include "driverlib.h"

#include "board.h"
/*
* ======== main ========
*/

#pragma NOINIT(counter)
uint16_t counter;
#pragma NOINIT(start_flag)
uint16_t start_flag;

int main(void)
{
Grace_init(); // Activate Grace-generated configuration
// >>>>> Fill-in user code here <<<<<

uint8_t port1, port1_delay;
uint8_t i;

//init counter at on a blank board
if(start_flag != 0x1298) {
start_flag=0x1298;
counter=0;
}
GPIO_setOutputLowOnPin(GPIO_PORT_P2,GPIO_PIN4);
port1=1;
port1_delay=1;
while(1){
port1=P2IN & BIT6;
if((port1_delay!=0) && (port1==0)){ // falling edge
for(i=0;i<100;i++); // delay about 1us
port1=P2IN & BIT6; // verify the pin status again for de-jitter purpose
if(port1==0){
// flash detected, increase the counter and write it back the FRAM
counter++;
GPIO_setOutputHighOnPin(GPIO_PORT_P2,GPIO_PIN4); // toggle the pin for debug purpose
for(i=0;i<10;i++);
GPIO_setOutputLowOnPin(GPIO_PORT_P2,GPIO_PIN4);

}
}

port1_delay=port1;

}


return (0);
}

7 Replies