Use PWM to trigger the DAC to output voltage, using DMA to transfer Data to DAC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

Design in PSoC Creator

The design shown in Figure 1 implements continuous updating of the VDAC Component’s output voltage using DMA; the TCPWM block generates the DAC update mode “Strobe edge sync” signals. The DMA transfers are initiated by a trigger signal generated by the previous update’s completion. The VDAC Component is placed into an available CTDAC hardware block and the output voltage waveform is routed to pin P9[6]. An oscilloscope connected to pin P9[6] can display the waveform as Figure 2 below.

Figure 1. PSoC Creator Component Schematic

LinglingG_46_0-1630307791176.png

 

Figure 2. The test result:

LinglingG_46_1-1630307791179.png

 

 

How to design it in Modus Toolbox 2.3:

The same function that develops in MTB has 2 key points that need to solve.

1: The “Strobe edge sync” DAC update mode is NOT configurable in “Device config”.

LinglingG_46_2-1630307791183.png

 

So, we should re-config it in the “ctdac_cofig” struct like below, pay attention to update Mode

const cy_stc_ctdac_config_t DAC_config_ring =

{

    .refSource = CY_CTDAC_REFSOURCE_VDDA,

    .formatMode = CY_CTDAC_FORMAT_UNSIGNED,

    .updateMode = CY_CTDAC_UPDATE_STROBE_EDGE_SYNC,

    .deglitchMode = CY_CTDAC_DEGLITCHMODE_UNBUFFERED,

    .outputMode = CY_CTDAC_OUTPUT_VALUE,

    .outputBuffer = CY_CTDAC_OUTPUT_UNBUFFERED,

    .deepSleep = CY_CTDAC_DEEPSLEEP_DISABLE,

    .deglitchCycles = 0x22u,

    .value = 0,

    .nextValue = 0,

    .enableInterrupt = true,

    .configClock = false,

    .dividerType = CY_SYSCLK_DIV_8_BIT,

    .dividerNum = 0,

    .dividerIntValue = 0,

    .dividerFracValue = 0,

};

2: TCPWM overflow connect to DAC strobe:

Now the Modus Toolbox 2.3 doesn’t support the UDB DSI config, essentially, all functions are registers configuration, so we need to copy the corresponding file from IDE PSoC Creator to Modus Toolbox.

Steps to transplant this function, copy the file “cydevice_trm.h” and copy the UDB DSI config part from the “cyfitter_cfg.c” to the Modus Toolbox project.

See my project's new API which names “custom_UDB_DSI_Config()”.

For the “DAC, TCPWM, DMA” driver code, see the attached project.

0 Replies