93 static uint16_t SetVCoreUp(uint8_t level)
95 uint16_t PMMRIE_backup, SVSMHCTL_backup, SVSMLCTL_backup;
107 PMMRIE_backup = PMMRIE;
108 PMMRIE &= ~(SVMHVLRPE | SVSHPE | SVMLVLRPE | SVSLPE | SVMHVLRIE |
109 SVMHIE | SVSMHDLYIE | SVMLVLRIE | SVMLIE | SVSMLDLYIE);
110 SVSMHCTL_backup = SVSMHCTL;
111 SVSMLCTL_backup = SVSMLCTL;
117 SVSMHCTL = SVMHE | SVSHE | (SVSMHRRL0 * level);
120 while ((PMMIFG & SVSMHDLYIFG) == 0) ;
123 PMMIFG &= ~SVSMHDLYIFG;
126 if ((PMMIFG & SVMHIFG) == SVMHIFG){
128 PMMIFG &= ~SVSMHDLYIFG;
129 SVSMHCTL = SVSMHCTL_backup;
132 while ((PMMIFG & SVSMHDLYIFG) == 0) ;
135 PMMIFG &= ~(SVMHVLRIFG | SVMHIFG | SVSMHDLYIFG | SVMLVLRIFG | SVMLIFG | SVSMLDLYIFG);
137 PMMRIE = PMMRIE_backup;
144 SVSMHCTL |= (SVSHRVL0 * level);
147 while ((PMMIFG & SVSMHDLYIFG) == 0) ;
150 PMMIFG &= ~SVSMHDLYIFG;
153 PMMCTL0_L = PMMCOREV0 * level;
156 SVSMLCTL = SVMLE | (SVSMLRRL0 * level) | SVSLE | (SVSLRVL0 * level);
159 while ((PMMIFG & SVSMLDLYIFG) == 0) ;
162 PMMIFG &= ~SVSMLDLYIFG;
167 SVSMLCTL &= (SVSLRVL0 + SVSLRVL1 + SVSMLRRL0 + SVSMLRRL1 + SVSMLRRL2);
170 SVSMLCTL_backup &= ~(SVSLRVL0 + SVSLRVL1 + SVSMLRRL0 + SVSMLRRL1 + SVSMLRRL2);
173 SVSMLCTL |= SVSMLCTL_backup;
177 SVSMHCTL &= (SVSHRVL0 + SVSHRVL1 + SVSMHRRL0 + SVSMHRRL1 + SVSMHRRL2);
180 SVSMHCTL_backup &= ~(SVSHRVL0 + SVSHRVL1 + SVSMHRRL0 + SVSMHRRL1 + SVSMHRRL2);
183 SVSMHCTL |= SVSMHCTL_backup;
186 while (((PMMIFG & SVSMLDLYIFG) == 0) && ((PMMIFG & SVSMHDLYIFG) == 0)) ;
189 PMMIFG &= ~(SVMHVLRIFG | SVMHIFG | SVSMHDLYIFG | SVMLVLRIFG | SVMLIFG | SVSMLDLYIFG);
191 PMMRIE = PMMRIE_backup;
204 static uint16_t SetVCoreDown(uint8_t level)
206 uint16_t PMMRIE_backup, SVSMHCTL_backup, SVSMLCTL_backup;
218 PMMRIE_backup = PMMRIE;
219 PMMRIE &= ~(SVMHVLRPE | SVSHPE | SVMLVLRPE | SVSLPE | SVMHVLRIE |
220 SVMHIE | SVSMHDLYIE | SVMLVLRIE | SVMLIE | SVSMLDLYIE);
221 SVSMHCTL_backup = SVSMHCTL;
222 SVSMLCTL_backup = SVSMLCTL;
225 PMMIFG &= ~(SVMHIFG | SVSMHDLYIFG | SVMLIFG | SVSMLDLYIFG);
228 SVSMHCTL = SVMHE | (SVSMHRRL0 * level) | SVSHE | (SVSHRVL0 * level);
229 SVSMLCTL = SVMLE | (SVSMLRRL0 * level) | SVSLE | (SVSLRVL0 * level);
232 while ((PMMIFG & SVSMHDLYIFG) == 0 || (PMMIFG & SVSMLDLYIFG) == 0) ;
235 PMMIFG &= ~(SVSMHDLYIFG + SVSMLDLYIFG);
239 PMMCTL0_L = PMMCOREV0 * level;
243 SVSMLCTL &= (SVSLRVL0 + SVSLRVL1 + SVSMLRRL0 + SVSMLRRL1 + SVSMLRRL2);
246 SVSMLCTL_backup &= ~(SVSLRVL0 + SVSLRVL1 + SVSMLRRL0 + SVSMLRRL1 + SVSMLRRL2);
249 SVSMLCTL |= SVSMLCTL_backup;
253 SVSMHCTL &= (SVSHRVL0 + SVSHRVL1 + SVSMHRRL0 + SVSMHRRL1 + SVSMHRRL2);
256 SVSMHCTL_backup &= ~(SVSHRVL0 + SVSHRVL1 + SVSMHRRL0 + SVSMHRRL1 + SVSMHRRL2);
259 SVSMHCTL |= SVSMHCTL_backup;
262 while (((PMMIFG & SVSMLDLYIFG) == 0) && ((PMMIFG & SVSMHDLYIFG) == 0)) ;
265 PMMIFG &= ~(SVMHVLRIFG | SVMHIFG | SVSMHDLYIFG | SVMLVLRIFG | SVMLIFG | SVSMLDLYIFG);
267 PMMRIE = PMMRIE_backup;
278 actlevel = (PMMCTL0 & PMMCOREV_3);
280 while ((level != actlevel) && (status == 0)) {
281 if (level > actlevel){
282 status = SetVCoreUp(++actlevel);
285 status = SetVCoreDown(--actlevel);