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.

DDR2 400 GEL initialization for 6748

Hello,

I am trying to initialize the DDR2 for our board.  I have been using the LogicPD Gel file as a template because that is what this post says to do:

http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/115/p/60850/218071.aspx#218071

the problem is I cannot get anything on the DDR2.  i get data verification errors and when I open up the memory map i see all 0's even if i manually write 0xAA to any location.

Here is my Gel init for PLL1 and DDR2. the DDR2 part number we are using is MT47H32M16HR-3.  I have been recalculating timings and ajusting clocks and i can't seem to get this to work....

/******************************************************************************/

/* Setup_PLL1() */

/* */

/* CLKIN = 24.576MHz cyrstal. */

/******************************************************************************/

Setup_PLL1( )

{

int PoweredDown = ((PLL1_PLLCTL & 0x00000002) >> 1);

int div1;

int div2;

int div3;

int pll1_freq;

 

GEL_TextOut("\n ***** PLL1 *****\n" );

 

/*

Step 1 - Set clock mode

*/

if( PoweredDown == 1 )

{

PLL1_PLLCTL = PLL1_PLLCTL & 0xFFFFFEFF; /* Select Onchip Oscillator */

}

 

/*

Step 2 - Set PLL to bypass and wait for PLL to stabilize

*/

PLL1_PLLCTL = PLL1_PLLCTL & 0xFFFFFFDF; /* clear PLLENSRC so PLLEN can take effect */

PLL1_PLLCTL = PLL1_PLLCTL & 0xFFFFFDFF; /* set clock source to be OSCIN */

PLL1_PLLCTL = PLL1_PLLCTL & 0xFFFFFFFE; /* Switch to bypass mode */

CPUCycleDelay( 500 ); /* Wait at least 4 CLKIN cycles(0.16uS) (150 = 6.1uS) */

 

/*

Step 3 - Reset PLL

*/

PLL1_PLLCTL = PLL1_PLLCTL & 0xFFFFFFF7; /* Start Reset of PLL1 */

 

/*

 

Step 4 - Powerup PLL

*/

if( PoweredDown == 1 )

{

PLL1_PLLCTL = PLL1_PLLCTL & 0xFFFFFFFD; /* Power up PLL */

}

 

/*

Step 5 - Load PLL multiplier

*/

PLL1_PLLM = 0x00000004; /* Set for x6 (PLLM + 1) */

 

/*

Step 6 - Load PLL dividers(1:DSP, 2:UART0, LCDC, DDR2, SPI0 3:EMIFA )

*/

while( (PLL1_PLLSTAT & 1) != 0 ); /* Wait for any previous GO operations to finish */

PLL1_PLLDIV1 = 0x00008000; /* Divide-by-1 */

PLL1_PLLDIV2 = 0x00008001; /* Divide-by-2 */

PLL1_PLLDIV3 = 0x00008002; /* Divide-by-3 */

PLL1_PLLCMD = PLL1_PLLCMD | 0x00000001; /* Set new divider values and phase alignment */

while( (PLL1_PLLSTAT & 1) != 0 ); /* Wait for GO operation to finish */

 

/*

Step 7 - Release from reset

*/

PLL1_PLLCTL = PLL1_PLLCTL | 0x00000008; /* Take PLL1 out of RESET

 

/*

Step 8 - Wait for PLL to re-lock

Step 9 - Switch from BYPASS mode to PLL mode

*/

CPUCycleDelay( 65536 ); /* Wait at least 535 cycles (PLL Lock Time) 2000/sqrt(PLLM) = 535 OSCIN CLK cycles */

PLL1_PLLCTL = PLL1_PLLCTL | 0x00000001; /* Switch to EN PLL mode */

 

pll1_freq = 24.576 * ((PLL1_PLLM & 0x0000001F) + 1);

div1 = PLL1_PLLDIV1 & 0x0000001F;

div2 = PLL1_PLLDIV2 & 0x0000001F;

div3 = PLL1_PLLDIV3 & 0x0000001F;

 

GEL_TextOut( "DDR2 = %d MHz \n",,,,, (pll1_freq / ( div1 + 1 )) );

GEL_TextOut( "SPI1 = %d MHz .... \n",,,,, (pll1_freq / ( div2 + 1 )) );

GEL_TextOut( "SYSCLK3 Phy = %d MHz .... \n",,,,, (pll1_freq / ( div3 + 1 )) );

GEL_TextOut( "[Done]\n" );

}

 

/******************************************************************************/

/* Setup_DDR2() */

/* */

/* DDR2 = 32M x 16 @ 147.46MHz */

/******************************************************************************/

Setup_DDR2( )

