Intel
®
81341 and 81342 I/O Processors
December 2007
Developer’s Manual
Order Number: 315037-002US
669
DDR SDRAM Memory Controller—Intel
®
81341 and 81342
7.8.36.1.1 DLLRCVREN Algorithm
#define MCU_DLLRCVER ((volatile unsigned int *) 0xffd82030)
#define MCU_SDCR0 ((volatile unsigned int *) 0xffd81804)
int compute_dllrcver(void)
{
int dllrcver_value, dqs_value, treg, fine, coarse;
int inverted_dqs_value, direction_value;
unsigned int sdcr0_val;
*MCU_DLLRCVER &= ~(1<<18); /* Clear bit 18 to clear Result bit */
dllrcver_value = 0x50;
/* Set Initial Value of DLLRCVER Delay using a
recommended initial value */
dqs_value = sample_dqs(dllrcver_value); /* Take first sample of DQS with
current DLLRCVER Delay */
/* Set direction and compare value to find next edge */
inverted_dqs_value = (dqs_value == 0) ? 1 : 0;
direction_value = (dqs_value == 0) ? +1 : -1; /* look for rising edge */
do {
dllrcver= direction_value;
dqs_value = sample_dqs(dllrcver_value);
if (dqs_value <= 0 || dqs_value >= 255)
return -1; // something went wrong
} while (dqs_value != inverted_dqs_value);
/* Verify if the DQS edge found above is the second DQS edge, and
adjust DLLRCVER Value if it was indeed the second edge */
if (dllrcver_value >= 0x30 && sample_dqs(dllrcver_value - 0x30))
dllrcver_value -= 0x40; // Shift back to first edge