MSPM0_ValvanoWare  1.0
ECE445L starter code
Files | Macros | Functions
Clock

Provide functions that initialize the MSPM0 clock module. More...

Files

file  Clock.h
 Provide functions that initialize the MSPM0 clock module.
 

Macros

#define OSCFREQ32MHZ   0
 using OSCFREQ32MHZ Clock_Init will create 32 MHz bus clock
 
#define OSCFREQ4MHZ   1
 using OSCFREQ4MHZ Clock_Init will create 4 MHz bus clock
 

Functions

void Clock_Init80MHz (int enablePA14)
 Initialize clock to 80 MHz. More...
 
void Clock_Init_HFXT_40_80MHz (int enablePA14)
 Initialize clock to 80 MHz. More...
 
void Clock_Init40MHz (void)
 Initialize clock to 40 MHz. More...
 
void Clock_Init_HFXT_16MHz (void)
 Initialize clock to 16 MHz. More...
 
void Clock_Init_HFXT_16_80MHz (int enablePA14)
 Initialize clock to 80 MHz. More...
 
void Clock_Init (uint32_t freq)
 Initialize clock to 4 or 32 MHz. More...
 
uint32_t Clock_Freq (void)
 Returns current clock bus frequency in Hz. More...
 
void Clock_Delay (uint32_t cycles) __attribute__((noinline))
 Software implementation of a busy-wait delay. More...
 
void Clock_Delay1ms (uint32_t ms)
 Software implementation of a busy-wait delay. More...
 
void SysTick_Init (void)
 SysTick for busy-wait delay. More...
 
void SysTick_Wait (uint32_t delay)
 SysTick implementation of a busy-wait delay. More...
 
void SysTick_Wait10ms (uint32_t t)
 SysTick implementation of a busy-wait delay. More...
 
void TimerG8_Init (uint32_t divider, uint32_t prescale)
 SysTick for busy-wait delay. More...
 

Detailed Description

Provide functions that initialize the MSPM0 clock module.

Clock pins
Pin Description
PA5 HFXIN crystal
PA6 HFXOUT crystal
PA14 Possible clock output

Function Documentation

◆ Clock_Delay()

void Clock_Delay ( uint32_t  cycles)

Software implementation of a busy-wait delay.

Simple delay function which delays about cycles bus cycles. It is implemented with a for-loop and is approximate.

Parameters
cyclesis the number of bus cycles to wait
Returns
none
Note
For a more accurate time delay, you could use the SysTick module.

◆ Clock_Delay1ms()

void Clock_Delay1ms ( uint32_t  ms)

Software implementation of a busy-wait delay.

Simple delay function which delays about ms milliseconds. It is implemented with a nested for-loop and is approximate.

Parameters
msis the number of milliseconds to wait
Returns
none
Note
For a more accurate time delay, you could use the SysTick module.

◆ Clock_Freq()

uint32_t Clock_Freq ( void  )

Returns current clock bus frequency in Hz.

Return the current bus clock frequency

Parameters
none
Returns
frequency of the system clock in Hz
Note
In this module, the return result will be 3000000, 32000000, 40000000 or 80000000
See also
Clock_Init(),Clock_Init40MHz(),Clock_Init80MHz()

◆ Clock_Init()

void Clock_Init ( uint32_t  freq)

Initialize clock to 4 or 32 MHz.

Configure the MSPM0 clock to run at 4MHz or 32MHz

Parameters
freqis either OSCFREQ32MHZ or OSCFREQ4MHZ
Returns
none
Note
Since the crystal is not used, the bus clock will not be accurate
See also
Clock_Freq()

◆ Clock_Init40MHz()

void Clock_Init40MHz ( void  )

Initialize clock to 40 MHz.

Configure the MSPM0 clock to run at 40 MHz, assuming 40MHz crystal exists across PA5 PA6 (LaunchPad)

Parameters
none
Returns
none
Note
Since the crystal is used, the bus clock will be very accurate
See also
Clock_Freq()

