mcf51cn_mcg.nut 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. --
  2. -- Multipurpore Clock Generator
  3. --
  4. nutarch_m68k_coldfire_mcf51cn_mcg =
  5. {
  6. sources = { "m68k/coldfire/dev/mcf51cn/mcf51cn_mcg.c"},
  7. options =
  8. {
  9. {
  10. macro = "MCG_BUS_DIV",
  11. brief = "Bus Frequency Divider",
  12. type = "enumerated",
  13. description = "Selects the amount to divide down the clock source selected by 'clock mode' below."..
  14. "\n"..
  15. "\n!! WARNING, the resulting bus clock frequency should not exceed the maximum specified bus clock frequency of the device."..
  16. "\n"..
  17. "\nClock References:"..
  18. "\n F.int = 32 kHz" ..
  19. "\n F.ext = 32 kHz - 40 MHz"..
  20. "\n"..
  21. "\nSetup Limitations:"..
  22. "\n FEE, FBE Mode: F.ext / 'Ref. Clock Divider' must be in the range of 31.25 kHz to 39.0625 kHz"..
  23. "\n PEE, PBE Mode: F.ext / 'Ref. Clock Divider' must be in the range of 1 MHz to 2 MHz"..
  24. "\n"..
  25. "\nBus Clock Calculations:"..
  26. "\n BUSCLK = CPUCLK / 2"..
  27. "\n"..
  28. "\n FEI Mode: CPUCLK = (F.int * 'FLL Multiply Factor' ) / 'Bus Frequency Divider'"..
  29. "\n FEE Mode: CPUCLK = (F.ext / 'Ref. Clock Divider' * 'FLL Multiply Factor') / 'Bus Frequency Divider'"..
  30. "\n FBI Mode: CPUCLK = F.int / 'Bus Frequency Divider'"..
  31. "\n FBE Mode: CPUCLK = F.ext / 'Bus Frequency Divider'"..
  32. "\n PEE Mode: CPUCLK = [(F.ext / 'Ref. Clock Divider') * 'PLL Multiply Factor'] / 'Bus Frequency Divider'"..
  33. "\n PBE Mode: CPUCLK = F.ext / 'Bus Frequency Divider'"..
  34. "\n BLPI Mode: CPUCLK = F.int / 'Bus Frequency Divider'"..
  35. "\n BLPE Mode: CPUCLK = F.ext / 'Bus Frequency Divider'",
  36. choices = { "1", "2", "4", "8" },
  37. file = "include/cfg/clock.h"
  38. },
  39. {
  40. macro = "MCG_MODE_FEI",
  41. brief = "FLL Engaged Internal (FEI)",
  42. description = "In FLL engaged internal mode, the bus clock is derived from the FLL which is controlled by the internal reference clock.\n"..
  43. "The Background Debug Controller (BDC) clock is supplied from the FLL.",
  44. provides = { "MCG_FLL", "MCG_INT_REF"},
  45. flavor = "boolean",
  46. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  47. file = "include/cfg/clock.h"
  48. },
  49. {
  50. macro = "MCG_MODE_FEE",
  51. brief = "FLL Engaged External (FEE)",
  52. description = "In FLL engaged external mode, the bus clock is derived from the FLL which is controlled by the external reference clock.\n"..
  53. "The Background Debug Controller (BDC) clock is supplied from the FLL.",
  54. provides = { "MCG_FLL", "MCG_EXT_REF", "MCG_EXT_REF_CLK_MONITOR" },
  55. flavor = "boolean",
  56. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  57. file = "include/cfg/clock.h"
  58. },
  59. {
  60. macro = "MCG_MODE_FBI",
  61. brief = "FLL Bypassed Internal (FBI)",
  62. description = "In FLL bypassed internal mode, the bus clock is derived from the internal reference clock.\n"..
  63. "The FLL is enabled and controlled by the internal reference clock, but is bypassed.\n"..
  64. "The Background Debug Controller (BDC) clock is supplied from the FLL.",
  65. provides = { "MCG_FLL", "MCG_INT_REF" },
  66. flavor = "boolean",
  67. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  68. file = "include/cfg/clock.h"
  69. },
  70. {
  71. macro = "MCG_MODE_FBE",
  72. brief = "FLL Bypassed External (FBE)",
  73. description = "In FLL bypassed external mode, the bus clock is derived from the external reference clock.\n"..
  74. "The FLL is enabled and controlled by the external reference clock, but is bypassed.\n"..
  75. "The Background Debug Controller (BDC) clock is supplied from the FLL.",
  76. provides = { "MCG_FLL", "MCG_EXT_REF", "MCG_EXT_REF_CLK_MONITOR" },
  77. flavor = "boolean",
  78. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  79. file = "include/cfg/clock.h"
  80. },
  81. {
  82. macro = "MCG_MODE_PEE",
  83. brief = "PLL Engaged External (PEE)",
  84. description = "In PLL engaged mode, the bus clock is derived from the PLL which is controlled by the external reference clock.\n"..
  85. "The Background Debug Controller (BDC) clock is supplied from the FLL.",
  86. provides = { "MCG_PLL", "MCG_EXT_REF", "MCG_EXT_REF_CLK_MONITOR" },
  87. flavor = "boolean",
  88. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  89. file = "include/cfg/clock.h"
  90. },
  91. {
  92. macro = "MCG_MODE_PBE",
  93. brief = "PLL Bypassed External (PBE)",
  94. description = "In PLL bypassed mode, the bus clock is derived from external reference clock.\n"..
  95. "The PLL is enabled and controlled by the external reference clock, but is bypassed.\n"..
  96. "The Background Debug Controller (BDC) clock is supplied from the FLL.",
  97. provides = { "MCG_PLL", "MCG_EXT_REF", "MCG_EXT_REF_CLK_MONITOR" },
  98. flavor = "boolean",
  99. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  100. file = "include/cfg/clock.h"
  101. },
  102. {
  103. macro = "MCG_MODE_BLPI",
  104. brief = "Bypassed Low Power Internal (BLPI)",
  105. description = "In bypassed low power internal mode, the bus clock is derived from the internal reference clock\n"..
  106. "The FLL and PLL are disabled and bypassed.\n"..
  107. "The Background Debug Controller (BDC) clock is not available.",
  108. provides = { "MCG_INT_REF" },
  109. flavor = "boolean",
  110. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  111. file = "include/cfg/clock.h"
  112. },
  113. {
  114. macro = "MCG_MODE_BLPE",
  115. brief = "Bypassed Low Power External (BLPE)",
  116. description = "In bypassed low power external mode, the bus clock is derived from the external reference clock.\n"..
  117. "The FLL and PLL are disabled and bypassed.\n"..
  118. "The Background Debug Controller (BDC) clock is not available.",
  119. provides = { "MCG_EXT_REF", "MCG_EXT_REF_CLK_MONITOR" },
  120. flavor = "boolean",
  121. exclusivity = { "MCG_MODE_FEI", "MCG_MODE_FEE", "MCG_MODE_FBI", "MCG_MODE_FBE", "MCG_MODE_PEE", "MCG_MODE_PBE", "MCG_MODE_BLPI", "MCG_MODE_BLPE" },
  122. file = "include/cfg/clock.h"
  123. },
  124. },
  125. --
  126. -- Internal lock
  127. --
  128. {
  129. name = "nutarch_m68k_coldfire_mcf51cn_mcg_clock_int_ref",
  130. brief = "Internal Reference Clock",
  131. description = "Internal Reference Clock: 32kHz",
  132. options =
  133. {
  134. {
  135. macro = "MCG_INT_REF_CLKEN",
  136. brief = "Enable For Peripherals",
  137. description = "Enables the internal reference clock for use as MCGIRCLK.\n\n"..
  138. "MCGIRCLK may be used by several peripherals as a clock source instead of BUSCLK.",
  139. flavor = "boolean",
  140. file = "include/cfg/clock.h"
  141. },
  142. },
  143. },
  144. --
  145. -- External Reference Clock
  146. --
  147. {
  148. name = "nutarch_m68k_coldfire_mcf51cn_mcg_clock_ext_ref",
  149. brief = "External Reference Clock",
  150. description = "Internal Reference Clock: 32kHz - 40MHz",
  151. options =
  152. {
  153. {
  154. macro = "MCG_EXT_REF_HIGH_GAIN_OSC",
  155. brief = "High Gain Oscilator",
  156. description = "Use this mode for Crystal Oscilator\n"..
  157. "This option provides a higher amplitude output for the improved noise immunity\n"..
  158. "Supports following frequency ranges:\n"..
  159. " - 32 kHz to 100 kHz\n"..
  160. " - 1 MHz to 25 MHz",
  161. flavor = "boolean",
  162. provides = { "MCG_EXT_REF_HIGH_GAIN_OSC" },
  163. exclusivity = {"MCG_EXT_REF_HIGH_GAIN_OSC", "MCG_EXT_REF_LOW_PWR_OSC", "MCG_EXT_REF_EXT_CLOCK" },
  164. file = "include/cfg/clock.h"
  165. },
  166. {
  167. macro = "MCG_EXT_REF_LOW_PWR_OSC",
  168. brief = "Low Power Oscilator",
  169. description = "Use this mode for Crystal Oscilator\n"..
  170. "This option provides the lower power consumption.\n"..
  171. "Supports following frequency ranges:\n"..
  172. " - 32 kHz to 100 kHz\n"..
  173. " - 1 MHz to 8 MHz",
  174. flavor = "boolean",
  175. provides = { "MCG_EXT_REF_LOW_PWR_OSC" },
  176. exclusivity = {"MCG_EXT_REF_HIGH_GAIN_OSC", "MCG_EXT_REF_LOW_PWR_OSC", "MCG_EXT_REF_EXT_CLOCK" },
  177. file = "include/cfg/clock.h"
  178. },
  179. {
  180. macro = "MCG_EXT_REF_EXT_CLOCK",
  181. brief = "External Clock",
  182. description = "Use this mode for External Clock Source",
  183. flavor = "boolean",
  184. provides = { "MCG_EXT_REF_EXT_CLOCK" },
  185. exclusivity = {"MCG_EXT_REF_HIGH_GAIN_OSC", "MCG_EXT_REF_LOW_PWR_OSC", "MCG_EXT_REF_EXT_CLOCK" },
  186. file = "include/cfg/clock.h"
  187. },
  188. {
  189. macro = "MCG_EXT_REF_HIGH_FREQ_RANGE",
  190. brief = "High Frequency Range",
  191. description =
  192. function()
  193. if c_is_provided("MCG_EXT_REF_EXT_CLOCK") then
  194. return "Select for the high frequency external clock source (1 MHz to 40 MHz).\n"..
  195. "Deselect for the low frequency external clock source (32 kHz to 1 MHz)."
  196. end
  197. return "Select for the high frequency crystal oscillator (1 MHz to 25 MHz).\n"..
  198. "Deselect for the low frequency crystal oscillator (32 kHz to 100 kHz).\n\n"..
  199. "If you need different frequency, use external clock source instead of crystal.";
  200. end,
  201. flavor = "boolean",
  202. provides = { "MCG_EXT_REF_HIGH_FREQ_RANGE" },
  203. file = "include/cfg/clock.h"
  204. },
  205. {
  206. macro = "MCG_EXT_REF_FREQ",
  207. brief = "Reference Clock Frequency",
  208. description =
  209. function()
  210. local range
  211. local source
  212. if c_is_provided("MCG_EXT_REF_EXT_CLOCK") then
  213. if c_is_provided("MCG_EXT_REF_HIGH_FREQ_RANGE") then
  214. range = "1 MHz to 40 MHz"
  215. else
  216. range = "32 kHz to 1 MHz"
  217. end
  218. source = "external clock"
  219. else
  220. if c_is_provided("MCG_EXT_REF_HIGH_FREQ_RANGE") then
  221. if c_is_provided("MCG_EXT_REF_HIGH_GAIN_OSC") then
  222. range = "1 MHz to 25 MHz"
  223. else
  224. range = "1 MHz to 8 MHz"
  225. end
  226. else
  227. range = "32 kHz to 100 kHz"
  228. end
  229. source = "crystal"
  230. end
  231. return "Please enter frequency of used "..source..".\n"..
  232. "It MUST be in range "..range..".\n\n"..
  233. "If you need another frequency, change the 'High Frequency Range' option or use different clock source."
  234. end,
  235. file = "include/cfg/clock.h"
  236. },
  237. {
  238. macro = "MCG_EXT_REF_CLKEN",
  239. brief = "Enable for peripherals",
  240. provides = { "MCG_EXT_REF_CLK_MONITOR" },
  241. description = "Enables the external reference clock for use as MCGERCLK.\n\n"..
  242. "MCGERCLK may be used by several peripherals as a clock source instead of BUSCLK.",
  243. flavor = "boolean",
  244. file = "include/cfg/clock.h"
  245. },
  246. {
  247. macro = "MCG_EXT_REF_CLK_MONITOR",
  248. brief = "Clock Monitor",
  249. requires = { "MCG_EXT_REF_CLK_MONITOR" },
  250. description = "The clock monitor issues reset after a loss of external clock is detected.",
  251. flavor = "boolean",
  252. file = "include/cfg/clock.h"
  253. },
  254. },
  255. },
  256. --
  257. -- PLL Setup
  258. --
  259. {
  260. name = "nutarch_m68k_coldfire_mcf51cn_mcg_clock_pll",
  261. brief = "PLL Setup",
  262. description = "PLL is used in PEE and PBE clock modes.\n"..
  263. "Only external clock may be used as a refernce clock for PLL.\n",
  264. requires = { "MCG_PLL" },
  265. options =
  266. {
  267. {
  268. macro = "MCG_EXT_REF_DIVIDE_FACTOR",
  269. brief = "Ref. Clock Divider",
  270. requires = { "MCG_EXT_REF" },
  271. type = "enumerated",
  272. description = "Selects the amount to divide down the external reference clock.\n"..
  273. "The resulting frequency MUST be in the range 1 MHz to 2 MHz.",
  274. choices = { "1", "2", "4", "8", "16", "32", "64", "128" },
  275. file = "include/cfg/clock.h"
  276. },
  277. {
  278. macro = "MCG_PLL_MULTIPLY_FACTOR",
  279. brief = "Multiply Factor",
  280. type = "enumerated",
  281. description = "Selects the amount to multiply up the PLL reference clock.\n"..
  282. " 4 (4-8MHz)\n"..
  283. " 8 (8-16MHz)\n"..
  284. " 12 (12-24MHz)\n"..
  285. " 16 (16-32MHz)\n"..
  286. " 20 (20-40MHz)\n"..
  287. " 24 (24-48MHz)\n"..
  288. " 28 (28-56MHz) !!\n"..
  289. " 32 (32-64MHz) !!\n"..
  290. " 36 (36-72MHz) !!\n"..
  291. " 40 (40-80MHz) !!\n"..
  292. " 44 (44-88MHz) !!\n"..
  293. " 48 (48-96MHz) !!\n\n"..
  294. "!! WARNING, the resulting bus clock frequency should not exceed the maximum specified bus clock frequency of the device.",
  295. choices = { "4", "8", "12", "16", "20", "24", "28", "32", "36", "40", "44", "48" },
  296. file = "include/cfg/clock.h"
  297. },
  298. },
  299. },
  300. --
  301. -- FLL Setup
  302. --
  303. {
  304. name = "nutarch_m68k_coldfire_mcf51cn_mcg_clock_fll",
  305. brief = "FLL Setup",
  306. description = "FLL is used in FEI. FEE, FBI and FBE clock modes."..
  307. "Either Internal or external clock may be used as a refernce clock for FLL.\n",
  308. requires = { "MCG_FLL" },
  309. options =
  310. {
  311. {
  312. macro = "MCG_EXT_REF_DIVIDE_FACTOR",
  313. brief = "Ref. Clock Divider",
  314. requires = { "MCG_EXT_REF" },
  315. type = "enumerated",
  316. description = "It selects the amount to divide down the external reference clock.\n"..
  317. "The resulting frequency MUST be in the range 31.25 kHz to 39.0625 kHz.\n\n"..
  318. "When internal reference clock is selected, this option is ignored (Divider = 1).",
  319. choices = { "1", "2", "4", "8", "16", "32", "64", "128", "256", "512", "1024" },
  320. file = "include/cfg/clock.h"
  321. },
  322. {
  323. macro = "MCG_FLL_DCO_MODE",
  324. brief = "DCO Fined Tuned 32kHz",
  325. provides = { "MCG_FLL_DCO_MODE" },
  326. flavor = "boolean",
  327. description =
  328. function()
  329. local description = "DCO is fined tuned for maximum frequency with 32.768 kHz reference.\n"..
  330. "In this mode, diferent 'Multiply Factors' are offered below."
  331. if c_is_provided("MCG_EXT_REF") then
  332. description = description.."\n\nThis mode MUST NOT be used, if (External Reference Clock Frequency / External Clock Divide factor) is not equal to 32kHz."
  333. end
  334. return description
  335. end,
  336. file = "include/cfg/clock.h"
  337. },
  338. {
  339. macro = "MCG_FLL_MULTIPLY_FACTOR",
  340. brief = "Multiply Factor",
  341. type = "enumerated",
  342. description =
  343. function()
  344. if c_is_provided("MCG_INT_REF") then
  345. local description = "Selects the amount to multiply up the FLL reference clock.\n\n"
  346. if c_is_provided("MCG_FLL_DCO_MODE") then
  347. return description..
  348. " 608 (19,92MHz)\n"..
  349. " 1216 (39,85MHz)\n"..
  350. " 1536 (50,33MHz)\n"..
  351. " 1824 (59,77MHz) !!\n\n"..
  352. "!! WARNING, the resulting bus clock frequency should not exceed the maximum specified bus clock frequency of the device."
  353. else
  354. return description..
  355. " 512 (16MHz)\n"..
  356. " 1024 (32MHz)\n"..
  357. " 1536 (50,33MHz)\n"
  358. end
  359. end
  360. if c_is_provided("MCG_EXT_REF") then
  361. local description = "Selects the amount to multiply up the FLL reference clock.\n\n"
  362. if c_is_provided("MCG_FLL_DCO_MODE") then
  363. return description..
  364. " 608 (19,92MHz)\n"..
  365. " 1216 (39,85MHz)\n"..
  366. " 1536 (50,33MHz)\n"..
  367. " 1824 (59,77MHz) !!\n\n"..
  368. "!! WARNING, the resulting bus clock frequency should not exceed the maximum specified bus clock frequency of the device."
  369. else
  370. return description..
  371. " 512 (16-20 MHz)\n"..
  372. " 1024 (32-40MHz)\n"..
  373. " 1536 (48-60MHz) !!\n\n"..
  374. "!! WARNING, the resulting bus clock frequency should not exceed the maximum specified bus clock frequency of the device."
  375. end
  376. end
  377. end,
  378. choices =
  379. function()
  380. if c_is_provided("MCG_FLL_DCO_MODE") then
  381. return {"608", "1216", "1536", "1824" }
  382. else
  383. return {"512", "1024", "1536" }
  384. end
  385. end,
  386. file = "include/cfg/clock.h"
  387. },
  388. },
  389. },
  390. }