1. 程式人生 > >STM32 ADC 解讀

STM32 ADC 解讀

(1)啟動停止

The ADC can be powered-on by setting the ADON bit in the ADC_CR2 register.

When the ADON bit is set for the first time, it wakes up the ADC from Power Down mode

Conversion starts when ADON bit is set for a second time by software after ADC power-up time (tSTAB).(相當於第一次置位ADON是power on  adc module,第二次置位ADON才是啟動ADC轉換)

reset ADON bit 就停止ADC功能,停止後功耗很低,幾個微安。

(2)時鐘

ADC clock 來自PCLK2,(APB2), RCC controller 有專用的ADC prescaler

(3)通道

16路multiplexed channels

AD轉換分為2組類別:regular group  and injected group<轉換先後順序、轉換數量設定>

regular group 由最多16個conversions組成,their order in the conversion sequence must be selected in the ADC_SQRx registers

The total number of conversions in the regular group must be written in the L[3:0] bits inthe ADC_SQR1 register

injected group 由最多4個conversion組成,the injected channels andtheir order in the conversion sequence must be selected in the ADC_JSQR register.The total number of conversions in the injected group must be written in the L[1:0] bits in the ADC_JSQR register.

(4)STM32內建的溫度感測器被置於ADC module<只在ADC1>,

連線到 ADCx_IN16,而內部參考電壓連線到ADCx_IN17。這兩個channel可以被設定為 injected channel 或 regular channel

The Temperature sensor is connected to channel ADCx_IN16 and the internal reference voltage VREFINT is connected to ADCx_IN17. These two internal channels can be selected and converted as injected or regular channels.

(5)單次轉換模式 CONT bit =0

通過置位ADON bit 觸發轉換(僅限 regular channel),還有通過外部觸發轉換。DATA REG , EOC BIT ,EOCIE

轉換結束後,AD功能自動停止。

(6)連續轉換模式 CONT bit =1

通過 ADON觸發,或者外部觸發轉換

啟動轉換操作方式跟單次的一樣

(7)ADC 初始化完後,要一個等待時間。

he ADC needs a stabilization time of tSTAB before it starts converting accurately.

(8)analog watchdog

analog watchdog status bit will be set ,if 低於或高過設定的閥值電壓。

在ADC_CR1中選擇通道。

hese thresholds are programmed in the 12 least significant bits of the ADC_HTR and ADC_LTR 16-bit registers

若AWDIE被設定1,則會產生中斷。

(9)scan mode

this mode is used to scan a group of analog channels

比較複雜,必須使用DMA,暫不深入。