Matteo Rubini

help about MCF52259 DEMO

Discussion created by Matteo Rubini on Nov 10, 2009
Latest reply on Nov 11, 2009 by Mark Butcher

Hello everyone, I'm an Italian student and I'm working on a MCF52259 demo. I'm trying to control a LED with the MCF52259 and I've written this code following an old work by a student, but the  doesn't work at the right frequency, even if I set it manually...


Do you see any error in my code? I can't figure out what's wrong about it. Thank you very much for your aid!!



 /*** ### MCF52259CAG80 "Cpu" init code ... ***/
  /*** PE initialization code after reset ***/
  /* System clock initialization */
  /* CCHR: ??=0,??=0,??=0,??=0,??=0,CCHR=5 */
  setReg8(CCHR, 0x05);                 /* Set the predivider */
  /* SYNCR: LOLRE=0,MFD=3,LOCRE=0,RFD=0,LOCEN=0,DISCLK=0,FWKUP=0,??=0,??=0,CLKsrc=1,PLLMODE=1,PLLEN=1 */
  setReg16(SYNCR, 0x3007);             /* Set the SYNCR register */
  while (!(SYNSR & SYNSR_LOCK_BITMASK)){} /* Wait until the PLL is locked. */
  /* LPDR: ??=0,??=0,??=0,??=0,LPD=0 */
  setReg8(LPDR, 0x00);                 /* Set the low power divider */
  /* RTCCR: ??=0,EXTALEN=0,??=0,OSCEN=0,KHZEN=0,REFS=0,LPEN=0,RTCSEL=1 */
  setReg8(RTCCR, 0x01);                /* Set the RTC oscillator and RTC clock select */
  /* BWCR: ??=0,??=0,??=0,??=0,??=0,??=0,BWDSTOP=0,BWDSEL=1 */
  setReg32(BWCR, 0x01);                /* Set the BWCR register */
  /*** End of PE initialization code after reset ***/



my code..

 double Out_sigma2=0;
double Out_sigma2_old=0;
double Vout=0;
double Vin=0;
double PidEnable=0;



 /* Blocco sigma delta del dimming */
  Vin=0.5; // valore fisso per prova
 //  random2 = rand() ;
//      random2=random2/65536;
    if (Out_sigma2<0.5)


 I set the micro so that it should work at 80 MHz, but the output switches at 100kHz!!!!!!


On the contrary, if I execute this code:





the exit switches at 3MHz !!!


Help me please!!!