Hi All,
I am struggling a bit with the Sinus demo conversion between the old DMA example included in the PE documentation and the new DMA method. I am *almost* there, but not quite.
I copied the Sinus table and interrupt code right from the Demo:
In events.c:
void DA1_OnComplete(LDD_TUserData *UserDataPtr)
{
/* Write your code here ... */
static uint8_t ArrayPageCntr = 0U;
DA1_SetBuffer(MyDacPtr, &Sinus[ArrayPageCntr*16U], 16U, 0U);
(ArrayPageCntr < 15) ? (ArrayPageCntr++):(ArrayPageCntr = 0);
}
And in my int_dac.c:
uint16_t Sinus[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
};
LDD_TError Error;
LDD_TDeviceData *MyDacPtr;
void DAC_init(void)
{
MyDacPtr = DA1_Init(NULL);
}
I have the DAC set up exactly the same way as in the documentation, with a 16-word Hardware Buffer with a Hardware Trigger from the PDB. The DAC hardware appears to be working just fine, and I get signal out. I get regular complete interrupts for the DMA as well. It just seems my DMA setup is incorrect as the last 2 words written to the DAC output appear to be delayed and present the incorrect data, though it is still altered data from the DAC hardware table.
I have screen caps of my settings in DMA Help.pdf if anyone cares to take a look, as well as a scope image to display what I am seeing. The "glitches" in the sinusoidal waveform are the last two samples sent according to setting the breakpoint in the DA1_OnComplete() event.
The root of what I need:
16 2-byte values copied into the DAC hardware buffer from my Sinus[] table every time the DAC has completed sending out the last 16 2-byte values and increment source buffer to the next 16 2-byte value. At the end of the source buffer (multiple of 16) I rotate back to the beginning of the table.
Ideally I don't even want the interrupt to need to move things to the next 16 2-byte values in my Sinus[] table, and return to the top of the table all on its own. I see some checks that may do that, but they don't seem to account for the total table size?
Thank you for any help. New to using DMAs, I never had the luxury before.