This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C6747 changing clock on EMIFB to external SDRAM



I want to dynamically change the clock on the C6747 EMIFB to the external SDRAM to slow it down to save power. I am running DSP/BIOS 5.x and an audio application with both code and data in internal and external SDRAM.

I run the sdram clock at 1/3 core speed which is 372/3=124 MHz.  I plan to go to around 5 MHz ram clock.  I do this by running the following code to be executed from internal memory and internal stack :

    HWkey = (Uint32)HWI_disable();
    SWI_disable();  
    TSK_disable();

    // put memory into self-refresh mode
    entryDDRCTL = REG(SDRFC_REG);
    REG(SDRFC_REG) &= ~SR_PD_BIT;   // select self-refresh mode
    REG(SDRFC_REG) |= LPMODEN_BIT;  // enable low-power mode

//Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress
    while(PLL0_PLLSTAT & 0x1==1){}
   
    //Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default)
 
    PLL0_PLLDIV5 = 0x8000 | PLLDIV5; // Make PLLDIV5 as bootpacket, do it for other PLLDIVx to if required

 
   //Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition
    PLL0_PLLCMD |= 0x1;

       
    //Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment)
    while(PLL0_PLLSTAT & 0x1==1) { }

    
    // restore SDRAM  mode
    REG(SDRFC_REG) = entryDDRCTL;
                
    HWI_restore(HWkey);    // _restore_interrupts(HWkey);
    SWI_enable();
    TSK_enable();

Questions

1) I would like to know if this is the correct method. 

2) Also when I single step this code it works.  Free running it can hang the code in one of the while loops.  So do I need some kind of delay before checking some of these registers.  Putting a delay before the 2 while loops works but I am not sure why and what the delay should be.

Thanks,

Fawad

  • Fawad,

    You are following the right procedure of described in the C6747 Technical reference manual but it is safer to insert delays after PLL_CMD and PLL_STAT is modified, to account for slow PLL transitions. A delay of around 200 to 2000 cycles should be sufficient. This could also explain why single stepping through the code worked for you. You should be able to see an sample implementation of this in the GEL files.

    Regards,

    Rahul



  • Rahul,

    Thanks for the info.  I am still a little concerned that even with appropriate delays I had a 1 in 100 chance of getting stuck in one of the while loops.  Any ideas/suggestions on what could be the cause of this?

    Also my delays are around 3000 cycles.

    Thanks,

    Fawad