Other Parts Discussed in Thread: MSP430FG4618
Hi, i'm trying record data to flash mem. using DMA but every time it records wrong value. I mean, i have RESLO = 0x031A but dma records to flash 0xAEE4 value. What can be the problem? I'm looking this a whole day but i couldn't solve this problem. I wish someone help me. (using msp430fg4618 exp board)
Thanks.
void main(void){
WDTCTL = WDTPW + WDTHOLD;
volatile unsigned int i;
WDTCTL = WDTPW +WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG));
RESLO = 0x031A;
TBCTL = TBSSEL_2; // Use SMCLK as Timer_B source
TBR = 0;
TBCCR0 = 100;
TBCCR2 = 50;
TBCCTL2 = OUTMOD_7;
DMACTL0 = DMA0TSEL_2;
DMA0SA = (unsigned int)RESLO;
DMA0DA = 0x9c00;
DMA0SZ = 0x0001; // 1-word transfer
DMA0CTL = DMAEN + DMAIE;
FCTL2 = FWKEY + FSSEL1 + FN1; // SMCLK/3 = ~333kHz
FCTL3 = FWKEY; // Unlock Flash memory for write
FCTL1 = FWKEY + WRT; // Enable Flash write for recording
TBCTL |= MC0;
__bis_SR_register(LPM0_bits + GIE);
__disable_interrupt();
FCTL1 = FWKEY; // Disable Flash write
FCTL3 = FWKEY + LOCK; // Lock Flash memory
TBCTL = 0;
}
#pragma vector=DMA_VECTOR
__interrupt void DMA_ISR(void)
{
DMA0CTL &= ~DMAIFG;
__bic_SR_register_on_exit(LPM0_bits);
}