Hi,
I am working on a design in which I would like to store a few variables in to
information flash, for now I am trying to get it working with segment c.
The microcontroller used is a msp430f4783 with a 32kHz and a 4MHz crystal
connected. The frequencies of the crystals are good, checked both with scope
and by using a logic analyzer connected to LEDs controlled by the basic timer
and timer A. The FLL is set to give 32768Hz on ACLK, 8.388MHz on MCLK
and 4MHz on SMCLK.
The problem is that I can not write to flash with Fftg derived from SMCLK set in
my own setup for the FLL. Fftg must be between 257 and 476 kHz.
I have set the flash timing generator to use SMCLK and divide by 12 :
FCTL2 = FWKEY + FSSEL_3 + FN3 + FN1 + FN0;
(Fftg = 4 MHz / 12 = 333333 Hz)
It works strangely enough if I select ACLK as input clock :
FCTL2 = FWKEY + FSSEL_0 + 0;
(Fftg = 32768 Hz / 1 = 32768 Hz)
The setup from msp430x47xx_flashwrite_01.c works at a calculated 349.5 kHz
with MCLK as input :
FCTL2 = FWKEY + FSSEL_1 + 2;
(Fftg = 32768 Hz * 32 / 3 = 349525 Hz)
The subroutine for setting up the FLL :
void oscillatoren_init(void)
{
unsigned integer i;
// maak de oscillator fout bitjes laag
// FLL_CTL0 &= ~(LFOF | DCOF);
// initialiseer de 32kHz oscillator lfxt1 in laag frequentie mode
FLL_CTL0 &= ~XTS_FLL;
// met 5pF condensatoren
FLL_CTL0 |= XCAP5_5F;
// wacht tot oscillator lfxt1 gestabiliseerd is
do
{
IFG1 &= ~OFIFG;
for(i = 10000; i > 0; i--)
{
}
}
while(IFG1 & OFIFG);
// initialiseer de DCO oscillator
// de eerste 8 maal vermenigvuldiging van lfxt1
FLL_CTL0 |= DCOPLUS;
// fdco = lfxt1 * FLLD_8 * SCFQ_1M = 8.388MHz
// fdco = 32768 * 8 * 32 = 8.388MHz
SCFI0 |= FLLD_8 | FN_2;
SCFQCTL = SCFQ_1M;
// selecteer dco als mclk
FLL_CTL1 |= SELM0;
// initialiseer de 4MHz oscillator xt2 in hoge frequentie mode
FLL_CTL2 = XT2S1;
// zet oscillator xt2 aan
FLL_CTL1 &= ~XT2OFF;
// selecteer xt2 smclk
FLL_CTL1 |= SELS;
}
I can not figure out what I am doing wrong here. Is there some one who
has this timing thing working at another frequency then 32 kHz or 1 MHz ?
I have selected several input and divider combinations for the flash timing
generator but none work except for the frequencies as mentioned above.
There is an errata FLL7 which as far as I can tell does not apply to my problem.
roelof