7 HAL ADC Generic Driver

Started by tha, June 28, 2022, 08:51:00 AM

Previous topic - Next topic

tha

7   HAL ADC Generic Driver

7.1   ADC Firmware driver registers structures

7.1.1   ADC_InitTypeDef
ADC_InitTypeDef ถูกกหนดใน the stm32f1xx_hal_adc.h
Data Fields
•   uint32_t DataAlign
•   uint32_t ScanConvMode
•   FunctionalState ContinuousConvMode
•   uint32_t NbrOfConversion
•   FunctionalState DiscontinuousConvMode
•   uint32_t NbrOfDiscConversion
•   uint32_t ExternalTrigConv
   

tha

Field Documentation
•   uint32_t ADC_InitTypeDef::DataAlign
     ระบุ ADC data alignment ไปทางขวาt (MSB บน register bit 11 และ LSB บน register bit 0) (การเซ็ตโดยเริ่มต้น) หรือไปทาง
     ซ้าย (ถ้า regular group: MSB บน register bit 15 และ LSB บน register bit 4, ถ้า injected group (MSB ถูกเก็บเป็นค่า
     เครื่องหมายเนื่องจากค่าลบที่อาจเกิดขึ้นหลังจากการประยุกต์ใช้ออฟเซ็ตแล้ว): MSB บน register bit 14 และ LSB บน register bit 3).
     parameter นี้สามารถเป็นค่าของ ADC_Data_align

tha

•   uint32_t ADC_InitTypeDef::ScanConvMode
     กำหนดค่าตัวจัดลำดับของ regular and injected groups. parameter นี้สามารถสัมพันธ์กับ parameter
     'DiscontinuousConvMode' เพื่อให้มี main sequence ถูกแบ่งย่อยเป็นส่วนที่ต่อเนื่องหลายส่วน. ถ้าปิดใช้งาน: การแปลงถูกดำเนิน
     การใน single mode (one channel ที่แปลง, ตัวหนึ่งที่กำหนดใน rank 1). Parameters 'NbrOfConversion' และ
     'InjectedNbrOfConversion' ถูกทิ้ง (เทียบเท่ากับเซ็ตเป็น 1). ถ้าเปิดใช้งาน: Conversions ถูกดำเนินการใน sequence mode
     (หลาย ranks ที่กำหนดโดย 'NbrOfConversion'/'InjectedNbrOfConversion' และแต่ละ channel rank). Scan direction จะ
     ขึ้นสูง: จาก rank1 ถึง rank 'n'. parameter นี้สามารถเป็นค่าของ ADC_Scan_mode โปรดทราบว่า: สำหรับ regular group,
     parameter นี้ควรถูกเปิดใช้งานใน conversion อย่างใดอย่างหนึ่งโดย polling (HAL_ADC_Start ด้วย Discontinuous mode
     และ NbrOfDiscConversion=1) หรือโดย DMA (HAL_ADC_Start_DMA), แต่ไม่ใช่โดย interruption
     (HAL_ADC_Start_IT): ใน scan mode, interruption จะถูกทริกเฉพาะบน the last conversion of the sequence. การแปลง
     ก่อนหน้าทั้งหมดจะถูกเขียนทับโดยการแปลงสุดท้าย. Injected group ที่ใช้พร้อมด้วย scan mode ไม่มีข้อจำกัดนี้: แต่ละ rank มี
     result register ของตัวเอง, ไม่มี data ถูกเขียนทับ.


tha

•   FunctionalState ADC_InitTypeDef::ContinuousConvMode
     ระบุ่า the conversion ถูกดำเนินการใน single mode (one conversion) หรือ continuous mode สำหรับ regular group, หลัง
     จาก the selected trigger เกิดขึ้น (software start หรือ external trigger). parameter นี้สามารถถูกเซ็ตเป็น ENABLE หรือ
     DISABLE.
•   uint32_t ADC_InitTypeDef::NbrOfConversion
     ระบุ the number of ranks ที่จะถูกแปลงภายใน the regular group sequencer. เพื่อใช้ regular group sequencer และแปลง
     หลาย ranks, parameter 'ScanConvMode' ต้องถูกเปิดใช้งาน. parameter นี้ต้องเป็นจำนนระหว่าง Min_Data = 1 and
     Max_Data = 16.

tha

•   FunctionalState ADC_InitTypeDef::DiscontinuousConvMode
     ระบุว่า the conversions sequence of regular group ถูกดำเนินการใน Complete-sequence/Discontinuous-sequence
     (main sequence ถูกแบ่งย่อยเป็นส่วนที่ต่อเนื่องหลายส่วน). Discontinuous mode ถูกใช้เฉพาะถ้า sequencer ถูกเปิดใช้งาน
     (parameter 'ScanConvMode'). ถ้า sequencer ถูกปิดใช้งาน, parameter จะถูกทิ้ง. Discontinuous mode สามารถถูกเปิดใช้งาน
     เฉพาะถ้า continuous mode ถูกปิดใช้งาน. ถ้า continuous mode ถูกเปิดใช้งาน, parameter setting นี้จะถูกทิ้ง. parameter นี้
     สามารถถูกเซ็ตเป็น ENABLE or DISABLE.

tha

•   uint32_t ADC_InitTypeDef::NbrOfDiscConversion
     ระบุ the number of discontinuous conversions ซึ่ง the main sequence of regular group (parameter
     NbrOfConversion) จะถูกแบ่งย่อย. ถ้า parameter 'DiscontinuousConvMode' ถูกปิดใช้งาน, parameter นี้จะถูกทิ้ง.
     parameter นี้ต้องเป็นจำนวนระหว่าง Min_Data = 1 and Max_Data = 8.
•   uint32_t ADC_InitTypeDef::ExternalTrigConv
     เลือก the external event ที่ใช้เพื่อทริก the conversion start of regular group. ถ้าเซ็ตเป็น ADC_SOFTWARE_START,
     external triggers จะถูกปิดใช้งาน. ถ้าเซ็ตเป็น external trigger source, triggering จะอยู่บน event rising edge. parameter นี้
    สามารถเป็นค่าของ ADC_External_trigger_source_Regular

moneyp1000

มาติดตามอ่านอยู่ครับ

tha

7.1.2 ADC_ChannelConfTypeDef
ADC_ChannelConfTypeDef ถูกกำหนดใน the stm32f1xx_hal_adc.h
Data Fields
•   uint32_t Channel
•   uint32_t Rank
•   uint32_t SamplingTime


Field Documentation
•   uint32_t ADC_ChannelConfTypeDef::Channel
     ระบุ the channel เพื่อกำหนดค่าลงใน ADC regular group. parameter นี้สามารถเป็น a value of ADC_channels หมายเหตุ:
     ขึ้นอยู่กับ devices, บาง channels อาจไม่มีให้ใช้งานบน package pins. ดูที่ device datasheet สำหรับ channels ที่มีให้ใช้งาน.
     หมายเหตุ: บน STM32F1 devices ที่มีหลาย ADC: เฉพาะ ADC1 สามารถเข้าถึง internal measurement channels
     (VrefInt/TempSensor) หมายเหตุ: บน STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch
     อาจถูกสร้าง (บน ADC input 0) บน the PA0 pin, เมื่อ the ADC กำลังแปลงด้วย injection trigger. ขอแนะนำให้กระจาย the
     analog channels เพื่อให้ Channel 0 ถูกกำหนดค่าเป็น an injected channel. ดูที่ errata sheet ของ devices เหล่านี้สำหรับ
     รายละเอียดเพิ่มเติม.