Sine Wave To DAC Using FRDM K64

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sine Wave To DAC Using FRDM K64

2,012 Views
oliviachristyva
Contributor III

Hi guys,

I am using FRDM K64f to generate a sine wave and give it as the input of DAC and receive a signal with 4.8mv amplitude at the DAC OUT. I generated a sine wave signal and gave to DAC input and received a sine wave at the DAC OUT with 1.65 v   amplitude . I am using processor expert with IAR.

I want to reduce the amplite of the signal to 4.8mv .How is it possible with the code. 

This is my code

static const LDD_DAC_TData SinusOutputData[SINUS_LENGTH] = {
2047U, 2097U, 2147U, 2198U, 2248U, 2298U, 2347U, 2397U, 2446U, 2496U, 2544U, 2593U, 2641U, 2689U,
2737U, 2784U, 2830U, 2877U, 2922U, 2967U, 3012U, 3056U, 3099U, 3142U, 3184U, 3226U, 3266U, 3306U,
3346U, 3384U, 3422U, 3458U, 3494U, 3530U, 3564U, 3597U, 3629U, 3661U, 3691U, 3721U, 3749U, 3776U,
3803U, 3828U, 3852U, 3875U, 3897U, 3918U, 3938U, 3957U, 3974U, 3991U, 4006U, 4020U, 4033U, 4044U,
4055U, 4064U, 4072U, 4079U, 4084U, 4088U, 4092U, 4093U, 4094U, 4093U, 4092U, 4088U, 4084U, 4079U,
4072U, 4064U, 4055U, 4044U, 4033U, 4020U, 4006U, 3991U, 3974U, 3957U, 3938U, 3918U, 3897U, 3875U,
3852U, 3828U, 3803U, 3776U, 3749U, 3721U, 3691U, 3661U, 3629U, 3597U, 3564U, 3530U, 3494U, 3458U,
3422U, 3384U, 3346U, 3306U, 3266U, 3226U, 3184U, 3142U, 3099U, 3056U, 3012U, 2967U, 2922U, 2877U,
2830U, 2784U, 2737U, 2689U, 2641U, 2593U, 2544U, 2496U, 2446U, 2397U, 2347U, 2298U, 2248U, 2198U,
2147U, 2097U, 2047U, 1997U, 1947U, 1896U, 1846U, 1796U, 1747U, 1697U, 1648U, 1598U, 1550U, 1501U,
1453U, 1405U, 1357U, 1310U, 1264U, 1217U, 1172U, 1127U, 1082U, 1038U, 995U, 952U, 910U, 868U,
828U, 788U, 748U, 710U, 672U, 636U, 600U, 564U, 530U, 497U, 465U, 433U, 403U, 373U,
345U, 318U, 291U, 266U, 242U, 219U, 197U, 176U, 156U, 137U, 120U, 103U, 88U, 74U,
61U, 50U, 39U, 30U, 22U, 15U, 10U, 6U, 2U, 1U, 0U, 1U, 2U, 6U,
10U, 15U, 22U, 30U, 39U, 50U, 61U, 74U, 88U, 103U, 120U, 137U, 156U, 176U,
197U, 219U, 242U, 266U, 291U, 318U, 345U, 373U, 403U, 433U, 465U, 497U, 530U, 564U,
600U, 636U, 672U, 710U, 748U, 788U, 828U, 868U, 910U, 952U, 995U, 1038U, 1082U, 1127U,
1172U, 1217U, 1264U, 1310U, 1357U, 1405U, 1453U, 1501U, 1550U, 1598U, 1648U, 1697U, 1747U, 1796U,
1846U, 1896U, 1947U, 1997U
};

for (i = 0; i < SINUS_LENGTH; i++) {

//SinusOutputData[i] = 4096-SinusOutputData[i];
DA0_SetValue(MyDacPtr, (SinusOutputData[i])); /* Set converter output */
}

Please help...

Thanks and Regards,

olivia

0 Kudos
Reply
4 Replies

1,309 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Olivia,

I suppose that you want to output a sine waveform on the DAC pin, if it is the case, the general method is to use PDB generate trigger signal to trigger DAC, so that the DAC can output sine waveform, the frequency of the sine waveform is only dependent on the PDB setting.

Regarding your current issue, I suppose that the DAC only output the last value of the sine table, which is 1997*Vref/4096=(3.3V*1997)/4096=4.8mV. In other words, you can not use a loop to output the sine table.

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply

1,309 Views
oliviachristyva
Contributor III

Hi Mark,

Thank you so much for your answer. Now I am  getting 7.5mv at the DAC OUT when vref is external (vdd) and 2.2mv when vref is internal .Can you tell me how do you calculated this value. I have to get 4.8mv at the output.

Thanks and Regards,

Olivia

0 Kudos
Reply

1,309 Views
mjbcswitzerland
Specialist V

Hi

0.0048/1.65 = 1/344

If it is too high, it is probably noise - you can simply try dividing more by

4.8/7.5

giving 1/538

If it doesn't react as much as you expect it is really noise that you are measuring and limiting the operation.

Regards

Mark

0 Kudos
Reply

1,309 Views
mjbcswitzerland
Specialist V

for (i = 0; i < SINUS_LENGTH; i++) {

//SinusOutputData[i] = 4096-SinusOutputData[i];
DA0_SetValue(MyDacPtr, (SinusOutputData[i]/344)); /* Set converter output */
}

0 Kudos
Reply