Configure the DMA for Compare TCC Channel 0

Configure the DMAC module to update TCC channel 0 compare value. The flow is similar to last DMA configure step for capture.
  1. Allocate and configure the DMA resource.
    struct dma_resource compare_dma_resource;
    
    struct dma_resource_config config;
    dma_get_config_defaults(&config);
    config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
    config.peripheral_trigger = CONF_COMPARE_TRIGGER;
    dma_allocate(&compare_dma_resource, &config);
    
  2. Prepare DMA transfer descriptor.
    COMPILER_ALIGNED(16) DmacDescriptor compare_dma_descriptor;
    
    struct dma_descriptor_config descriptor_config;
    
    dma_descriptor_get_config_defaults(&descriptor_config);
    
    descriptor_config.block_transfer_count = 3;
    descriptor_config.beat_size = DMA_BEAT_SIZE_HWORD;
    descriptor_config.dst_increment_enable = false;
    descriptor_config.source_address =
            (uint32_t)compare_values + sizeof(compare_values);
    descriptor_config.destination_address =
            (uint32_t)&CONF_PWM_MODULE->CC[CONF_PWM_CHANNEL];
    
    dma_descriptor_create(&compare_dma_descriptor, &descriptor_config);
    
  3. Start DMA transfer job with prepared descriptor.
    dma_add_descriptor(&compare_dma_resource, &compare_dma_descriptor);
    dma_add_descriptor(&compare_dma_resource, &compare_dma_descriptor);
    dma_start_transfer_job(&compare_dma_resource);
    
  4. Enable the TCC module to start the timer and begin PWM signal generation.
    tcc_enable(&tcc_instance);