-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I believe because you're not triggering adc sampling again.  Circular
DMA only means that the destination buffer will wrap around, but it
still only transfers when it's triggered.  I know you have "adc
continuous conversion mode" but I'm not sure if that's enough.  I've
never tried continuous ADC, I've normally timer triggered a sequence at
a known sample rate and let that be DMA transferred.

Cheers,
Karl P


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
> 
> ------------------------------------------------------------------------------
> 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

- -- 
Sent using Mailpile, Free Software from www.mailpile.is

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBAgAGBQJVnwXuAAoJEBmotQ/U1cr2TssP/RWKbApqxWYtMtukdkpuGRNf
aosurNydxf+6RSkZTJUWTjEf3qdwNm7/akf8AkJvwtCGUljr/vgPUk8xBefxEJK9
ytkqHFyxgvUdcP2lPCcoF2sTSqPpaJl1jLn2tNDtSRKiej9ViAoU34XGPu9GLgLJ
DaSeFTJ7W6Suupl1no2rfvhqn8Ao5BfCHkqiOeELQqzt1K2iN1slyjYj9O8mdTIP
cS14uNiyC3IRVNPLIMmEiCdsvntQWl8ikKKCqtGlgCJYRFtCAriQGmcSlO+zC4a2
0RmCYvSsqAyL8i5hOXK7iXhahTUZB5hGNH9+MczzX4o+EvBbfgH9IkhLwpcmHCcv
951SNr0SsEBEDxPQsDdHiBthg9XiiZ45UvKvGDENO4J0uxrhDpjpiB4Xt+qM2opj
RqXwvWGk3nOyQlplute7+T0wxIyVd/CCq27jU2CzTfB5Iy2dJNvQA6RQS3QcKsus
ePQfFiE8/0fhsKLuK1BZ4iDCrtIxv8b2wK7PjYN+CZly+Ljmqk2CiFixqwIPCFFS
ilc8VqesB/d4+OD5NOSoXdqek8mQhWJNYApBdpSRQoDiDl84afKDvaNK41G6s1Ro
NUwos83Fya7XqkRGcoWZdya7SopuSbK4mleLpaZ4sv2I3lSOjDaFgCYM5lBNtOFH
b0b0HYUTFwzarAfX0OXT
=bzRB
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
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