Hello,
would like to check the exact how-to for setting DCOCLK to 1048576 on the MSP432.
1) Based on what I've read till now, one can set DCO to 1,5/3/6/12/24/48 MHz and to 'tune' it to the exact CLK one desires, one uses DCOTUNE as shown from this document : http://www.ti.com/lit/an/slaa658a/slaa658a.pdf
in which the calculation for DCOTUNE was shown :
But what I am not sure is what are the values I should be inserting into the equation..because I tried setting DCOTUNE as 0x485 to get 2 MHz but it didn't work. Here's the sample code I worked with:
#include "msp.h"
#include <stdint.h>
#define DCOTUNE 0x485
int main(void) {
volatile uint32_t i;
WDT_A->CTL = WDT_A_CTL_PW | // Stop WDT
WDT_A_CTL_HOLD;
P1->DIR |= BIT0; // P1.0 set as output
P4->DIR |= BIT2 | BIT3;
P4->SEL0 |= BIT2 | BIT3; // Output ACLK & MCLK
P4->SEL1 &= ~(BIT2 | BIT3);
CS->KEY = CS_KEY_VAL; // Unlock CS module for register access
CS->CTL0 = CS_CTL0_DCORSEL_0 | CS_CTL0_DCOTUNE_OFS;
CS->CTL1 = CS_CTL1_SELA_2 | CS_CTL1_SELS_3 | CS_CTL1_SELM_3;
CS->KEY = 0; // Lock CS module from unintended accesses
while (1) // continuous loop
{
P1->OUT ^= BIT0; // XOR P1.0
for (i = 20000; i > 0; i--); // Delay
}
}
I got with an OSCI, SMCLK and MCLK = 1.5 MHz, ACLK = ~32 kHz and the led blinks at 1.9 Hz, after having set DCOTUNE for a DCO of 2MHz.
I assume I made a mistake somewhere or perhaps missed a specific line of settings for it?
2) I came across a 2nd possibility in the same document which was to use DriverLib API CS_setFrequency(xxxxxxx) would also work. But does that mean I can just forgo all the usual CS-> Key/CTL0/CTL1 settings with this one line?
3) ALSO what exactly happens when I change __SYSTEM_CLOCK under system_msp432p401r.c? Am I right to assume that changing the CLK there to any specific frequency I want changes the default DCOCLK?
Any help would be appreciated. Thank you very much.