37 #ifndef MCAL_P33SMPS_OSCILLATOR_H
38 #define MCAL_P33SMPS_OSCILLATOR_H
44 #include "p33smps_devices.h"
68 typedef enum CPU_SPEED_DEFAULTS_e
70 CPU_SPEED_20_MIPS = 20,
71 CPU_SPEED_30_MIPS = 30,
72 CPU_SPEED_40_MIPS = 40,
73 CPU_SPEED_50_MIPS = 50,
74 CPU_SPEED_60_MIPS = 60,
75 CPU_SPEED_70_MIPS = 70,
76 CPU_SPEED_80_MIPS = 80,
77 CPU_SPEED_90_MIPS = 90,
78 CPU_SPEED_100_MIPS = 100
79 } CPU_SPEED_DEFAULTS_t;
82 typedef enum AUX_PLL_DEFAULTS_e
131 volatile uint32_t
fp;
142 #if defined (__P33SMPS_CH__)
144 #define FRCTUN_MIN -32 // minimum tuning value
145 #define FRCTUN_MAX 31 // maximum tuning value
146 #define OSC_FRC_FREQ 8000000 // Frequency of the internal oscillator in [Hz]
147 #define OSC_FRC_TUN 0 // <OSCTUN> FRC Oscillator Tuning Rregister default value
148 #define OSC_TUN_STEP_PERCENTAGE 0.00047 // Oscillator frequency step size of <OSCTUN>
150 #elif defined (__P33SMPS_CK__)
152 #define FRCTUN_MIN -32 // minimum tuning value
153 #define FRCTUN_MAX 31 // maximum tuning value
154 #define OSC_FRC_FREQ 8000000 // Frequency of the internal oscillator in [Hz]
155 #define OSC_FRC_TUN 0 // <OSCTUN> FRC Oscillator Tuning Rregister value
156 #define OSC_TUN_STEP_PERCENTAGE 0.00047 // Oscillator frequency step size of <OSCTUN>
159 #pragma message "error: === selected device family not supported by oscillator mcal driver library ==="
162 #define OSC_TUN_STEP_FREQUENCY (volatile int32_t)(OSC_FRC_FREQ * OSC_TUN_STEP_PERCENTAGE)
172 #define REG_OSCCON_VALID_DATA_WRITE_MASK 0x0789
173 #define REG_OSCCON_VALID_DATA_READ_MASK 0x77A9
175 #define REG_OSCCON_OSWEN_REQUEST_SWITCH 0b0000000000001000
176 #define REG_OSCCON_OSWEN_SWITCH_COMPLETE 0b0000000000000000
179 OSCCON_OSWEN_REQUEST_SWITCH = 0b1,
180 OSCCON_OSWEN_SWITCH_COMPLETE = 0b0
183 #define REG_OSCCON_CF_CLKSTAT_FAIL 0b0000000000001000
184 #define REG_OSCCON_CF_CLKSTAT_OK 0b0000000000000000
187 OSCCON_CF_CLKSTAT_FAIL = 0b1,
188 OSCCON_CF_CLKSTAT_OK = 0b0
191 #define REG_OSCCON_LOCK_PLL_LOCKED 0b0000000000100000
192 #define REG_OSCCON_LOCK_PLL_UNLOCKED 0b0000000000000000
195 OSCCON_LOCK_PLL_LOCKED = 0b1,
196 OSCCON_LOCK_PLL_UNLOCKED = 0b0
199 #define REG_OSCCON_CLKLOCK_LOCKED 0b0000000010000000
200 #define REG_OSCCON_CLKLOCK_UNLOCKED 0b0000000000000000
203 OSCCON_CLKLOCK_LOCKED = 0b1,
204 OSCCON_CLKLOCK_UNLOCKED = 0b0
207 #define REG_OSCCON_NOSC_FRCDIVN 0b0000011100000000
208 #define REG_OSCCON_NOSC_BFRC 0b0000011000000000
209 #define REG_OSCCON_NOSC_LPRC 0b0000010100000000
210 #define REG_OSCCON_NOSC_PRIPLL 0b0000001100000000
211 #define REG_OSCCON_NOSC_PRI 0b0000001000000000
212 #define REG_OSCCON_NOSC_FRCPLL 0b0000000100000000
213 #define REG_OSCCON_NOSC_FRC 0b0000000000000000
215 #define REG_OSCCON_COSC_FRCDIVN 0b0111000000000000
216 #define REG_OSCCON_COSC_BFRC 0b0110000000000000
217 #define REG_OSCCON_COSC_LPRC 0b0101000000000000
218 #define REG_OSCCON_COSC_PRIPLL 0b0011000000000000
219 #define REG_OSCCON_COSC_PRI 0b0010000000000000
220 #define REG_OSCCON_COSC_FRCPLL 0b0001000000000000
221 #define REG_OSCCON_COSC_FRC 0b0000000000000000
225 OSCCON_xOSC_FRC = 0b000,
226 OSCCON_xOSC_FRCPLL = 0b001,
227 OSCCON_xOSC_PRI = 0b010,
228 OSCCON_xOSC_PRIPLL = 0b011,
229 OSCCON_xOSC_LPRC = 0b101,
230 OSCCON_xOSC_BFRC = 0b110,
231 OSCCON_xOSC_FRCDIVN = 0b111
232 } OSCCON_xOSC_TYPE_e ;
235 volatile OSCCON_OSWEN_e OSWEN : 1;
236 volatile unsigned : 2;
237 volatile OSCCON_CF_e CF : 1;
238 volatile unsigned : 1;
239 volatile OSCCON_LOCK_e LOCK : 1;
240 volatile unsigned : 1;
241 volatile OSCCON_CLKLOCK_e CLKLOCK : 1;
242 volatile OSCCON_xOSC_TYPE_e NOSC : 3;
243 volatile unsigned : 1;
244 volatile OSCCON_xOSC_TYPE_e COSC : 3;
246 } __attribute__((packed)) OSCCON_t;
257 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
259 #define REG_CLKDIV_VALID_DATA_WRITE_MASK 0xFF0F
260 #define REG_CLKDIV_VALID_DATA_READ_MASK 0xFF0F
262 #define REG_CLKDIV_PLLPRE_DIV_MASK 0b0000000000001111
263 #define REG_CLKDIV_PLLPRE_DIVIDER_N1(x) {(x & REG_CLKDIV_PLLPRE_DIV_MASK)}
266 CLKDIV_PLLDIV_N1_1 = 0b000001,
267 CLKDIV_PLLDIV_N1_2 = 0b000010,
268 CLKDIV_PLLDIV_N1_3 = 0b000011,
269 CLKDIV_PLLDIV_N1_4 = 0b000100,
270 CLKDIV_PLLDIV_N1_5 = 0b000101,
271 CLKDIV_PLLDIV_N1_6 = 0b000110,
272 CLKDIV_PLLDIV_N1_7 = 0b000111,
273 CLKDIV_PLLDIV_N1_8 = 0b001000
277 #pragma message "error: === selected device family is not supported by oscillator mcal library ==="
280 #define REG_CLKDIV_DOZE_DIV_1 0b0000000000000000
281 #define REG_CLKDIV_DOZE_DIV_2 0b0001000000000000
282 #define REG_CLKDIV_DOZE_DIV_4 0b0010000000000000
283 #define REG_CLKDIV_DOZE_DIV_8 0b0011000000000000
284 #define REG_CLKDIV_DOZE_DIV_16 0b0100000000000000
285 #define REG_CLKDIV_DOZE_DIV_32 0b0101000000000000
286 #define REG_CLKDIV_DOZE_DIV_64 0b0110000000000000
287 #define REG_CLKDIV_DOZE_DIV_128 0b0111000000000000
290 CLKDIV_DOZE_DIV_1 = 0b000,
291 CLKDIV_DOZE_DIV_2 = 0b001,
292 CLKDIV_DOZE_DIV_4 = 0b010,
293 CLKDIV_DOZE_DIV_8 = 0b011,
294 CLKDIV_DOZE_DIV_16 = 0b100,
295 CLKDIV_DOZE_DIV_32 = 0b101,
296 CLKDIV_DOZE_DIV_64 = 0b110,
297 CLKDIV_DOZE_DIV_128 = 0b111
300 #define REG_CLKDIV_DOZEN_ENABLED 0b0000100000000000
301 #define REG_CLKDIV_DOZEN_DISABLED 0b0000000000000000
304 CLKDIV_DOZEN_ENABLED = 0b1,
305 CLKDIV_DOZEN_DISABLED = 0b0
308 #define REG_CLKDIV_FRCDIVN_256 0b0000011100000000
309 #define REG_CLKDIV_FRCDIVN_64 0b0000011000000000
310 #define REG_CLKDIV_FRCDIVN_32 0b0000010100000000
311 #define REG_CLKDIV_FRCDIVN_16 0b0000010000000000
312 #define REG_CLKDIV_FRCDIVN_8 0b0000001100000000
313 #define REG_CLKDIV_FRCDIVN_4 0b0000001000000000
314 #define REG_CLKDIV_FRCDIVN_2 0b0000000100000000
315 #define REG_CLKDIV_FRCDIVN_1 0b0000000000000000
317 typedef enum CLKDIV_FRCDIVN_e {
318 CLKDIV_FRCDIVN_1 = 0b000,
319 CLKDIV_FRCDIVN_2 = 0b001,
320 CLKDIV_FRCDIVN_4 = 0b010,
321 CLKDIV_FRCDIVN_8 = 0b011,
322 CLKDIV_FRCDIVN_16 = 0b100,
323 CLKDIV_FRCDIVN_32 = 0b101,
324 CLKDIV_FRCDIVN_64 = 0b110,
325 CLKDIV_FRCDIVN_256 = 0b111
328 #define REG_CLKDIV_ROI_ENABLED 0b1000000000000000
329 #define REG_CLKDIV_ROI_DISABLED 0b0000000000000000
332 CLKDIV_ROI_ENABLED = 0b1,
333 CLKDIV_ROI_DISABLED = 0b0
337 volatile CLKDIV_PLLPRE_e PLLPRE : 6;
338 volatile unsigned : 2;
339 volatile enum CLKDIV_FRCDIVN_e FRCDIV : 3;
340 volatile CLKDIV_DOZEN_e DOZEN : 1;
341 volatile CLKDIV_DOZE_e DOZE : 3;
342 volatile CLKDIV_ROI_e ROI : 1;
343 } __attribute__((packed)) CLKDIV_t;
355 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
357 #define REG_PLLFBD_VALID_DATA_WRITE_MASK 0x00FF
358 #define REG_PLLFBD_VALID_DATA_READ_MASK 0x00FF
360 #define REG_PLLFBD_PLLFBDIV_M_MASK 0b0000000011111111
361 #define REG_PLLFBD_MULTIPLIER_M(x) {(x & REG_PLLFBD_PLLFBDIV_M_MASK)}
364 PLLFBD_PLLFBDIV_M_16 = 0b00010000,
365 PLLFBD_PLLFBDIV_M_17 = 0b00010001,
366 PLLFBD_PLLFBDIV_M_18 = 0b00010010,
367 PLLFBD_PLLFBDIV_M_19 = 0b00010011,
368 PLLFBD_PLLFBDIV_M_20 = 0b00010100,
369 PLLFBD_PLLFBDIV_M_21 = 0b00010101,
370 PLLFBD_PLLFBDIV_M_22 = 0b00010110,
371 PLLFBD_PLLFBDIV_M_23 = 0b00010111,
372 PLLFBD_PLLFBDIV_M_24 = 0b00011000,
373 PLLFBD_PLLFBDIV_M_25 = 0b00011001,
374 PLLFBD_PLLFBDIV_M_26 = 0b00011010,
375 PLLFBD_PLLFBDIV_M_27 = 0b00011011,
376 PLLFBD_PLLFBDIV_M_28 = 0b00011100,
377 PLLFBD_PLLFBDIV_M_29 = 0b00011101,
378 PLLFBD_PLLFBDIV_M_30 = 0b00011110,
379 PLLFBD_PLLFBDIV_M_31 = 0b00011111,
380 PLLFBD_PLLFBDIV_M_32 = 0b00100000,
381 PLLFBD_PLLFBDIV_M_33 = 0b00100001,
382 PLLFBD_PLLFBDIV_M_34 = 0b00100010,
383 PLLFBD_PLLFBDIV_M_35 = 0b00100011,
384 PLLFBD_PLLFBDIV_M_36 = 0b00100100,
385 PLLFBD_PLLFBDIV_M_37 = 0b00100101,
386 PLLFBD_PLLFBDIV_M_38 = 0b00100110,
387 PLLFBD_PLLFBDIV_M_39 = 0b00100111,
388 PLLFBD_PLLFBDIV_M_40 = 0b00101000,
389 PLLFBD_PLLFBDIV_M_41 = 0b00101001,
390 PLLFBD_PLLFBDIV_M_42 = 0b00101010,
391 PLLFBD_PLLFBDIV_M_43 = 0b00101011,
392 PLLFBD_PLLFBDIV_M_44 = 0b00101100,
393 PLLFBD_PLLFBDIV_M_45 = 0b00101101,
394 PLLFBD_PLLFBDIV_M_46 = 0b00101110,
395 PLLFBD_PLLFBDIV_M_47 = 0b00101111,
396 PLLFBD_PLLFBDIV_M_48 = 0b00110000,
397 PLLFBD_PLLFBDIV_M_49 = 0b00110001,
398 PLLFBD_PLLFBDIV_M_50 = 0b00110010,
399 PLLFBD_PLLFBDIV_M_51 = 0b00110011,
400 PLLFBD_PLLFBDIV_M_52 = 0b00110100,
401 PLLFBD_PLLFBDIV_M_53 = 0b00110101,
402 PLLFBD_PLLFBDIV_M_54 = 0b00110110,
403 PLLFBD_PLLFBDIV_M_55 = 0b00110111,
404 PLLFBD_PLLFBDIV_M_56 = 0b00111000,
405 PLLFBD_PLLFBDIV_M_57 = 0b00111001,
406 PLLFBD_PLLFBDIV_M_58 = 0b00111010,
407 PLLFBD_PLLFBDIV_M_59 = 0b00111011,
408 PLLFBD_PLLFBDIV_M_60 = 0b00111100,
409 PLLFBD_PLLFBDIV_M_61 = 0b00111101,
410 PLLFBD_PLLFBDIV_M_62 = 0b00111110,
411 PLLFBD_PLLFBDIV_M_63 = 0b00111111,
412 PLLFBD_PLLFBDIV_M_64 = 0b01000000,
413 PLLFBD_PLLFBDIV_M_65 = 0b01000001,
414 PLLFBD_PLLFBDIV_M_66 = 0b01000010,
415 PLLFBD_PLLFBDIV_M_67 = 0b01000011,
416 PLLFBD_PLLFBDIV_M_68 = 0b01000100,
417 PLLFBD_PLLFBDIV_M_69 = 0b01000101,
418 PLLFBD_PLLFBDIV_M_70 = 0b01000110,
419 PLLFBD_PLLFBDIV_M_71 = 0b01000111,
420 PLLFBD_PLLFBDIV_M_72 = 0b01001000,
421 PLLFBD_PLLFBDIV_M_73 = 0b01001001,
422 PLLFBD_PLLFBDIV_M_74 = 0b01001010,
423 PLLFBD_PLLFBDIV_M_75 = 0b01001011,
424 PLLFBD_PLLFBDIV_M_76 = 0b01001100,
425 PLLFBD_PLLFBDIV_M_77 = 0b01001101,
426 PLLFBD_PLLFBDIV_M_78 = 0b01001110,
427 PLLFBD_PLLFBDIV_M_79 = 0b01001111,
428 PLLFBD_PLLFBDIV_M_80 = 0b01010000,
429 PLLFBD_PLLFBDIV_M_81 = 0b01010001,
430 PLLFBD_PLLFBDIV_M_82 = 0b01010010,
431 PLLFBD_PLLFBDIV_M_83 = 0b01010011,
432 PLLFBD_PLLFBDIV_M_84 = 0b01010100,
433 PLLFBD_PLLFBDIV_M_85 = 0b01010101,
434 PLLFBD_PLLFBDIV_M_86 = 0b01010110,
435 PLLFBD_PLLFBDIV_M_87 = 0b01010111,
436 PLLFBD_PLLFBDIV_M_88 = 0b01011000,
437 PLLFBD_PLLFBDIV_M_89 = 0b01011001,
438 PLLFBD_PLLFBDIV_M_90 = 0b01011010,
439 PLLFBD_PLLFBDIV_M_91 = 0b01011011,
440 PLLFBD_PLLFBDIV_M_92 = 0b01011100,
441 PLLFBD_PLLFBDIV_M_93 = 0b01011101,
442 PLLFBD_PLLFBDIV_M_94 = 0b01011110,
443 PLLFBD_PLLFBDIV_M_95 = 0b01011111,
444 PLLFBD_PLLFBDIV_M_96 = 0b01100000,
445 PLLFBD_PLLFBDIV_M_97 = 0b01100001,
446 PLLFBD_PLLFBDIV_M_98 = 0b01100010,
447 PLLFBD_PLLFBDIV_M_99 = 0b01100011,
448 PLLFBD_PLLFBDIV_M_100 = 0b01100100,
449 PLLFBD_PLLFBDIV_M_101 = 0b01100101,
450 PLLFBD_PLLFBDIV_M_102 = 0b01100110,
451 PLLFBD_PLLFBDIV_M_103 = 0b01100111,
452 PLLFBD_PLLFBDIV_M_104 = 0b01101000,
453 PLLFBD_PLLFBDIV_M_105 = 0b01101001,
454 PLLFBD_PLLFBDIV_M_106 = 0b01101010,
455 PLLFBD_PLLFBDIV_M_107 = 0b01101011,
456 PLLFBD_PLLFBDIV_M_108 = 0b01101100,
457 PLLFBD_PLLFBDIV_M_109 = 0b01101101,
458 PLLFBD_PLLFBDIV_M_110 = 0b01101110,
459 PLLFBD_PLLFBDIV_M_111 = 0b01101111,
460 PLLFBD_PLLFBDIV_M_112 = 0b01110000,
461 PLLFBD_PLLFBDIV_M_113 = 0b01110001,
462 PLLFBD_PLLFBDIV_M_114 = 0b01110010,
463 PLLFBD_PLLFBDIV_M_115 = 0b01110011,
464 PLLFBD_PLLFBDIV_M_116 = 0b01110100,
465 PLLFBD_PLLFBDIV_M_117 = 0b01110101,
466 PLLFBD_PLLFBDIV_M_118 = 0b01110110,
467 PLLFBD_PLLFBDIV_M_119 = 0b01110111,
468 PLLFBD_PLLFBDIV_M_120 = 0b01111000,
469 PLLFBD_PLLFBDIV_M_121 = 0b01111001,
470 PLLFBD_PLLFBDIV_M_122 = 0b01111010,
471 PLLFBD_PLLFBDIV_M_123 = 0b01111011,
472 PLLFBD_PLLFBDIV_M_124 = 0b01111100,
473 PLLFBD_PLLFBDIV_M_125 = 0b01111101,
474 PLLFBD_PLLFBDIV_M_126 = 0b01111110,
475 PLLFBD_PLLFBDIV_M_127 = 0b01111111,
476 PLLFBD_PLLFBDIV_M_128 = 0b10000000,
477 PLLFBD_PLLFBDIV_M_129 = 0b10000001,
478 PLLFBD_PLLFBDIV_M_130 = 0b10000010,
479 PLLFBD_PLLFBDIV_M_131 = 0b10000011,
480 PLLFBD_PLLFBDIV_M_132 = 0b10000100,
481 PLLFBD_PLLFBDIV_M_133 = 0b10000101,
482 PLLFBD_PLLFBDIV_M_134 = 0b10000110,
483 PLLFBD_PLLFBDIV_M_135 = 0b10000111,
484 PLLFBD_PLLFBDIV_M_136 = 0b10001000,
485 PLLFBD_PLLFBDIV_M_137 = 0b10001001,
486 PLLFBD_PLLFBDIV_M_138 = 0b10001010,
487 PLLFBD_PLLFBDIV_M_139 = 0b10001011,
488 PLLFBD_PLLFBDIV_M_140 = 0b10001100,
489 PLLFBD_PLLFBDIV_M_141 = 0b10001101,
490 PLLFBD_PLLFBDIV_M_142 = 0b10001110,
491 PLLFBD_PLLFBDIV_M_143 = 0b10001111,
492 PLLFBD_PLLFBDIV_M_144 = 0b10010000,
493 PLLFBD_PLLFBDIV_M_145 = 0b10010001,
494 PLLFBD_PLLFBDIV_M_146 = 0b10010010,
495 PLLFBD_PLLFBDIV_M_147 = 0b10010011,
496 PLLFBD_PLLFBDIV_M_148 = 0b10010100,
497 PLLFBD_PLLFBDIV_M_149 = 0b10010101,
498 PLLFBD_PLLFBDIV_M_150 = 0b10010110,
499 PLLFBD_PLLFBDIV_M_151 = 0b10010111,
500 PLLFBD_PLLFBDIV_M_152 = 0b10011000,
501 PLLFBD_PLLFBDIV_M_153 = 0b10011001,
502 PLLFBD_PLLFBDIV_M_154 = 0b10011010,
503 PLLFBD_PLLFBDIV_M_155 = 0b10011011,
504 PLLFBD_PLLFBDIV_M_156 = 0b10011100,
505 PLLFBD_PLLFBDIV_M_157 = 0b10011101,
506 PLLFBD_PLLFBDIV_M_158 = 0b10011110,
507 PLLFBD_PLLFBDIV_M_159 = 0b10011111,
508 PLLFBD_PLLFBDIV_M_160 = 0b10100000,
509 PLLFBD_PLLFBDIV_M_161 = 0b10100001,
510 PLLFBD_PLLFBDIV_M_162 = 0b10100010,
511 PLLFBD_PLLFBDIV_M_163 = 0b10100011,
512 PLLFBD_PLLFBDIV_M_164 = 0b10100100,
513 PLLFBD_PLLFBDIV_M_165 = 0b10100101,
514 PLLFBD_PLLFBDIV_M_166 = 0b10100110,
515 PLLFBD_PLLFBDIV_M_167 = 0b10100111,
516 PLLFBD_PLLFBDIV_M_168 = 0b10101000,
517 PLLFBD_PLLFBDIV_M_169 = 0b10101001,
518 PLLFBD_PLLFBDIV_M_170 = 0b10101010,
519 PLLFBD_PLLFBDIV_M_171 = 0b10101011,
520 PLLFBD_PLLFBDIV_M_172 = 0b10101100,
521 PLLFBD_PLLFBDIV_M_173 = 0b10101101,
522 PLLFBD_PLLFBDIV_M_174 = 0b10101110,
523 PLLFBD_PLLFBDIV_M_175 = 0b10101111,
524 PLLFBD_PLLFBDIV_M_176 = 0b10110000,
525 PLLFBD_PLLFBDIV_M_177 = 0b10110001,
526 PLLFBD_PLLFBDIV_M_178 = 0b10110010,
527 PLLFBD_PLLFBDIV_M_179 = 0b10110011,
528 PLLFBD_PLLFBDIV_M_180 = 0b10110100,
529 PLLFBD_PLLFBDIV_M_181 = 0b10110101,
530 PLLFBD_PLLFBDIV_M_182 = 0b10110110,
531 PLLFBD_PLLFBDIV_M_183 = 0b10110111,
532 PLLFBD_PLLFBDIV_M_184 = 0b10111000,
533 PLLFBD_PLLFBDIV_M_185 = 0b10111001,
534 PLLFBD_PLLFBDIV_M_186 = 0b10111010,
535 PLLFBD_PLLFBDIV_M_187 = 0b10111011,
536 PLLFBD_PLLFBDIV_M_188 = 0b10111100,
537 PLLFBD_PLLFBDIV_M_189 = 0b10111101,
538 PLLFBD_PLLFBDIV_M_190 = 0b10111110,
539 PLLFBD_PLLFBDIV_M_191 = 0b10111111,
540 PLLFBD_PLLFBDIV_M_192 = 0b11000000,
541 PLLFBD_PLLFBDIV_M_193 = 0b11000001,
542 PLLFBD_PLLFBDIV_M_194 = 0b11000010,
543 PLLFBD_PLLFBDIV_M_195 = 0b11000011,
544 PLLFBD_PLLFBDIV_M_196 = 0b11000100,
545 PLLFBD_PLLFBDIV_M_197 = 0b11000101,
546 PLLFBD_PLLFBDIV_M_198 = 0b11000110,
547 PLLFBD_PLLFBDIV_M_199 = 0b11000111,
548 PLLFBD_PLLFBDIV_M_200 = 0b11001000
552 volatile PLLFBD_PLLFBDIV_e PLLFBDIV : 8;
553 volatile unsigned : 8;
557 #pragma message "error: === selected device family is not supported by oscillator mcal library ==="
570 #define REG_OSCTUN_VALID_DATA_WRITE_MASK 0x003F
571 #define REG_OSCTUN_VALID_DATA_READ_MASK 0x003F
573 #define REG_OSCTUN_TUNE_VALUE_MASK 0b0000000000111111
574 #define REG_OSCTUN_TUNE_VALUE(x) {(x & REG_OSCTUN_TUNE_VALUE_MASK)}
576 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
578 typedef enum OSCTUN_TUN_e {
579 OSCTUN_TUN_MINUS_31 = 0b100001,
580 OSCTUN_TUN_MINUS_30 = 0b100010,
581 OSCTUN_TUN_MINUS_29 = 0b100011,
582 OSCTUN_TUN_MINUS_28 = 0b100100,
583 OSCTUN_TUN_MINUS_27 = 0b100101,
584 OSCTUN_TUN_MINUS_26 = 0b100110,
585 OSCTUN_TUN_MINUS_25 = 0b100111,
586 OSCTUN_TUN_MINUS_24 = 0b101000,
587 OSCTUN_TUN_MINUS_23 = 0b101001,
588 OSCTUN_TUN_MINUS_22 = 0b101010,
589 OSCTUN_TUN_MINUS_21 = 0b101011,
590 OSCTUN_TUN_MINUS_20 = 0b101100,
591 OSCTUN_TUN_MINUS_19 = 0b101101,
592 OSCTUN_TUN_MINUS_18 = 0b101110,
593 OSCTUN_TUN_MINUS_17 = 0b101111,
594 OSCTUN_TUN_MINUS_16 = 0b110000,
595 OSCTUN_TUN_MINUS_15 = 0b110001,
596 OSCTUN_TUN_MINUS_14 = 0b110010,
597 OSCTUN_TUN_MINUS_13 = 0b110011,
598 OSCTUN_TUN_MINUS_12 = 0b110100,
599 OSCTUN_TUN_MINUS_11 = 0b110101,
600 OSCTUN_TUN_MINUS_10 = 0b110110,
601 OSCTUN_TUN_MINUS_9 = 0b110111,
602 OSCTUN_TUN_MINUS_8 = 0b111000,
603 OSCTUN_TUN_MINUS_7 = 0b111001,
604 OSCTUN_TUN_MINUS_6 = 0b111010,
605 OSCTUN_TUN_MINUS_5 = 0b111011,
606 OSCTUN_TUN_MINUS_4 = 0b111100,
607 OSCTUN_TUN_MINUS_3 = 0b111101,
608 OSCTUN_TUN_MINUS_2 = 0b111110,
609 OSCTUN_TUN_MINUS_1 = 0b111111,
610 OSCTUN_TUN_NOMINAL = 0b000000,
611 OSCTUN_TUN_PLUS_1 = 0b000001,
612 OSCTUN_TUN_PLUS_2 = 0b000010,
613 OSCTUN_TUN_PLUS_3 = 0b000011,
614 OSCTUN_TUN_PLUS_4 = 0b000100,
615 OSCTUN_TUN_PLUS_5 = 0b000101,
616 OSCTUN_TUN_PLUS_6 = 0b000110,
617 OSCTUN_TUN_PLUS_7 = 0b000111,
618 OSCTUN_TUN_PLUS_8 = 0b001000,
619 OSCTUN_TUN_PLUS_9 = 0b001001,
620 OSCTUN_TUN_PLUS_10 = 0b001010,
621 OSCTUN_TUN_PLUS_11 = 0b001011,
622 OSCTUN_TUN_PLUS_12 = 0b001100,
623 OSCTUN_TUN_PLUS_13 = 0b001101,
624 OSCTUN_TUN_PLUS_14 = 0b001110,
625 OSCTUN_TUN_PLUS_15 = 0b001111,
626 OSCTUN_TUN_PLUS_16 = 0b010000,
627 OSCTUN_TUN_PLUS_17 = 0b010001,
628 OSCTUN_TUN_PLUS_18 = 0b010010,
629 OSCTUN_TUN_PLUS_19 = 0b010011,
630 OSCTUN_TUN_PLUS_20 = 0b010100,
631 OSCTUN_TUN_PLUS_21 = 0b010101,
632 OSCTUN_TUN_PLUS_22 = 0b010110,
633 OSCTUN_TUN_PLUS_23 = 0b010111,
634 OSCTUN_TUN_PLUS_24 = 0b011000,
635 OSCTUN_TUN_PLUS_25 = 0b011001,
636 OSCTUN_TUN_PLUS_26 = 0b011010,
637 OSCTUN_TUN_PLUS_27 = 0b011011,
638 OSCTUN_TUN_PLUS_28 = 0b011100,
639 OSCTUN_TUN_PLUS_29 = 0b011101,
640 OSCTUN_TUN_PLUS_30 = 0b011110,
641 OSCTUN_TUN_PLUS_31 = 0b011111
645 #pragma message "error: === selected device family is not supported by oscillator mcal library ==="
649 volatile enum OSCTUN_TUN_e TUN : 6;
650 volatile unsigned : 10;
651 } __attribute__((packed)) OSCTUN_t;
663 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
665 #define REG_PLLDIV_VALID_DATA_WRITE_MASK 0x0377
666 #define REG_PLLDIV_VALID_DATA_READ_MASK 0x0377
668 #define REG_PLLDIV_POST1DIV_N2_MASK 0b0000000001110000
669 #define REG_PLLDIV_POST1DIV_N2(x) {((x << 4) & REG_PLLDIV_POST1DIV_N2_MASK)}
671 #define REG_PLLDIV_POST2DIV_N3_MASK 0b0000000000000111
672 #define REG_PLLDIV_POST2DIV_N3(x) {(x & REG_PLLDIV_POST1DIV_N3_MASK)}
675 PLLDIV_POST2DIV_N2N3_1 = 0b001,
676 PLLDIV_POST2DIV_N2N3_2 = 0b010,
677 PLLDIV_POST2DIV_N2N3_3 = 0b011,
678 PLLDIV_POST2DIV_N2N3_4 = 0b100,
679 PLLDIV_POST2DIV_N2N3_5 = 0b101,
680 PLLDIV_POST2DIV_N2N3_6 = 0b110,
681 PLLDIV_POST2DIV_N2N3_7 = 0b111
684 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_1 0b0000001100000000
685 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_2 0b0000001000000000
686 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_3 0b0000000100000000
687 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_4 0b0000000000000000
690 PLLDIV_VCODIV_FVCO_DIV_BY_1 = 0b11,
691 PLLDIV_VCODIV_FVCO_DIV_BY_2 = 0b10,
692 PLLDIV_VCODIV_FVCO_DIV_BY_3 = 0b01,
693 PLLDIV_VCODIV_FVCO_DIV_BY_4 = 0b00
697 volatile PLLDIV_POSTxDIV_e POST2DIV : 3;
698 volatile unsigned : 1;
699 volatile PLLDIV_POSTxDIV_e POST1DIV : 3;
700 volatile unsigned : 1;
701 volatile PLLDIV_VCODIV_e VCODIV : 2;
702 volatile unsigned : 6;
703 } __attribute__((packed)) PLLDIV_t;
706 volatile uint16_t value;
707 volatile PLLDIV_t PLLDIV;
708 } REGBLK_PLLDIV_CONFIG_t;
717 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
719 #define REG_ACLKCON_VALID_DATA_WRITE_MASK 0xC10F
720 #define REG_ACLKCON_VALID_DATA_READ_MASK 0xC10F
722 #define REG_ACLKCON_APLLPRE_DIV_MASK 0b0000000000001111
723 #define REG_ACLKCON_APLLPRE_DIVIDER_N1(x) {(x & REG_ACLKCON_APLLPRE_DIV_MASK)}
726 ACLKCON_APLLDIV_N1_1 = 0b000001,
727 ACLKCON_APLLDIV_N1_2 = 0b000010,
728 ACLKCON_APLLDIV_N1_3 = 0b000011,
729 ACLKCON_APLLDIV_N1_4 = 0b000100,
730 ACLKCON_APLLDIV_N1_5 = 0b000101,
731 ACLKCON_APLLDIV_N1_6 = 0b000110,
732 ACLKCON_APLLDIV_N1_7 = 0b000111,
733 ACLKCON_APLLDIV_N1_8 = 0b001000
736 #define REG_ACLKCON_FRCSEL_FRC 0b0000000100000000
737 #define REG_ACLKCON_FRCSEL_PRI 0b0000000000000000
740 PLLDIV_ACLKCON_FRCSEL_FRC = 0b1,
741 PLLDIV_ACLKCON_FRCSEL_PRI = 0b0
744 #define REG_ACLKCON_APLLCK_STAT_LOCKED 0b0100000000000000
745 #define REG_ACLKCON_APLLCK_STAT_UNLOCKED 0b0000000000000000
748 ACLKCON_APLLCK_STAT_LOCKED = 0b1,
749 ACLKCON_APLLCK_STAT_UNLOCKED = 0b0
752 #define REG_ACLKCON_APLLEN_ENABLED 0b1000000000000000
753 #define REG_ACLKCON_APLLEN_DISABLED 0b0000000000000000
756 ACLKCON_APLLEN_ENABLED = 0b1,
757 ACLKCON_APLLEN_DISABLED = 0b0
761 volatile ACLKCON_APLLPRE_e APLLPRE : 6;
762 volatile unsigned : 2;
763 volatile ACLKCON_FRCSEL_e FRCSEL : 1;
764 volatile unsigned : 5;
765 volatile ACLKCON_APLLCK_e APLLCK : 1;
766 volatile ACLKCON_APLLEN_e APLLEN : 1;
770 volatile uint16_t value;
771 volatile ACLKCON_t ACLKCON;
772 } REGBLK_ACLKCON_CONFIG_t;
775 #pragma message "error: === selected device family is not supported by oscillator mcal library ==="
782 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
784 #define REG_APLLFBD_VALID_DATA_WRITE_MASK 0x00FF
785 #define REG_APLLFBD_VALID_DATA_READ_MASK 0x00FF
787 #define REG_APLLFBD_APLLFBDIV_M_MASK 0b0000000011111111
788 #define REG_APLLFBD_MULTIPLIER_M(x) {(x & REG_APLLFBD_APLLFBDIV_M_MASK)}
791 APLLFBD_APLLFBDIV_M_16 = 0b00010000,
792 APLLFBD_APLLFBDIV_M_17 = 0b00010001,
793 APLLFBD_APLLFBDIV_M_18 = 0b00010010,
794 APLLFBD_APLLFBDIV_M_19 = 0b00010011,
795 APLLFBD_APLLFBDIV_M_20 = 0b00010100,
796 APLLFBD_APLLFBDIV_M_21 = 0b00010101,
797 APLLFBD_APLLFBDIV_M_22 = 0b00010110,
798 APLLFBD_APLLFBDIV_M_23 = 0b00010111,
799 APLLFBD_APLLFBDIV_M_24 = 0b00011000,
800 APLLFBD_APLLFBDIV_M_25 = 0b00011001,
801 APLLFBD_APLLFBDIV_M_26 = 0b00011010,
802 APLLFBD_APLLFBDIV_M_27 = 0b00011011,
803 APLLFBD_APLLFBDIV_M_28 = 0b00011100,
804 APLLFBD_APLLFBDIV_M_29 = 0b00011101,
805 APLLFBD_APLLFBDIV_M_30 = 0b00011110,
806 APLLFBD_APLLFBDIV_M_31 = 0b00011111,
807 APLLFBD_APLLFBDIV_M_32 = 0b00100000,
808 APLLFBD_APLLFBDIV_M_33 = 0b00100001,
809 APLLFBD_APLLFBDIV_M_34 = 0b00100010,
810 APLLFBD_APLLFBDIV_M_35 = 0b00100011,
811 APLLFBD_APLLFBDIV_M_36 = 0b00100100,
812 APLLFBD_APLLFBDIV_M_37 = 0b00100101,
813 APLLFBD_APLLFBDIV_M_38 = 0b00100110,
814 APLLFBD_APLLFBDIV_M_39 = 0b00100111,
815 APLLFBD_APLLFBDIV_M_40 = 0b00101000,
816 APLLFBD_APLLFBDIV_M_41 = 0b00101001,
817 APLLFBD_APLLFBDIV_M_42 = 0b00101010,
818 APLLFBD_APLLFBDIV_M_43 = 0b00101011,
819 APLLFBD_APLLFBDIV_M_44 = 0b00101100,
820 APLLFBD_APLLFBDIV_M_45 = 0b00101101,
821 APLLFBD_APLLFBDIV_M_46 = 0b00101110,
822 APLLFBD_APLLFBDIV_M_47 = 0b00101111,
823 APLLFBD_APLLFBDIV_M_48 = 0b00110000,
824 APLLFBD_APLLFBDIV_M_49 = 0b00110001,
825 APLLFBD_APLLFBDIV_M_50 = 0b00110010,
826 APLLFBD_APLLFBDIV_M_51 = 0b00110011,
827 APLLFBD_APLLFBDIV_M_52 = 0b00110100,
828 APLLFBD_APLLFBDIV_M_53 = 0b00110101,
829 APLLFBD_APLLFBDIV_M_54 = 0b00110110,
830 APLLFBD_APLLFBDIV_M_55 = 0b00110111,
831 APLLFBD_APLLFBDIV_M_56 = 0b00111000,
832 APLLFBD_APLLFBDIV_M_57 = 0b00111001,
833 APLLFBD_APLLFBDIV_M_58 = 0b00111010,
834 APLLFBD_APLLFBDIV_M_59 = 0b00111011,
835 APLLFBD_APLLFBDIV_M_60 = 0b00111100,
836 APLLFBD_APLLFBDIV_M_61 = 0b00111101,
837 APLLFBD_APLLFBDIV_M_62 = 0b00111110,
838 APLLFBD_APLLFBDIV_M_63 = 0b00111111,
839 APLLFBD_APLLFBDIV_M_64 = 0b01000000,
840 APLLFBD_APLLFBDIV_M_65 = 0b01000001,
841 APLLFBD_APLLFBDIV_M_66 = 0b01000010,
842 APLLFBD_APLLFBDIV_M_67 = 0b01000011,
843 APLLFBD_APLLFBDIV_M_68 = 0b01000100,
844 APLLFBD_APLLFBDIV_M_69 = 0b01000101,
845 APLLFBD_APLLFBDIV_M_70 = 0b01000110,
846 APLLFBD_APLLFBDIV_M_71 = 0b01000111,
847 APLLFBD_APLLFBDIV_M_72 = 0b01001000,
848 APLLFBD_APLLFBDIV_M_73 = 0b01001001,
849 APLLFBD_APLLFBDIV_M_74 = 0b01001010,
850 APLLFBD_APLLFBDIV_M_75 = 0b01001011,
851 APLLFBD_APLLFBDIV_M_76 = 0b01001100,
852 APLLFBD_APLLFBDIV_M_77 = 0b01001101,
853 APLLFBD_APLLFBDIV_M_78 = 0b01001110,
854 APLLFBD_APLLFBDIV_M_79 = 0b01001111,
855 APLLFBD_APLLFBDIV_M_80 = 0b01010000,
856 APLLFBD_APLLFBDIV_M_81 = 0b01010001,
857 APLLFBD_APLLFBDIV_M_82 = 0b01010010,
858 APLLFBD_APLLFBDIV_M_83 = 0b01010011,
859 APLLFBD_APLLFBDIV_M_84 = 0b01010100,
860 APLLFBD_APLLFBDIV_M_85 = 0b01010101,
861 APLLFBD_APLLFBDIV_M_86 = 0b01010110,
862 APLLFBD_APLLFBDIV_M_87 = 0b01010111,
863 APLLFBD_APLLFBDIV_M_88 = 0b01011000,
864 APLLFBD_APLLFBDIV_M_89 = 0b01011001,
865 APLLFBD_APLLFBDIV_M_90 = 0b01011010,
866 APLLFBD_APLLFBDIV_M_91 = 0b01011011,
867 APLLFBD_APLLFBDIV_M_92 = 0b01011100,
868 APLLFBD_APLLFBDIV_M_93 = 0b01011101,
869 APLLFBD_APLLFBDIV_M_94 = 0b01011110,
870 APLLFBD_APLLFBDIV_M_95 = 0b01011111,
871 APLLFBD_APLLFBDIV_M_96 = 0b01100000,
872 APLLFBD_APLLFBDIV_M_97 = 0b01100001,
873 APLLFBD_APLLFBDIV_M_98 = 0b01100010,
874 APLLFBD_APLLFBDIV_M_99 = 0b01100011,
875 APLLFBD_APLLFBDIV_M_100 = 0b01100100,
876 APLLFBD_APLLFBDIV_M_101 = 0b01100101,
877 APLLFBD_APLLFBDIV_M_102 = 0b01100110,
878 APLLFBD_APLLFBDIV_M_103 = 0b01100111,
879 APLLFBD_APLLFBDIV_M_104 = 0b01101000,
880 APLLFBD_APLLFBDIV_M_105 = 0b01101001,
881 APLLFBD_APLLFBDIV_M_106 = 0b01101010,
882 APLLFBD_APLLFBDIV_M_107 = 0b01101011,
883 APLLFBD_APLLFBDIV_M_108 = 0b01101100,
884 APLLFBD_APLLFBDIV_M_109 = 0b01101101,
885 APLLFBD_APLLFBDIV_M_110 = 0b01101110,
886 APLLFBD_APLLFBDIV_M_111 = 0b01101111,
887 APLLFBD_APLLFBDIV_M_112 = 0b01110000,
888 APLLFBD_APLLFBDIV_M_113 = 0b01110001,
889 APLLFBD_APLLFBDIV_M_114 = 0b01110010,
890 APLLFBD_APLLFBDIV_M_115 = 0b01110011,
891 APLLFBD_APLLFBDIV_M_116 = 0b01110100,
892 APLLFBD_APLLFBDIV_M_117 = 0b01110101,
893 APLLFBD_APLLFBDIV_M_118 = 0b01110110,
894 APLLFBD_APLLFBDIV_M_119 = 0b01110111,
895 APLLFBD_APLLFBDIV_M_120 = 0b01111000,
896 APLLFBD_APLLFBDIV_M_121 = 0b01111001,
897 APLLFBD_APLLFBDIV_M_122 = 0b01111010,
898 APLLFBD_APLLFBDIV_M_123 = 0b01111011,
899 APLLFBD_APLLFBDIV_M_124 = 0b01111100,
900 APLLFBD_APLLFBDIV_M_125 = 0b01111101,
901 APLLFBD_APLLFBDIV_M_126 = 0b01111110,
902 APLLFBD_APLLFBDIV_M_127 = 0b01111111,
903 APLLFBD_APLLFBDIV_M_128 = 0b10000000,
904 APLLFBD_APLLFBDIV_M_129 = 0b10000001,
905 APLLFBD_APLLFBDIV_M_130 = 0b10000010,
906 APLLFBD_APLLFBDIV_M_131 = 0b10000011,
907 APLLFBD_APLLFBDIV_M_132 = 0b10000100,
908 APLLFBD_APLLFBDIV_M_133 = 0b10000101,
909 APLLFBD_APLLFBDIV_M_134 = 0b10000110,
910 APLLFBD_APLLFBDIV_M_135 = 0b10000111,
911 APLLFBD_APLLFBDIV_M_136 = 0b10001000,
912 APLLFBD_APLLFBDIV_M_137 = 0b10001001,
913 APLLFBD_APLLFBDIV_M_138 = 0b10001010,
914 APLLFBD_APLLFBDIV_M_139 = 0b10001011,
915 APLLFBD_APLLFBDIV_M_140 = 0b10001100,
916 APLLFBD_APLLFBDIV_M_141 = 0b10001101,
917 APLLFBD_APLLFBDIV_M_142 = 0b10001110,
918 APLLFBD_APLLFBDIV_M_143 = 0b10001111,
919 APLLFBD_APLLFBDIV_M_144 = 0b10010000,
920 APLLFBD_APLLFBDIV_M_145 = 0b10010001,
921 APLLFBD_APLLFBDIV_M_146 = 0b10010010,
922 APLLFBD_APLLFBDIV_M_147 = 0b10010011,
923 APLLFBD_APLLFBDIV_M_148 = 0b10010100,
924 APLLFBD_APLLFBDIV_M_149 = 0b10010101,
925 APLLFBD_APLLFBDIV_M_150 = 0b10010110,
926 APLLFBD_APLLFBDIV_M_151 = 0b10010111,
927 APLLFBD_APLLFBDIV_M_152 = 0b10011000,
928 APLLFBD_APLLFBDIV_M_153 = 0b10011001,
929 APLLFBD_APLLFBDIV_M_154 = 0b10011010,
930 APLLFBD_APLLFBDIV_M_155 = 0b10011011,
931 APLLFBD_APLLFBDIV_M_156 = 0b10011100,
932 APLLFBD_APLLFBDIV_M_157 = 0b10011101,
933 APLLFBD_APLLFBDIV_M_158 = 0b10011110,
934 APLLFBD_APLLFBDIV_M_159 = 0b10011111,
935 APLLFBD_APLLFBDIV_M_160 = 0b10100000,
936 APLLFBD_APLLFBDIV_M_161 = 0b10100001,
937 APLLFBD_APLLFBDIV_M_162 = 0b10100010,
938 APLLFBD_APLLFBDIV_M_163 = 0b10100011,
939 APLLFBD_APLLFBDIV_M_164 = 0b10100100,
940 APLLFBD_APLLFBDIV_M_165 = 0b10100101,
941 APLLFBD_APLLFBDIV_M_166 = 0b10100110,
942 APLLFBD_APLLFBDIV_M_167 = 0b10100111,
943 APLLFBD_APLLFBDIV_M_168 = 0b10101000,
944 APLLFBD_APLLFBDIV_M_169 = 0b10101001,
945 APLLFBD_APLLFBDIV_M_170 = 0b10101010,
946 APLLFBD_APLLFBDIV_M_171 = 0b10101011,
947 APLLFBD_APLLFBDIV_M_172 = 0b10101100,
948 APLLFBD_APLLFBDIV_M_173 = 0b10101101,
949 APLLFBD_APLLFBDIV_M_174 = 0b10101110,
950 APLLFBD_APLLFBDIV_M_175 = 0b10101111,
951 APLLFBD_APLLFBDIV_M_176 = 0b10110000,
952 APLLFBD_APLLFBDIV_M_177 = 0b10110001,
953 APLLFBD_APLLFBDIV_M_178 = 0b10110010,
954 APLLFBD_APLLFBDIV_M_179 = 0b10110011,
955 APLLFBD_APLLFBDIV_M_180 = 0b10110100,
956 APLLFBD_APLLFBDIV_M_181 = 0b10110101,
957 APLLFBD_APLLFBDIV_M_182 = 0b10110110,
958 APLLFBD_APLLFBDIV_M_183 = 0b10110111,
959 APLLFBD_APLLFBDIV_M_184 = 0b10111000,
960 APLLFBD_APLLFBDIV_M_185 = 0b10111001,
961 APLLFBD_APLLFBDIV_M_186 = 0b10111010,
962 APLLFBD_APLLFBDIV_M_187 = 0b10111011,
963 APLLFBD_APLLFBDIV_M_188 = 0b10111100,
964 APLLFBD_APLLFBDIV_M_189 = 0b10111101,
965 APLLFBD_APLLFBDIV_M_190 = 0b10111110,
966 APLLFBD_APLLFBDIV_M_191 = 0b10111111,
967 APLLFBD_APLLFBDIV_M_192 = 0b11000000,
968 APLLFBD_APLLFBDIV_M_193 = 0b11000001,
969 APLLFBD_APLLFBDIV_M_194 = 0b11000010,
970 APLLFBD_APLLFBDIV_M_195 = 0b11000011,
971 APLLFBD_APLLFBDIV_M_196 = 0b11000100,
972 APLLFBD_APLLFBDIV_M_197 = 0b11000101,
973 APLLFBD_APLLFBDIV_M_198 = 0b11000110,
974 APLLFBD_APLLFBDIV_M_199 = 0b11000111,
975 APLLFBD_APLLFBDIV_M_200 = 0b11001000
976 } APLLFBD_APLLFBDIV_e;
979 volatile APLLFBD_APLLFBDIV_e APLLFBDIV : 8;
980 volatile unsigned : 8;
984 volatile uint16_t value;
985 volatile APLLFBD_t APLLFBD;
986 } REGBLK_APLLFBD_CONFIG_t;
989 #pragma message "error: === selected device family is not supported by oscillator mcal library ==="
996 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
998 #define REG_APLLDIV_VALID_DATA_WRITE_MASK 0x0377
999 #define REG_APLLDIV_VALID_DATA_READ_MASK 0x0377
1001 #define REG_APLLDIV_POST1DIV_N2_MASK 0b0000000001110000
1002 #define REG_APLLDIV_POST1DIV_N2(x) {((x << 4) & REG_APLLDIV_POST1DIV_N2_MASK)}
1004 #define REG_APLLDIV_POST2DIV_N3_MASK 0b0000000000000111
1005 #define REG_APLLDIV_POST2DIV_N3(x) {(x & REG_APLLDIV_POST1DIV_N3_MASK)}
1008 APLLDIV_POST2DIV_N2N3_1 = 0b001,
1009 APLLDIV_POST2DIV_N2N3_2 = 0b010,
1010 APLLDIV_POST2DIV_N2N3_3 = 0b011,
1011 APLLDIV_POST2DIV_N2N3_4 = 0b100,
1012 APLLDIV_POST2DIV_N2N3_5 = 0b101,
1013 APLLDIV_POST2DIV_N2N3_6 = 0b110,
1014 APLLDIV_POST2DIV_N2N3_7 = 0b111
1015 } APLLDIV_POSTxDIV_e;
1017 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_1 0b0000001100000000
1018 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_2 0b0000001000000000
1019 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_3 0b0000000100000000
1020 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_4 0b0000000000000000
1023 APLLDIV_AVCODIV_FVCO_DIV_BY_1 = 0b11,
1024 APLLDIV_AVCODIV_FVCO_DIV_BY_2 = 0b10,
1025 APLLDIV_AVCODIV_FVCO_DIV_BY_3 = 0b01,
1026 APLLDIV_AVCODIV_FVCO_DIV_BY_4 = 0b00
1027 } APLLDIV_AVCODIV_e;
1030 volatile APLLDIV_POSTxDIV_e APOST2DIV : 3;
1031 volatile unsigned : 1;
1032 volatile APLLDIV_POSTxDIV_e APOST1DIV : 3;
1033 volatile unsigned : 1;
1034 volatile APLLDIV_AVCODIV_e AVCODIV : 2;
1035 volatile unsigned : 6;
1036 } __attribute__((packed)) APLLDIV_t;
1039 volatile uint16_t value;
1040 volatile APLLDIV_t APLLDIV;
1041 } REGBLK_APLLDIV_CONFIG_t;
1044 #pragma message "error: === selected device family is not supported by oscillator mcal library ==="
1051 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__)
1053 typedef struct OSC_CONFIG_s {
1054 volatile OSCCON_xOSC_TYPE_e osc_type;
1055 volatile enum CLKDIV_FRCDIVN_e frc_div;
1056 volatile enum OSCTUN_TUN_e frc_tune;
1057 volatile CLKDIV_PLLPRE_e N1;
1058 volatile PLLFBD_PLLFBDIV_e M;
1059 volatile PLLDIV_POSTxDIV_e N2;
1060 volatile PLLDIV_POSTxDIV_e N3;
1061 volatile PLLDIV_VCODIV_e VCODIV;
1064 typedef struct AUXOSC_CONFIG_s {
1065 volatile ACLKCON_APLLPRE_e N1;
1066 volatile APLLFBD_APLLFBDIV_e M;
1067 volatile APLLDIV_POSTxDIV_e N2;
1068 volatile APLLDIV_POSTxDIV_e N3;
1069 volatile APLLDIV_AVCODIV_e AVCODIV;
1070 volatile ACLKCON_FRCSEL_e FRCSEL : 1;
1071 volatile ACLKCON_APLLCK_e APLLCK : 1;
1072 volatile ACLKCON_APLLEN_e APLLEN : 1;
1076 #pragma message "error: === selected device family is not supported by oscillator mcal library ==="
1084 typedef enum OSC_CFG_ERR_RESULT_e{
1085 OSCERR_FAILURE = 0x0000,
1086 OSCERR_SUCCESS = 0x0001,
1087 OSCERR_CSF = 0x0002,
1088 OSCERR_RST = 0x0004,
1089 OSCERR_CSD = 0x0008,
1090 OSCERR_PLL_LCK = 0x0010,
1091 OSCERR_APLL_LCK = 0x0020,
1092 } OSC_CFG_ERR_RESULT_t;
1099 extern volatile uint16_t p33c_Osc_Initialize(
volatile struct OSC_CONFIG_s osc_config);
1100 extern volatile uint16_t
p33c_OscFrc_Initialize(
volatile enum CLKDIV_FRCDIVN_e frc_div,
volatile enum OSCTUN_TUN_e frc_tun);