Hello to all, I am a student that this programming MSP430f169 for a
project, but I have a small problem with the programming of the clock,
my code for init the osccillator is the following one:
1 | void InitOsc(void)
|
2 | {
|
3 | WDTCTL = WDTPW | WDTHOLD; // Paramos el watchdog timer
|
4 | BCSCTL1 |= XTS; // XT1 ~ high-frequency
|
5 | _BIC_SR(OSCOFF); // turn on XT1 oscillator
|
6 |
|
7 | do // wait in loop until crystal is stable
|
8 | IFG1 &= ~OFIFG;
|
9 | while (IFG1 & OFIFG);
|
10 |
|
11 | BCSCTL1 |= DIVA1 | DIVA0; // ACLK = XT1 / 8 = 1 MHz
|
12 | IE1 &= ~WDTIE; // desactiva WDT int.
|
13 | IFG1 &= ~WDTIFG; // clear WDT int. flag
|
14 | WDTCTL = WDTPW | WDTTMSEL | WDTCNTCL | WDTSSEL | WDTIS1;
|
15 | // use WDT as timer, flag each. 512 pulses from ACLK
|
16 |
|
17 | while (~(IFG1 & WDTIFG)); // cuenta 1024 pulsos XT1
|
18 |
|
19 | IFG1 &= ~OFIFG; // clear osc. fault int. flag
|
20 | DCOCTL |= DCO2 | DCO1 | DCO0;
|
21 | BCSCTL1 |= RSEL2 | RSEL1 | RSEL0; // MCLK = DCO, 8 MHz (MCLK=Reloj de la CPU)
|
22 | }
|
And not because he still has to me blocked in the intruccion:
While (~ (IFG1 and WDTIFG));
It is supposed that on having put the Watchdog already not deberia to
enter(approach) of indefinite form, but does it.
Regards to all, I wait for answers