microcontroller based system design
DESCRIPTION
Microcontroller based system design. Asst. Prof. Dr. Alper ŞİŞMAN. ADC Hardware. - PowerPoint PPT PresentationTRANSCRIPT
Microcontroller based system design
Asst. Prof. Dr. Alper ŞİŞMAN
ADC Hardware• Three 12-bit analog-to-digital converters are embedded
and each ADC shares up to 16 external channels, performing conversions in the single-shot or scan mode. In scan mode, automatic conversion is performed on a selected group of analog inputs.
• The ADC can be served by the DMA controller. An analog watchdog feature allows very precise monitoring of the converted voltage of one, some or all selected channels. An interrupt is generated when the converted voltage is outside the programmed thresholds.
• To synchronize A/D conversion and timers, the ADCs could be triggered by any of TIM1, TIM2, TIM3, TIM4, TIM5, or TIM8 timer.
Temperature Sensor / VBat
• The temperature sensor has to generate a voltage that varies linearly with temperature.
• The temperature sensor is internally connected to the ADC1_IN16 input channel which is used to convert the sensor output voltage into a digital value.
ADC Hardware
STM32F405xx/STM32F407xxDatasheet
ADC Characteristics
Tempereture/Battery Sensor Characteristics
ADC Registers
Regular mode:SWSTART: ADCx->CR2 bit#30
Injected mode:JSWSTART: ADCx->CR2 bit#22
Activate ADC: ADON: ADCx->CR2 bit#0
End of conversion conntrol : EOC: ADCx->SR bit#1
End of conversion control : JEOC: ADCx->SR bit#2
Read the result when conversion ends: Regular Mode: İnjected Mode:Result DATA REGISTER: ADCx->DR Result DATA REGISTER: ADCx->JDR
Clock: ADC1: RCC->APB2ENR -> bit#8ADC2: RCC->APB2ENR -> bit#9 ADC3: RCC->APB2ENR -> bit#10
ADC Prescaler: (if needed)ADC->CCR -> bit# 17:16
Regular mode:Sequence length:SQR1: ADCx->SQR1 bit#23:20
SQR1,SQR2,SQR3: give the sequence in the desired order
Injected mode:Sequence length:JSQR: ADCx->JSQR bit#21:20
JSQR : give the sequence in the desired order
Enable temperature sensor:TSVREFE: ADC->CCR bit#23
Single conversion mode operation
Cont. conversion mode operation
Continious conversion:CONT: ADCx->CR2 bit#1
Timing Diagram
Analog watchdog:ADCx->HTR: High thresholdADCx->LTR: Low thresholdAWDEN: ADCx->CR1 bit#23AWDSGL: ADCx->CR1: bit#9AWDCH: ADCx->CR1 bit#4:0
Injected Channels:JAWDEN: ADCx->CR1 bit#22
SCAN: ADCx->CR1 bit#8
Channelx sampling time selection:ADCx->SMPR1ADCx->SMPR2ADCx->SMPR3
Wrıte the proper setting to the area of channel which will be set.