Skip to content

Commit

Permalink
Cores prepared for 20 MHz MCU clock
Browse files Browse the repository at this point in the history
  • Loading branch information
dberenguer committed Jun 7, 2017
1 parent 7fb6b10 commit d6ea672
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 17 additions & 2 deletions cores/panstamp/cc430core.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* MCLK config macros with fixed VCORE
*/
#define _SET_MCLK_12MHZ() _SET_VCORE_12MHZ(2)
#define _SET_MCLK_20MHZ() setVcoreMCLK(3, DCORSEL_4, 0x262)
#define _SET_MCLK_20MHZ() setVcoreMCLK(3, DCORSEL_7, 0x262)

/**
* Class: CC430CORE
Expand Down Expand Up @@ -88,6 +88,17 @@ class CC430CORE
*/
void init(uint8_t vCore=2, uint16_t dcorsel=DCORSEL_5, uint16_t flln=0x16E);

/**
* init20mhz
*
* Initialize CC430 core at VCORE = 2 and SCLK = 20 MHz
*
*/
inline void init20mhz(void)
{
init(3, DCORSEL_7, 0x262);
}

/**
* setLowPowerMode
*
Expand All @@ -112,6 +123,9 @@ class CC430CORE
*/
inline void begin(void)
{
#if (SYSTEM_CLK_FREQ == CLK_FREQ_20MHZ)
init20mhz();
#else
// Initialize MCU core with minimum COREV
init(0);
// Read Vcc
Expand All @@ -121,6 +135,7 @@ class CC430CORE
init(2);
else if (vcc > 2000)
init(1);
#endif
}

/**
Expand Down Expand Up @@ -184,7 +199,7 @@ class CC430CORE
*
* Read internal temperature from CC430 MCU
*
* @return voltage in 0.1 ºC
* @return temperature in 0.1 ºC
*/
inline int getTemp(void)
{
Expand Down
7 changes: 6 additions & 1 deletion cores/panstamp/wiring.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
/**
* System clock
*/
#define SYSTEM_CLK_FREQ 12000000L
#define CLK_FREQ_12MHZ 12000000L
#define CLK_FREQ_20MHZ 20000000L

#define SYSTEM_CLK_FREQ CLK_FREQ_12MHZ
//#define SYSTEM_CLK_FREQ CLK_FREQ_20MHZ

#ifndef F_CPU
#define F_CPU SYSTEM_CLK_FREQ
#endif
Expand Down

0 comments on commit d6ea672

Please sign in to comment.