* @file system_XMC1100.c\r
* @brief Device specific initialization for the XMC1100-Series according \r
* to CMSIS\r
- * @version V1.2\r
- * @date 13 Dec 2012\r
+ * @version V1.4\r
+ * @date 01 Feb 2013\r
*\r
* @note\r
* Copyright (C) 2012-2013 Infineon Technologies AG. All rights reserved.\r
/*\r
* *************************** Change history ********************************\r
* V1.2, 13 Dec 2012, PKB : Created change history table\r
+ * V1.3, 20 Dec 2012, PKB : Fixed SystemCoreClock computation\r
+ * V1.3, 01 Feb 2013, PKB : SCU_CLOCK -> SCU_CLK\r
*/\r
\r
#include "system_XMC1100.h"\r
/*----------------------------------------------------------------------------\r
Clock Global defines\r
*----------------------------------------------------------------------------*/\r
-#define DCO_DCLK 64000000UL\r
-\r
+#define DCO_DCLK 64000000UL\r
+#define DCO_DCLK_MULTIPLIER 16384000UL\r
+#define DCO_DCLK_DIVIDER 9UL\r
+#define MCLK_MHZ 32000000UL\r
+#define KHZ_MULTIPLIER 1000UL\r
+#define FRACBITS 8UL\r
/*----------------------------------------------------------------------------\r
Clock Variable definitions\r
*----------------------------------------------------------------------------*/\r
-/*!< System Clock Frequency (Core Clock)*/\r
+/*!< System Clock Frequency (Core Clock) (MCLK on TIMM1) */\r
uint32_t SystemCoreClock;\r
\r
+/*----------------------------------------------------------------------------\r
+ Fixed point math definitions\r
+ *----------------------------------------------------------------------------*/\r
+typedef int32_t Q_24_8;\r
+typedef int32_t Q_15_0;\r
\r
/**\r
* @brief Setup the microcontroller system.\r
*/\r
void SystemInit(void)\r
{ \r
+\r
/*\r
* Clock tree setup by CMSIS routines is allowed only in the absence of DAVE\r
* Clock app.\r
*/\r
void SystemCoreClockUpdate(void)\r
{\r
- uint32_t IDIV, CLKCR;\r
+ uint32_t IDIV, FDIV, CLKCR, Clock;\r
\r
- CLKCR = SCU_CLOCK -> CLKCR;\r
- \r
- IDIV = (CLKCR & SCU_CLOCK_CLKCR_IDIV_Msk) >> SCU_CLOCK_CLKCR_IDIV_Pos;\r
+ CLKCR = SCU_CLK -> CLKCR;\r
+ IDIV = (CLKCR & SCU_CLK_CLKCR_IDIV_Msk) >> SCU_CLK_CLKCR_IDIV_Pos;\r
+ FDIV = (CLKCR & SCU_CLK_CLKCR_FDIV_Msk) >> SCU_CLK_CLKCR_FDIV_Pos;\r
\r
if(IDIV)\r
{\r
- SystemCoreClock = DCO_DCLK / (2 * IDIV );\r
+ /* Divider is enabled and used */\r
+ if(0 == FDIV)\r
+ {\r
+ /* No fractional divider, so MCLK = DCO_Clk / (2 * IDIV) */\r
+ Clock = MCLK_MHZ / IDIV;\r
+ }\r
+ else\r
+ {\r
+ /* Both integer and fractional divider must be considered */\r
+ /* 1. IDIV + FDIV/256 */\r
+ Q_24_8 FDiv_IDiv_Sum = (IDIV << FRACBITS) + FDIV; \r
+\r
+ /* 2. Fixed point division Q24.8 / Q9.8 = Q15.0 */\r
+ Q_15_0 ClockVal = (DCO_DCLK_MULTIPLIER << FRACBITS)/ FDiv_IDiv_Sum;\r
+ Clock = ((uint32_t)ClockVal) * KHZ_MULTIPLIER;\r
+ Clock = Clock >> DCO_DCLK_DIVIDER;\r
+ }\r
}\r
else\r
{\r
- /* Divider bypassed */\r
- SystemCoreClock = DCO_DCLK;\r
+ /* Divider bypassed. Simply divide DCO_DCLK by 2 */\r
+ Clock = MCLK_MHZ;\r
}\r
+\r
+ /* Finally with the math class over, update SystemCoreClock */\r
+ SystemCoreClock = Clock; \r
}\r
\r
* @file system_XMC1200.c\r
* @brief Device specific initialization for the XMC1200-Series according \r
* to CMSIS\r
- * @version V1.2\r
- * @date 13 Dec 2012\r
+ * @version V1.4\r
+ * @date 01 Feb 2013\r
*\r
* @note\r
* Copyright (C) 2012-2013 Infineon Technologies AG. All rights reserved.\r
/*\r
* *************************** Change history ********************************\r
* V1.2, 13 Dec 2012, PKB : Created change history table\r
+ * V1.3, 20 Dec 2012, PKB : Fixed SystemCoreClock computation\r
+ * V1.4, 01 Feb 2013, PKB : SCU_CLOCK -> SCU_CLK\r
*/\r
\r
-#include "System_XMC1200.h"\r
+#include "system_XMC1200.h"\r
#include <XMC1200.h>\r
\r
/*---------------------------------------------------------------------------\r
/*----------------------------------------------------------------------------\r
Clock Global defines\r
*----------------------------------------------------------------------------*/\r
-#define DCO_DCLK 64000000UL\r
-\r
+#define DCO_DCLK 64000000UL\r
+#define DCO_DCLK_MULTIPLIER 16384000UL\r
+#define DCO_DCLK_DIVIDER 9UL\r
+#define MCLK_MHZ 32000000UL\r
+#define KHZ_MULTIPLIER 1000UL\r
+#define FRACBITS 8UL\r
/*----------------------------------------------------------------------------\r
Clock Variable definitions\r
*----------------------------------------------------------------------------*/\r
-/*!< System Clock Frequency (Core Clock)*/\r
+/*!< System Clock Frequency (Core Clock) (MCLK on TIMM1) */\r
uint32_t SystemCoreClock;\r
\r
+/*----------------------------------------------------------------------------\r
+ Fixed point math definitions\r
+ *----------------------------------------------------------------------------*/\r
+typedef int32_t Q_24_8;\r
+typedef int32_t Q_15_0;\r
\r
/**\r
* @brief Setup the microcontroller system.\r
*/\r
void SystemInit(void)\r
{ \r
+\r
/*\r
* Clock tree setup by CMSIS routines is allowed only in the absence of DAVE\r
* Clock app.\r
*/\r
void SystemCoreClockUpdate(void)\r
{\r
- uint32_t IDIV, CLKCR;\r
+ uint32_t IDIV, FDIV, CLKCR, Clock;\r
\r
- CLKCR = SCU_CLOCK -> CLKCR;\r
- \r
- IDIV = (CLKCR & SCU_CLOCK_CLKCR_IDIV_Msk) >> SCU_CLOCK_CLKCR_IDIV_Pos;\r
+ CLKCR = SCU_CLK -> CLKCR;\r
+ IDIV = (CLKCR & SCU_CLK_CLKCR_IDIV_Msk) >> SCU_CLK_CLKCR_IDIV_Pos;\r
+ FDIV = (CLKCR & SCU_CLK_CLKCR_FDIV_Msk) >> SCU_CLK_CLKCR_FDIV_Pos;\r
\r
if(IDIV)\r
{\r
- SystemCoreClock = DCO_DCLK / (2 * IDIV );\r
+ /* Divider is enabled and used */\r
+ if(0 == FDIV)\r
+ {\r
+ /* No fractional divider, so MCLK = DCO_Clk / (2 * IDIV) */\r
+ Clock = MCLK_MHZ / IDIV;\r
+ }\r
+ else\r
+ {\r
+ /* Both integer and fractional divider must be considered */\r
+ /* 1. IDIV + FDIV/256 */\r
+ Q_24_8 FDiv_IDiv_Sum = (IDIV << FRACBITS) + FDIV; \r
+\r
+ /* 2. Fixed point division Q24.8 / Q9.8 = Q15.0 */\r
+ Q_15_0 ClockVal = (DCO_DCLK_MULTIPLIER << FRACBITS)/ FDiv_IDiv_Sum;\r
+ Clock = ((uint32_t)ClockVal) * KHZ_MULTIPLIER;\r
+ Clock = Clock >> DCO_DCLK_DIVIDER;\r
+ }\r
}\r
else\r
{\r
- /* Divider bypassed */\r
- SystemCoreClock = DCO_DCLK;\r
+ /* Divider bypassed. Simply divide DCO_DCLK by 2 */\r
+ Clock = MCLK_MHZ;\r
}\r
+\r
+ /* Finally with the math class over, update SystemCoreClock */\r
+ SystemCoreClock = Clock; \r
}\r
\r
* @file system_XMC1300.c\r
* @brief Device specific initialization for the XMC1300-Series according \r
* to CMSIS\r
- * @version V1.2\r
- * @date 13 Dec 2012\r
+ * @version V1.4\r
+ * @date 01 Feb 2013\r
*\r
* @note\r
* Copyright (C) 2012-2013 Infineon Technologies AG. All rights reserved.\r
*\r
******************************************************************************/\r
/*\r
- * ************************** Change history *********************************\r
- * V1.2, 13 Dec 2012, PKB, Created this table, Changed System_ to system_\r
+ * *************************** Change history ********************************\r
+ * V1.2, 13 Dec 2012, PKB : Created change history table\r
+ * V1.3, 20 Dec 2012, PKB : Fixed SystemCoreClock computation\r
+ * V1.4, 02 Feb 2013, PKB : SCU_CLOCK -> SCU_CLK\r
*/\r
\r
#include "system_XMC1300.h"\r
/*----------------------------------------------------------------------------\r
Clock Global defines\r
*----------------------------------------------------------------------------*/\r
-#define DCO_DCLK 64000000UL\r
-\r
+#define DCO_DCLK 64000000UL\r
+#define DCO_DCLK_MULTIPLIER 16384000UL\r
+#define DCO_DCLK_DIVIDER 9UL\r
+#define MCLK_MHZ 32000000UL\r
+#define KHZ_MULTIPLIER 1000UL\r
+#define FRACBITS 8UL\r
/*----------------------------------------------------------------------------\r
Clock Variable definitions\r
*----------------------------------------------------------------------------*/\r
-/*!< System Clock Frequency (Core Clock)*/\r
+/*!< System Clock Frequency (Core Clock) (MCLK on TIMM1) */\r
uint32_t SystemCoreClock;\r
\r
+/*----------------------------------------------------------------------------\r
+ Fixed point math definitions\r
+ *----------------------------------------------------------------------------*/\r
+typedef int32_t Q_24_8;\r
+typedef int32_t Q_15_0;\r
\r
/**\r
* @brief Setup the microcontroller system.\r
*/\r
void SystemInit(void)\r
{ \r
+\r
/*\r
* Clock tree setup by CMSIS routines is allowed only in the absence of DAVE\r
* Clock app.\r
*/\r
void SystemCoreClockUpdate(void)\r
{\r
- uint32_t IDIV, CLKCR;\r
+ uint32_t IDIV, FDIV, CLKCR, Clock;\r
\r
- CLKCR = SCU_CLOCK -> CLKCR;\r
- \r
- IDIV = (CLKCR & SCU_CLOCK_CLKCR_IDIV_Msk) >> SCU_CLOCK_CLKCR_IDIV_Pos;\r
+ CLKCR = SCU_CLK -> CLKCR;\r
+ IDIV = (CLKCR & SCU_CLK_CLKCR_IDIV_Msk) >> SCU_CLK_CLKCR_IDIV_Pos;\r
+ FDIV = (CLKCR & SCU_CLK_CLKCR_FDIV_Msk) >> SCU_CLK_CLKCR_FDIV_Pos;\r
\r
if(IDIV)\r
{\r
- SystemCoreClock = DCO_DCLK / (2 * IDIV );\r
+ /* Divider is enabled and used */\r
+ if(0 == FDIV)\r
+ {\r
+ /* No fractional divider, so MCLK = DCO_Clk / (2 * IDIV) */\r
+ Clock = MCLK_MHZ / IDIV;\r
+ }\r
+ else\r
+ {\r
+ /* Both integer and fractional divider must be considered */\r
+ /* 1. IDIV + FDIV/256 */\r
+ Q_24_8 FDiv_IDiv_Sum = (IDIV << FRACBITS) + FDIV; \r
+\r
+ /* 2. Fixed point division Q24.8 / Q9.8 = Q15.0 */\r
+ Q_15_0 ClockVal = (DCO_DCLK_MULTIPLIER << FRACBITS)/ FDiv_IDiv_Sum;\r
+ Clock = ((uint32_t)ClockVal) * KHZ_MULTIPLIER;\r
+ Clock = Clock >> DCO_DCLK_DIVIDER;\r
+ }\r
}\r
else\r
{\r
- /* Divider bypassed */\r
- SystemCoreClock = DCO_DCLK;\r
+ /* Divider bypassed. Simply divide DCO_DCLK by 2 */\r
+ Clock = MCLK_MHZ;\r
}\r
+\r
+ /* Finally with the math class over, update SystemCoreClock */\r
+ SystemCoreClock = Clock; \r
}\r
\r
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
- <IsCurrentTarget>1</IsCurrentTarget>
+ <IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>255</CpuCode>
<Books>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
- <Name>/</Name>
+ <Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
- <Name>/</Name>
+ <Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
- <IsCurrentTarget>0</IsCurrentTarget>
+ <IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>255</CpuCode>
<Books>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
- <Name></Name>
+ <Name>/</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>0</TopLine>
- <CurrentLine>0</CurrentLine>
+ <TopLine>1</TopLine>
+ <CurrentLine>1</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\Keil_Specific\system_XMC1300.c</PathWithFileName>
<FilenameWithoutPath>system_XMC1300.c</FilenameWithoutPath>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>26</ColumnNumber>
+ <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>0</TopLine>
- <CurrentLine>0</CurrentLine>
+ <TopLine>1028</TopLine>
+ <CurrentLine>1036</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Source\queue.c</PathWithFileName>
<FilenameWithoutPath>queue.c</FilenameWithoutPath>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>2152</TopLine>
- <CurrentLine>2153</CurrentLine>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Source\tasks.c</PathWithFileName>
<FilenameWithoutPath>tasks.c</FilenameWithoutPath>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>0</TopLine>
- <CurrentLine>0</CurrentLine>
+ <TopLine>253</TopLine>
+ <CurrentLine>261</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Source\portable\RVDS\ARM_CM0\port.c</PathWithFileName>
<FilenameWithoutPath>port.c</FilenameWithoutPath>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>0</ColumnNumber>
+ <ColumnNumber>45</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>57</TopLine>
- <CurrentLine>122</CurrentLine>
+ <TopLine>63</TopLine>
+ <CurrentLine>96</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath>
<Focus>0</Focus>
<ColumnNumber>15</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>38</TopLine>
- <CurrentLine>74</CurrentLine>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\ParTest_XMC1100.c</PathWithFileName>
<FilenameWithoutPath>ParTest_XMC1100.c</FilenameWithoutPath>
<Focus>0</Focus>
<ColumnNumber>15</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>44</TopLine>
- <CurrentLine>74</CurrentLine>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\ParTest_XMC1300.c</PathWithFileName>
<FilenameWithoutPath>ParTest_XMC1300.c</FilenameWithoutPath>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>0</TopLine>
- <CurrentLine>0</CurrentLine>
+ <TopLine>411</TopLine>
+ <CurrentLine>419</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\Common\Minimal\dynamic.c</PathWithFileName>
<FilenameWithoutPath>dynamic.c</FilenameWithoutPath>
\r
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
or 0 to run the more comprehensive test and demo application. */\r
-#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0\r
+#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1\r
\r
\r
/*-----------------------------------------------------------*/\r
<Windows>\r
\r
\r
- <Wnd2>\r
+ <Wnd0>\r
<Tabs>\r
<Tab>\r
<Identity>TabID-23707-15152</Identity>\r
</Tab>\r
</Tabs>\r
\r
- <SelectedTab>0</SelectedTab></Wnd2><Wnd3>\r
+ <SelectedTab>0</SelectedTab></Wnd0><Wnd1>\r
<Tabs>\r
<Tab>\r
<Identity>TabID-19002-15240</Identity>\r
</Tab>\r
<Tab><Identity>TabID-13685-21727</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs>\r
\r
- <SelectedTab>0</SelectedTab></Wnd3></Windows>\r
+ <SelectedTab>0</SelectedTab></Wnd1></Windows>\r
<Editor>\r
\r
\r
\r
\r
\r
- <Top><Row0><Sizes><Toolbar-01348f68><key>iaridepm.enu1</key></Toolbar-01348f68></Sizes></Row0></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>740</Bottom><Right>435</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>260119</sizeVertCX><sizeVertCY>755601</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
+ <Top><Row0><Sizes><Toolbar-01348f68><key>iaridepm.enu1</key></Toolbar-01348f68></Sizes></Row0></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>740</Bottom><Right>435</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>260119</sizeVertCX><sizeVertCY>755601</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd1></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
</Desktop>\r
</Workspace>\r
\r