◆ Clock_Init80MHz()

void Clock_Init80MHz ( int  enablePA14)

Initialize clock to 80 MHz.

Configure the MSPM0 clock to run at 80 MHz

Parameters
enablePA141 means 10 MHz sinewave clock output on PA14, 0 means no output on PA14
Returns
none
Note
Since the internal oscillator is used, the bus clock will only be 0.07%
See also
Clock_Freq()

◆ Clock_Init_HFXT_16_80MHz()

void Clock_Init_HFXT_16_80MHz ( int  enablePA14)

Initialize clock to 80 MHz.

Configure the MSPM0 clock to run at 80 MHz, assuming 16MHz crystal exists across PA5 PA6 (ECE445L project boards)

  • PA5 is HFXIN
  • PA6 is HFXOUT
    Parameters
    enablePA141 means 10 MHz sinewave clock output on PA14, 0 means no output on PA14
    Returns
    none
    Note
    Since the 16 MHz crystal is used, the bus clock will be very accurate
    See also
    Clock_Freq()

◆ Clock_Init_HFXT_16MHz()

void Clock_Init_HFXT_16MHz ( void  )

Initialize clock to 16 MHz.

Configure the MSPM0 clock to run at 16 MHz, assuming 16MHz crystal exists across PA5 PA6 (ECE445L project boards)

  • PA5 is HFXIN
  • PA6 is HFXOUT runs ok, if
  • after hardware reset button
  • after power on reset
  • after debug Run-Debug launch
    Note
    sometimes crashes after debugger pause/resume or debugger pause/reset
    Parameters
    none
    Returns
    none
    Note
    Since the crystal is used, the bus clock will be very accurate
    See also
    Clock_Freq()

◆ Clock_Init_HFXT_40_80MHz()

void Clock_Init_HFXT_40_80MHz ( int  enablePA14)

Initialize clock to 80 MHz.

Configure the MSPM0 clock to run at 80 MHz, assuming 40MHz crystal exists across PA5 PA6 (LaunchPad)

  • PA5 is HFXIN
  • PA6 is HFXOUT
    Parameters
    enablePA141 means 10 MHz sinewave clock output on PA14, 0 means no output on PA14
    Returns
    none
    Note
    Since the 40 MHz crystal is used, the bus clock will be very accurate
    See also
    Clock_Freq()

◆ SysTick_Init()

void SysTick_Init ( void  )

SysTick for busy-wait delay.

Initialize the 24-bit SysTick timer.

Parameters
none
Returns
none
Note
Call this before using SysTick_Wait or SysTick_Wait10ms.

◆ SysTick_Wait()

void SysTick_Wait ( uint32_t  delay)

SysTick implementation of a busy-wait delay.

Delay function which delays about delay bus cycles. It is implemented with SysTick and is accurate.

Parameters
delayis the number of bus cycles to wait
Returns
none

◆ SysTick_Wait10ms()

void SysTick_Wait10ms ( uint32_t  t)

SysTick implementation of a busy-wait delay.

Delay function which delays about t*10ms time, assuming the bus clock is 80 MHz. It is implemented with SysTick and is accurate.

Parameters
tis the time to wait (units 10ms)
Returns
none

◆ TimerG8_Init()

void TimerG8_Init ( uint32_t  divider,
uint32_t  prescale 
)

SysTick for busy-wait delay.

Initialize the 16-bit G8 timer for continuous counting. The precision is 16 bits. Simply read TIMG8->COUNTERREGS.CTR for 16 bit time

TimerG8 examples for 80 MHz clock
dividerprescaleresolutionrange
1 1 12.5ns 819 us
1 80 1us 65 ms
1 160 2us 131 ms
5 160 10us 655 ms
8 256 25.6us 1.7 s
Parameters
dividermust be 1 to 8
prescalemust be 1 to 256
Returns
none
Note
resolution is busperiod*divider*prescale