Closed Matt-Lemcke closed 2 years ago
Enable ADC1 clk, enable GPIOx clk. Set GPIO pin in analog mode Set ADC prescalar (from APB2 source). Set continuous conversion, EOC after each conversion, data alignment LEFT. Set sampling time to 3 cycles. Set one conversion in regular sequence, assign channel as 1st conversion. Set sampling frequency. Set TSVREFE bit to wait sensor. Enable DMA in CR2 register. Enable continuous request.
Enable ADC (ADON=1). Wait at least 10us.
Enable DMA clock. Set peripheral to memory stream CIRC = 1. MINC = 1. Set PSIZE and MSIZE for size of data (16 bit) Select channel for stream (find in datasheet)
Set size of DMA stream transfer size. Set source address as peripheral address. Set destination address as memory location of buffer variable. Enable dma stream.
ADC clear SR register. Start conversion (SWSTART = 1)
Read values through buffer variable when needed
ADC1 uses DMA2, stream 0, channel 0
Configure ADC to capture input