USING KNOWLEDGE FROM C LANGUAGE PRGRAMMING DONT
COMPILE ONLY JUST READ EACH OF THE FOLLWING LINES AND EXPLAIN WHAT
THE LINES ARE DOING.
#include <stdint.h> //exact-width integer types
#include <ti\devices\msp432p4xx\driverlib\driverlib.h> //driver library
#define DCO_FREQ 48e6 //unit: Hz
uint32_t mclk, hsmclk, smclk, aclk, bclk;
void main(void)
{
uint32_t n;
WDT_A_holdTimer(); //stop watchdog timer
//Set the DCO Frequency.
//Only use DCO nominal frequencies: 1.5, 3, 6, 12, 24, 48MHz.
//Enable FPU for DCO Frequency calculation.
//Change VCORE to 1 to support a frequency higher than 24MHz.
//See data sheet for Flash wait-state requirement for a given frequency.
FPU_enableModule();
PCM_setCoreVoltageLevel(PCM_VCORE1);
FlashCtl_setWaitState(FLASH_BANK0, 1);
FlashCtl_setWaitState(FLASH_BANK1, 1);
CS_setDCOFrequency(DCO_FREQ);
//Init clock signals: MCLK, HSMCLK, SMCLK.
//Can be divided by 1, 2, 4, 8, 16, 32, 64, or 128.
CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
CS_initClockSignal(CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_8);
CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_16);
//Get clock signals settings.
mclk = CS_getMCLK();
hsmclk = CS_getHSMCLK();
smclk = CS_getSMCLK();
aclk = CS_getACLK();
bclk = CS_getBCLK();
//Configure P1.0 as output.
//P1.0 is connected to a red LED on LaunchPad.
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
while(1)
{
//simple delay loop
for(n=0; n<1000000; n++)
{
//do nothing
}
GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
}
}
Please save it as '.c' file and open in a text editor then you will be able to differentiate comments and code easily
----------------------------------------------
#include <stdint.h> //Including stdint.h, stdint.h is a header file that having specified width by defining corresponding macros,
#include <ti\devices\msp432p4xx\driverlib\driverlib.h>
//driver library is boing included from the specified path
//Driver library is a set of APIs used to configure, control the
hardware periferals of MSP432 platform
#define DCO_FREQ 48e6 //DCO_FREQ is the macro, it means where ever
we have DCO_FREQ we have the value, 48e6,
//DCO_FREQ: Frequency in Hz that the user wants to set the DCO
to.
uint32_t mclk, hsmclk, smclk, aclk, bclk; // these are variables defined of type uint32_t, uint32_t is unsigned value between 0 to 2^32 -1
void main(void)
{
uint32_t n; //Another variable n of type uint32_t
WDT_A_holdTimer(); //stop watchdog timer from running, this way no interrupt or PUC is asserted
//Set the DCO Frequency.
//Only use DCO nominal frequencies: 1.5, 3, 6, 12, 24, 48MHz.
//Enable FPU for DCO Frequency calculation.
//Change VCORE to 1 to support a frequency higher than 24MHz.
//See data sheet for Flash wait-state requirement for a given frequency.
FPU_enableModule(); //This function enables the floating-point instructions to be executed
PCM_setCoreVoltageLevel(PCM_VCORE1); //This functions sets the core voltage level
FlashCtl_setWaitState(FLASH_BANK0, 1); //sets two variables, FLASH_BANK to set wait state for, waitState: the number of wait state to set
FlashCtl_setWaitState(FLASH_BANK1, 1);
CS_setDCOFrequency(DCO_FREQ); //Automatically sets/tunes the DCO to the given frequency. DCO_FREQ: Frequency in Hz that the user wants to set the DCO to.
//Init clock signals: MCLK, HSMCLK, SMCLK.
//Can be divided by 1, 2, 4, 8, 16, 32, 64, or 128.
CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT,
CS_CLOCK_DIVIDER_1); //This function initializes each of the clock
signals.
/* The user must ensure that this function is called for each clock
signal
3 variables passed are
ClockSignal-Clock signal to initialize.
clockSource-Clock source for the selectedClockSignal signal.
clockSourceDivider-selected the clock divider to calculate clock
signal from clock source. This parameter is
ignored when setting BLCK.
*/
CS_initClockSignal(CS_HSMCLK, CS_DCOCLK_SELECT,
CS_CLOCK_DIVIDER_8);
CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_16);
//Get clock signals settings.
//Followinf 5 functions return corresponding MCLK frequency, SMCLK
frequency etc.
mclk = CS_getMCLK(); //If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module.
hsmclk = CS_getHSMCLK();
smclk = CS_getSMCLK();
aclk = CS_getACLK();
bclk = CS_getBCLK();
/*
This function configures the selected Pin as output pin.
This function selected pins on a selected port as output
pins.
Two variables
selectedPort is the selected port.
selectedPins is the specified pin in the selected port.
*/
//Configure P1.0 as output.
//P1.0 is connected to a red LED on LaunchPad.
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
while(1)
{
//simple delay loop
for(n=0; n<1000000; n++)
{
//do nothing
}
/*
This function toggles the output on the selected Pin.
This function toggles the output on the selected port’s pin.
*/
GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
}
}
USING KNOWLEDGE FROM C LANGUAGE PRGRAMMING DONT COMPILE ONLY JUST READ EACH OF THE FOLLWING LINES...