Post Go back to editing

How to write successfully user data to RAM in AD9957

Hi,

It seems that this issue has already been raised at this forum. Unfortunately, even though I tried to follow exactly the suggested steps I couldn't get the data successfully delivered to the memory in AD9957. In particular, I'm not sure how to organize the sequence of signals during RAM loading. I tried as follows:

1. CS = low

2. Send RAM address (0x16)

3. Send N 32-bit words one after another (with I/O_Update issued after each of them)

4. CS = high

Sometimes, I see that the first bit is changed but all the other are unaffected by the above procedure.

I will appreciate any suggestions.

Bartek

Parents
  • Regarding RAM size, I have erroneously copied to the forum RAM0 settings (it was correct). Anyway, now that I have included your suggestions my code is as follows:

     

    /CS = 1
    SCLK = 1
    MASTER_RESET = 1
    MASTER_RESET = 0

    I/O_RESET = 1
    I/O_RESET = 0
    /CS = 0

    //CFR1 settings:
    0x00
    0x01000002
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //CFR2 settings:
    0x01
    0x00400020
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //CFR3 settings:
    0x02
    0x113f0100
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //PROFILE0 settings:
    0x0e
    0x0480000000000000
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //RAM Segment Register 0 settings:
    0x05
    0x0001ffc00004

    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    RT = 0
    RT = 1

    0x00
    0x9f000002

    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    0x16

     

    (here I put 1024 of 32 words one after another without I/O updates between)

     

    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    /CS = 1

    RT = 0
    RT = 1

     

    Now, I see some strange relation between my writing to RAM and the generated signal.

    If I put simply zeros, there is nothing generated and this is obviously ok.

    However, I don't know how to load RAM, let say, with a cosine function. I tried this way:

     

    unsigned short RAMvalue = 0x0000;
    float tmp = 0.0;

    for (int i = 0; i < 1024; i++)
    {
    tmp = cos(8*3.14159*i/1024);
    if (tmp>=0)
       RAMvalue = ((unsigned short) tmp) & 0xefff; //two's complement (positive)
    else{
       tmp = -tmp;
       RAMvalue = ((unsigned short) tmp) | 0x8000; //two's complement (negative)

    }
    RAMdata.bits31_16 = RAMvalue; //I-path
    RAMdata.bits15_0 = 0x0000; //Q-path

    AD9957_send_register_AD9957_RAM(AD9957_RAM, &RAMdata, sizeof(RAMdata));
    }

     

    Unfortunately, it does not work correctly. When I change the frequency in the cosine function above, the shape of pulses (yes, I get pulses instead of cosine) is exactly the same but their repetition is changing only! I'm afraid it has something to do with my erroneous understanding of memory split into I/Q paths sequence in the interpolating DAC mode and the way two's complement is functioning. One way or another, could you propose some exemplary sequency? Thank you in advance.

Reply
  • Regarding RAM size, I have erroneously copied to the forum RAM0 settings (it was correct). Anyway, now that I have included your suggestions my code is as follows:

     

    /CS = 1
    SCLK = 1
    MASTER_RESET = 1
    MASTER_RESET = 0

    I/O_RESET = 1
    I/O_RESET = 0
    /CS = 0

    //CFR1 settings:
    0x00
    0x01000002
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //CFR2 settings:
    0x01
    0x00400020
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //CFR3 settings:
    0x02
    0x113f0100
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //PROFILE0 settings:
    0x0e
    0x0480000000000000
    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    //RAM Segment Register 0 settings:
    0x05
    0x0001ffc00004

    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    RT = 0
    RT = 1

    0x00
    0x9f000002

    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    0x16

     

    (here I put 1024 of 32 words one after another without I/O updates between)

     

    I/O_UPDATE = 0
    I/O_UPDATE = 1
    I/O_UPDATE = 0

    /CS = 1

    RT = 0
    RT = 1

     

    Now, I see some strange relation between my writing to RAM and the generated signal.

    If I put simply zeros, there is nothing generated and this is obviously ok.

    However, I don't know how to load RAM, let say, with a cosine function. I tried this way:

     

    unsigned short RAMvalue = 0x0000;
    float tmp = 0.0;

    for (int i = 0; i < 1024; i++)
    {
    tmp = cos(8*3.14159*i/1024);
    if (tmp>=0)
       RAMvalue = ((unsigned short) tmp) & 0xefff; //two's complement (positive)
    else{
       tmp = -tmp;
       RAMvalue = ((unsigned short) tmp) | 0x8000; //two's complement (negative)

    }
    RAMdata.bits31_16 = RAMvalue; //I-path
    RAMdata.bits15_0 = 0x0000; //Q-path

    AD9957_send_register_AD9957_RAM(AD9957_RAM, &RAMdata, sizeof(RAMdata));
    }

     

    Unfortunately, it does not work correctly. When I change the frequency in the cosine function above, the shape of pulses (yes, I get pulses instead of cosine) is exactly the same but their repetition is changing only! I'm afraid it has something to do with my erroneous understanding of memory split into I/Q paths sequence in the interpolating DAC mode and the way two's complement is functioning. One way or another, could you propose some exemplary sequency? Thank you in advance.

Children
No Data