{

int dummy_read;

int pch_nch;

 

GEL_TextOut( "Setup DDR2 Memory Controller... ");

 

/*

Step 1 - Setup PLL2

Step 2 - Enable DDR2 PHY

*/

//shoudl already be enabled....

psc_change_state1( LPSC_DDR2, LPSC_STATE_ENABLE );

 

/*

Step 3 - Enable VTP calibration

Step 4 - Wait for VTP calibration

*/

if((VTPIO_CTL & 0x00000040))

{

DDR_VTPIOCR |= (0x00004000); // Set IOPWRDN bit to enable input buffer powerdown enable mode

DDR_VTPIOCR &= ~(0x00000040); // Clear POWERDN bit (enable VTP)

 

// Pulse (low) CLRZ to initiate VTP IO Calibration

DDR_VTPIOCR |= (0x00002000); // Set CLRZ bit

DDR_VTPIOCR &= ~(0x00002000); // Clear CLRZ bit (CLRZ should be low for at least 2ns)

CPUCycleDelay( 50 );

DDR_VTPIOCR |= 0x00002000; // Set CLRZ bit

 

while((DDR_VTPIOCR & 0x00008000) != 0x00008000); //wait for ready (bit 15)

 

DDR_VTPIOCR |= 0x00000080; // Set LOCK bit for static mode

DDR_VTPIOCR |= 0x00000100; // Set PWRSAVE bit to save power

DDR_VTPIOCR |= 0x00000040; // Set POWERDN bit to power down VTP module

}

 

/*

Step 5 alter bus priority register

*/

DDR_PBBPR = 0x00000015; // Enable the Peripheral Bus Burst Priority Register

 

/*

Step 6 - DDR2 Initialization

*/

DDR_SDCR |= 0x00800000; // Set BOOTUNLOCK

DDR_DDRPHYCR = 0x000000C3; // DLL powered up and NOT in reset, ReadLatency=3

DDR_SDCR = 0x0010C622; // Unlock Timer Regs, 16-bit bus, CAS=3, 4 banks, 1024-word page

 

//for 147.46MHz

//DDR_SDTIMR = 0x1E922A09; // DDR Timing ( set for 129.024MHz )

//DDR_SDTIMR2 = 0x3C10C722; // DDR Timing ( set for 129.024MHz )

 

//for 122.73MHz

DDR_SDTIMR = 0x1A9229C9; // DDR Timing ( set for 129.024MHz )

DDR_SDTIMR2 = 0x3C0EC722; // DDR Timing ( set for 129.024MHz )

 

 

DDR_SDCR = DDR_SDCR & 0xFFFF7FFF; // Lock Timer Regs

 

DDR_SDCR2 = 0x00000000; // IBANK_POS set to 0 so this register does not apply

DDR_SDRCR = 0xC000047E; // Refresh Control [ 7.8 usec * 147.46MHz ]

 

 

/*

Step 7 - Soft Reset ( SYNCRESET followed by ENABLE ) of DDR2 PHY

*/

psc_change_state1( LPSC_DDR2, LPSC_STATE_SYNCRESET );

psc_change_state1( LPSC_DDR2, LPSC_STATE_ENABLE );

 

DDR_SDRCR &= ~0xC0000000; // disable self-refresh

 

GEL_TextOut( "[Done]\n" );

}

  • Below are some questions I had about your DDR configuration:

    • Is this a custom board with C6748? 
    • What frequency is the DDR suppose to be operating at?
      Based on the code you provided for PLL1 initialization, it seems PLL1_SYSCLK1 is running at 24.576*(4+1) = 122.88Mhz.  Therefore, DDR is operating at 61.44Mhz.  This DDR frequency is too low. 
    • After the GEL finish executing, can you use the Excel sheet here, http://processors.wiki.ti.com/index.php/Programming_mDDR/DDR2_EMIF_on_OMAP-L1x/C674x, to parse the DDR timing registers to verify that it matches your DDR datasheet?

    --Christina

  • Yes, it is a custom board.

    i know the clock is wrong...now.  i set it too low because i thought i read the datasheet wrong.  i currently have PLLM set to 11 to get a x12. i got the DDR2 to work when i set the PLLM to x6 to get 147.456MHz, but that is only a 73MHz DDR_CLK which is too slow again.  i am trying to get as close to 150MHz as i can with the DDR_CLK, which, i hope, means the output of PLL1_SYSCLK1 needs to be as close to 300MHz as possible. i'm just rather confused as to why the DDR2 worked when i set the PLLM to x6.  the timing i set for the TIMR and TIMR2 were calculated assuming a DDR2_CLK of 147.456MHz which would mean that PLL1_SYSCLK1 needs to be 294.912MHz.

    thanks for the link to the spreadsheet. It did provide me with some slightly different values.  unfortunately it did not get my DDR2 working. i really don't understand what i am doing wrong at this point.

  • well now i am even more confused than before.  i was using the memory window as an indicator that the DDR2 was working or not.  i woudl always get ????'s.  just for the heck of it i tried to load my code and it did it!  i can load code and it seems to be operating fine for right now at the right clock..but i still can't see any of my ddr2 in the memory window.  yes i am at the right address (0xc0000000).  any ideas why that might be?

  • Did you purchase a LogicPD C6748 EVM?  If you did, can you go to the LogicPD website and download their GEL file?  Their GEL file is much easier to update b/c the DDR control registers are broken down into fields.

    If you do not have access to the LogicPD GEL file, I would then recommend using the DDR spreadsheet that you downloaded.  The first tab allows you to input the DDR datasheet values, as well as the DDR frequency.  It will then spit out the correct timing values to program into the DDR control registers.

    --Christina