Out of curiosity, what is with the QK_ISR_ENTRY and QK_ISR_EXIT macros?

Have you checked if you need to re-enable DMA after it completes a cycle?

On Thu, Jul 9, 2015 at 2:23 PM, Bernard Mentink <bment...@gmail.com> wrote:
> Hi All,
>
> I am trying to get adc conversions put in an array via the dma module.
> It works once on power on, i.e the array gets filled and the end-of-transfer
> interrupt goes off, but even though the dma is put in "circular" mode,
> nothing further happens.
>
> The relevant code is:
>
> -----------------------------------------------------------------------------------------------------------
> void setup_adc(uint32_t adc, uint32_t channels, uint8_t *channel_array)
> {
>     adc_disable_external_trigger_regular(adc);
> adc_set_right_aligned(adc);
>     adc_set_sample_time_on_all_channels(adc, ADC_SMPR_SMP_3CYC);
> adc_enable_scan_mode(adc);
>
> adc_power_on(adc);
>
> /* Wait for ADC starting up. */
> int i;
> for (i = 0; i < 800000; i++)    /* Wait a bit. */
> __asm__("nop");
>
>     // adc_reset_calibration(adc); adc_calibration(adc);
>
> adc_set_regular_sequence(adc, channels, channel_array);
> adc_set_continuous_conversion_mode(adc);
>     /***** Start conversion (in simultaneous-mode only adc to be triggered)
> *****/
>     adc_start_conversion_regular(adc);
>
> }
>
> void setup_adc_dma(uint32_t adc, uint32_t channels, uint8_t *channel_array,
> uint16_t *buff, uint32_t nsamples)
> {
> rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);
>
> /* setup DMA */
> rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_DMA2EN);
>
> /* Make sure the ADC doesn't run during config. */
> adc_off(adc);
>
> dma_stream_reset(DMA2, DMA_STREAM0);
>
> dma_set_peripheral_address(DMA2, DMA_STREAM0, (uint32_t) &ADC_DR(adc));
> dma_set_memory_address(DMA2, DMA_STREAM0, (uint32_t) buff);
> dma_enable_memory_increment_mode(DMA2, DMA_STREAM0);
> dma_set_peripheral_size(DMA2, DMA_STREAM0, DMA_SxCR_PSIZE_16BIT);
> dma_set_memory_size(DMA2, DMA_STREAM0, DMA_SxCR_MSIZE_16BIT);
> dma_set_priority(DMA2, DMA_STREAM0, DMA_SxCR_PL_LOW);
>
> dma_enable_transfer_complete_interrupt(DMA2, DMA_STREAM0);
> //dma_enable_half_transfer_interrupt(DMA2, DMA_STREAM0);
> dma_set_number_of_data(DMA2, DMA_STREAM0, nsamples);
> dma_enable_circular_mode(DMA2, DMA_STREAM0);
> dma_set_transfer_mode(DMA2, DMA_STREAM0,DMA_SxCR_DIR_PERIPHERAL_TO_MEM);
> dma_channel_select(DMA2, DMA_STREAM0, DMA_SxCR_CHSEL_0);
>
> dma_enable_stream(DMA2, DMA_STREAM0);
> adc_enable_dma(adc);
>
> setup_adc(adc, channels, channel_array);
> }
>
> void dma2_stream0_isr(void)  /* ADC1 dma interrupt */
> {
> volatile uint16_t tmp;
>
> QK_ISR_ENTRY();
>
> if (dma_get_interrupt_flag(DMA2, DMA_STREAM0, DMA_TCIF)) {
> dma_clear_interrupt_flags(DMA2, DMA_STREAM0, DMA_TCIF);
> tmp = adc_data[0]; tmp += 2;
> }
>
> QK_ISR_EXIT();
> }
> -----------------------------------------------------------------------------------------------------------------
>
> Anyone see how to get the a2d conversions/DMA transfer to happen continuous?
>
> Thanks,
> Bernie
>
> --
> -----------------------------------------------------------------------------------------------------------------------------------------
> People born in the 50's have lived
> in seven decades.
> two centuries,
> and two millenniums.
> We had the best music, fastest cars, drive-in theaters, soda fountains, and
> happy days.
> And we are not even that old yet.
> We're just that cool.
> ----------------------------------------------------------------------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> libopencm3-devel mailing list
> libopencm3-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libopencm3-devel
>

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
libopencm3-devel mailing list
libopencm3-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libopencm3-devel

Reply via email to