Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MSP430FR5994 BOOSTXL-CC1120-90 Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Energy-Driven Computing
MSP430FR5994 BOOSTXL-CC1120-90 Library
Commits
1bdcd9fd
Commit
1bdcd9fd
authored
5 years ago
by
Edward Longman
Browse files
Options
Downloads
Patches
Plain Diff
move into msp_setup function
parent
a5290be8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
source/lib/hal_mcu/hal_mcu.c
+3
-52
3 additions, 52 deletions
source/lib/hal_mcu/hal_mcu.c
source/lib/hal_mcu/hal_mcu_fr5.h
+59
-0
59 additions, 0 deletions
source/lib/hal_mcu/hal_mcu_fr5.h
source/test/min2.c
+3
-65
3 additions, 65 deletions
source/test/min2.c
with
65 additions
and
117 deletions
source/lib/hal_mcu/hal_mcu.c
+
3
−
52
View file @
1bdcd9fd
...
@@ -168,55 +168,7 @@ void msp_setup(void) {
...
@@ -168,55 +168,7 @@ void msp_setup(void) {
#endif
#endif
#if defined (__MSP430FR5994__)
#if defined (__MSP430FR5994__)
//Define the Main Clock setup options. Done here for the delay function setup
#include
"hal_mcu_fr5.h"
#define DCO_RANGE_SEL DCORSEL
#define DCO_FREQ_SEL DCOFSEL_4
#define F_CPU_SCALE DIVM_0
/**
* @defgroup Delay_function
* @brief Directives to create the _delay_us macro.
* @{
*/
/**
* @def _delay_us(__us)
* @brief Delay for a specified time using the __delay_cycles primitive.
*
* @param[in] __us - time to delay for
* @return none
* @note Assumes using the internal DCO. Will need modification to work with
* XTAL. VLO is two innacurate (6%) for this to be a good delay anyway.
* Max possible delay is (2**32-1)*F_CPU
* That would be 178s for 24MHz.
* helped by https://docs.microsoft.com/en-us/cpp/preprocessor/hash-if-hash-elif-hash-else-and-hash-endif-directives-c-cpp?view=vs-2019
* and https://github.com/ab2tech/msp430/blob/master/include/msp/delay.h
*
*/
#if DCO_RANGE_SEL==DCORSEL
#define F_CPU_RANGE 16000000UL
#else
#define F_CPU_RANGE 5330000UL
#endif
#if DCO_FREQ_SEL==DCOFSEL_0
#define F_CPU F_CPU_RANGE*1.0
#elif DCO_FREQ_SEL==DCOFSEL_1
#define F_CPU F_CPU_RANGE*1.25
#elif DCO_FREQ_SEL==DCOFSEL_2
#define F_CPU F_CPU_RANGE*1.0
#else //DCO_FREQ_SEL==DCOFSEL_3
#define F_CPU F_CPU_RANGE*1.5
#endif
#define F_CPU_SCALED_US F_CPU/(1<<F_CPU_SCALE)/1000000.0
/* Number of CPU cycles per us */
#define _delay_us(__us) \
if((uint32_t) (F_CPU_SCALED_US * __us) != F_CPU_SCALED_US * __us)\
__delay_cycles((uint32_t) ( F_CPU_SCALED_US * __us)+1);\
else __delay_cycles((uint32_t) ( F_CPU_SCALED_US * __us))
/** @} */
/*******************************************************************************
/*******************************************************************************
* @brief Setup all the peripherals of the MSP430, set the CPU speed to 16MHz,
* @brief Setup all the peripherals of the MSP430, set the CPU speed to 16MHz,
* enable the 250kHz and configure WDT for a 1 sec tick speed.
* enable the 250kHz and configure WDT for a 1 sec tick speed.
...
@@ -228,7 +180,6 @@ void msp_setup(void) {
...
@@ -228,7 +180,6 @@ void msp_setup(void) {
* @return none
* @return none
*******************************************************************************/
*******************************************************************************/
void
msp_setup
(
void
)
{
void
msp_setup
(
void
)
{
// Enable the interupts on port 2 to catch the user button (TRXEB)
// Enable the interupts on port 2 to catch the user button (TRXEB)
BUTTON_DIR
&=
~
BUTTON_PIN
;
// input direction
BUTTON_DIR
&=
~
BUTTON_PIN
;
// input direction
...
@@ -241,7 +192,7 @@ void msp_setup(void) {
...
@@ -241,7 +192,7 @@ void msp_setup(void) {
// Removed XTAL configuration and DCO Fault detection as not on exp430_fr5994
// Removed XTAL configuration and DCO Fault detection as not on exp430_fr5994
// Unlock CS registers.
// Unlock CS registers.
CSCTL0
_H
=
0xA5
;
CSCTL0
=
CSKEY
;
// Set DCO to 24MHz.
// Set DCO to 24MHz.
CSCTL1
=
DCO_RANGE_SEL
+
DCO_FREQ_SEL
;
CSCTL1
=
DCO_RANGE_SEL
+
DCO_FREQ_SEL
;
// ACLK = VLO, SMCLK = MCLK = DCO
// ACLK = VLO, SMCLK = MCLK = DCO
...
@@ -251,7 +202,7 @@ void msp_setup(void) {
...
@@ -251,7 +202,7 @@ void msp_setup(void) {
// Power down unused clocks.
// Power down unused clocks.
CSCTL4
=
HFXTOFF
+
VLOOFF
;
CSCTL4
=
HFXTOFF
+
VLOOFF
;
// Lock clock registers.
// Lock clock registers.
CSCTL0
_H
=
0
;
CSCTL0
=
0
;
// Setup Watch dog timer for 0.5 second tick using 16MHz DCO on MSP430FR5994
// Setup Watch dog timer for 0.5 second tick using 16MHz DCO on MSP430FR5994
// WDT 0.5s @ 16mHz, SMCLK, interval timer
// WDT 0.5s @ 16mHz, SMCLK, interval timer
...
...
This diff is collapsed.
Click to expand it.
source/lib/hal_mcu/hal_mcu_fr5.h
0 → 100644
+
59
−
0
View file @
1bdcd9fd
//Define the Main Clock setup options. Done here for the delay function setup
#define DCO_RANGE_SEL DCORSEL
#define DCO_FREQ_SEL DCOFSEL_4
#define F_CPU_SCALE DIVM_0
/**
* @defgroup Delay_function
* @brief Directives to create the _delay_us macro.
* @{
*/
/**
* @def _delay_us(__us)
* @brief Delay for a specified time using the __delay_cycles primitive.
*
* @param[in] __us - time to delay for
* @return none
* @note Assumes using the internal DCO. Will need modification to work with
* XTAL. VLO is two innacurate (6%) for this to be a good delay anyway.
* Max possible delay is (2**32-1)*F_CPU
* That would be 178s for 24MHz.
* helped by https://docs.microsoft.com/en-us/cpp/preprocessor/hash-if-hash-elif-hash-else-and-hash-endif-directives-c-cpp?view=vs-2019
* and https://github.com/ab2tech/msp430/blob/master/include/msp/delay.h
*
*/
#if DCO_RANGE_SEL==DCORSEL
#if DCO_FREQ_SEL>DCOFSEL_3
#define F_CPU_RANGE 5333000UL
#else
#define F_CPU_RANGE 5333000UL*1.5
#endif
#else
#define F_CPU_RANGE 2667000UL
#endif
#if DCO_FREQ_SEL==DCOFSEL_1
#define F_CPU F_CPU_RANGE*1.0
#elif DCO_FREQ_SEL==DCOFSEL_2
#define F_CPU F_CPU_RANGE*1.313
#elif DCO_FREQ_SEL==DCOFSEL_3
#define F_CPU F_CPU_RANGE*1.5
#elif DCO_FREQ_SEL==DCOFSEL_4
#define F_CPU F_CPU_RANGE*2.0
#elif DCO_FREQ_SEL==DCOFSEL_5
#define F_CPU F_CPU_RANGE*2.62
#elif DCO_FREQ_SEL==DCOFSEL_6
#define F_CPU F_CPU_RANGE*3.0
#else //DCO_FREQ_SEL==DCOFSEL_0
#define F_CPU 1000000UL
#endif
#define F_CPU_SCALED_US F_CPU/(1<<F_CPU_SCALE)/1000000.0
/* Number of CPU cycles per us */
#define _delay_us(__us) \
if((uint32_t) (F_CPU_SCALED_US * __us) != F_CPU_SCALED_US * __us)\
__delay_cycles((uint32_t) ( F_CPU_SCALED_US * __us)+1);\
else __delay_cycles((uint32_t) ( F_CPU_SCALED_US * __us))
/** @} */
This diff is collapsed.
Click to expand it.
source/test/min2.c
+
3
−
65
View file @
1bdcd9fd
#include
"msp430fr5994.h"
#include
"msp430fr5994.h"
#include
"stdio.h"
#include
"stdio.h"
#include
"lib/radio_drv/hal_types.h"
#include
"lib/radio_drv/hal_types.h"
#include
"lib/hal_mcu/hal_mcu_fr5.h"
/******************************************************************************
/******************************************************************************
* LOCAL FUNCTIONS
* LOCAL FUNCTIONS
*/
*/
extern
void
msp_setup
(
void
);
unsigned
long
volatile
time_counter
;
unsigned
long
volatile
time_counter
;
...
@@ -29,42 +31,6 @@ unsigned long volatile time_counter;
...
@@ -29,42 +31,6 @@ unsigned long volatile time_counter;
*
*
*/
*/
#define DCO_RANGE_SEL DCORSEL
#define DCO_FREQ_SEL DCOFSEL_4
#define F_CPU_SCALE DIVM_0
#if DCO_RANGE_SEL==DCORSEL
#if DCO_FREQ_SEL>DCOFSEL_3
#define F_CPU_RANGE 5333000UL
#else
#define F_CPU_RANGE 5333000UL*1.5
#endif
#else
#define F_CPU_RANGE 2667000UL
#endif
#if DCO_FREQ_SEL==DCOFSEL_1
#define F_CPU F_CPU_RANGE*1.0
#elif DCO_FREQ_SEL==DCOFSEL_2
#define F_CPU F_CPU_RANGE*1.313
#elif DCO_FREQ_SEL==DCOFSEL_3
#define F_CPU F_CPU_RANGE*1.5
#elif DCO_FREQ_SEL==DCOFSEL_4
#define F_CPU F_CPU_RANGE*2.0
#elif DCO_FREQ_SEL==DCOFSEL_5
#define F_CPU F_CPU_RANGE*2.62
#elif DCO_FREQ_SEL==DCOFSEL_6
#define F_CPU F_CPU_RANGE*3.0
#else //DCO_FREQ_SEL==DCOFSEL_0
#define F_CPU 1000000UL
#endif
#define F_CPU_SCALED_US F_CPU/(1<<F_CPU_SCALE)/1000000.0
/* Number of CPU cycles per us */
#define _delay_us(__us) \
if((uint32_t) (F_CPU_SCALED_US * __us) != F_CPU_SCALED_US * __us)\
__delay_cycles((uint32_t) ( F_CPU_SCALED_US * __us)+1);\
else __delay_cycles((uint32_t) ( F_CPU_SCALED_US * __us))
enum
state_names
{
IDLE_RESET
,
WAIT
,
OPERATE
};
enum
state_names
{
IDLE_RESET
,
WAIT
,
OPERATE
};
void
main
(
void
)
void
main
(
void
)
{
{
...
@@ -76,39 +42,11 @@ void main (void)
...
@@ -76,39 +42,11 @@ void main (void)
/* Setup MSP specific functions, IO's, timers and WDT */
/* Setup MSP specific functions, IO's, timers and WDT */
//Comes from lib/hal_mcu/hal_mcu.c
//Comes from lib/hal_mcu/hal_mcu.c
//
msp_setup();
msp_setup
();
// Enable the interupts on port 2 to catch the user button (TRXEB)
// Enable the interupts on port 2 to catch the user button (TRXEB)
BUTTON_DIR
&=
~
BUTTON_PIN
;
// input direction
BUTTON_OUT
|=
BUTTON_PIN
;
// set high on port
BUTTON_PxIE
|=
BUTTON_PIN
;
// enable interupt
BUTTON_PxIES
|=
BUTTON_PIN
;
// Hi/lo edge
BUTTON_REN
|=
BUTTON_PIN
;
// Pull up resistor
BUTTON_PxIES
&=
~
BUTTON_PIN
;
// IFG cleared
// Removed XTAL configuration and DCO Fault detection as not on exp430_fr5994
// Unlock CS registers.
CSCTL0
=
CSKEY
;
// Set DCO to 24MHz.
CSCTL1
=
DCO_RANGE_SEL
+
DCO_FREQ_SEL
;
// ACLK = VLO, SMCLK = MCLK = DCO
CSCTL2
=
SELA_1
+
SELS_3
+
SELM_3
;
// ACLK/1, SMCLK/8, MCLK/1
CSCTL3
=
DIVA_0
+
DIVS_0
+
F_CPU_SCALE
;
// Power down unused clocks.
CSCTL4
=
HFXTOFF
+
VLOOFF
;
// Lock clock registers.
CSCTL0
=
0
;
// Setup Watch dog timer for 0.5 second tick using 16MHz DCO on MSP430FR5994
// WDT 0.5s @ 16mHz, SMCLK, interval timer
WDTCTL
=
WDTPW
+
WDTSSEL_0
+
WDTTMSEL
+
WDTIS_2
;
SFRIE1
|=
WDTIE
;
// Enable WDT interrupt
// Unlock the system.
PM5CTL0
&=
~
LOCKLPM5
;
P1DIR
|=
BIT0
|
BIT1
;
P1DIR
|=
BIT0
|
BIT1
;
__enable_interrupt
();
__enable_interrupt
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment