STM32F7 15 Analog-to-digital converter (ADC)

Started by tha, September 01, 2022, 06:48:47 AM

Previous topic - Next topic

tha

15.6 Conversion on external trigger and trigger polarity

Conversion สามารถถูกทริกโดย an external event (เช่น timer capture, EXTI line). ถ้า the EXTEN[1:0] control bits (สำหรับ a regular conversion) หรือ JEXTEN[1:0] bits (สำหรับ an injected conversion) แตกต่างจาก "0b00", จากนั้น external events จะสามารถทริก a conversion ด้วย the selected polarity. Table 95 จัดให้มีความตรงกันระหว่าง the EXTEN[1:0] และ JEXTEN[1:0] values และ the trigger polarity.

Note: The polarity of the external trigger สามารถถูกเปลี่ยนได้ทันที.

The EXTSEL[3:0] and JEXTSEL[3:0] control bits ถูกใช้เพื่อเลือกจาก 16 possible events ที่สามารถทริก conversion สำหรับ the regular และ injected groups.

Table 96 ให้ the possible external trigger สำหรับ regular conversion.


Table 97 ให้ the possible external trigger สำหรับ injected conversion.


Software source trigger events สามารถถูกสร้างโดยการเซ็ต SWSTART (สำหรับ regular conversion) หรือ JSWSTART (สำหรับ injected conversion) ใน ADC_CR2.

A regular group conversion สามารถถูกอินเตอร์รัพท์โดย an injected trigger.

Note: The trigger selection สามารถถูกเปลี่ยนได้ทันที อย่างไรก็ตาม, เมื่อ the selection เปลี่ยน, จะมีกรอบเวลา 1 APB clock cycle
         ในระหว่างที่ the trigger detection ถูกปิดใช้งาน. นี้เพื่อหลีกเลี่ยง spurious detection ในระหว่าง transitions.

tha

15.7 Fast conversion mode

มันสามารถเป็นได้ที่จะดำเนินการ faster conversion โดยการลด the ADC resolution. The RES bits ถูกใช้เพื่อเลือกจำนวนของ bits มีให้ใช้งานใน the data register. The minimum conversion time สำหรับแต่ละ resolution เป็นดังต่อไปนี้:
•   12 bits: 3 + 12 = 15 ADCCLK cycles
•   10 bits: 3 + 10 = 13 ADCCLK cycles
•   8 bits: 3 + 8 = 11 ADCCLK cycles
•   6 bits: 3 + 6 = 9 ADCCLK cycles

tha

15.8 Data management

15.8.1 Using the DMA

เนื่องจากการแปลง regular channel values จะถูกเก็บลงใน a unique data register, มันจะมีประโยชน์ที่จะใช้ DMA สำหรับ conversion ของมากกว่าหนึ่ง regular channel. นี้หลีกเลี่ยงการสูญหายของ the data ที่ถูกเก็บใน the ADC_DR register แล้ว.

เมื่อ the DMA mode ถูกเปิดใช้งาน (DMA bit ถูกเซ็ตเป็น 1 ใน the ADC_CR2 register), หลังจากแต่ละ conversion ของ a regular channel, a DMA request ถูกสร้างขึ้น. นี้ยอมให้ the transfer ของ the converted data จาก the ADC_DR register ไปยัง the destination location ที่เลือกโดย the software.


tha

อย่างไรก็ตาม, ถ้า data สูญหาย (overrun), the OVR bit ใน the ADC_SR register จะถูกเซ็ตและ an interrupt ถูกสร้างขึ้น (ถ้า the OVRIE enable bit ถูกเซ็ต). DMA transfers ดังนั้นถูกปิดใช้งานและ DMA requests ไม่ถูกยอมรับอีกต่อไป. ในกรณีนี้, ถ้า a DMA request ถูกทำ, the regular conversion ที่กำลังดำเนินการอยู่จะถูกทิ้งและ regular triggers อันต่อไปจะถูกเพิกเฉย. ดังนั้นจำเป็นต้องเคลียร์ the OVR flag และ the DMAEN bit ใน the used DMA stream, และเพื่อเริ่มต้นใหม่ทั้ง the DMA และ the ADC เพื่อที่ the wanted converted channel data ถูกส่งถ่ายไปยัง the right memory location. เท่านั้นจึงจะสามารถ the conversion ถูกทำให้กลับคืนมาทำงานต่อและ the data transfer, ถูกเปิดใช้งานอีกครั้ง. Injected channel conversions ไม่ถูกกระทบโดย overrun errors.

เมื่อ OVR = 1 ใน DMA mode, the DMA requests จะถูกบล็อกหลังจาก the last valid data ถูกส่งถ่ายแล้ว, ซึ่งหมายความว่าทุก the data ที่ส่งถ่ายไปยัง the RAM สามารถถูกพิจารณาได้ว่าถูกต้อง.

tha

ที่ the end ของ the last DMA transfer (จำนวนของ transfers ที่กำหนดค่าใน the DMA controller's DMA_SxNTR register):
•   ไม่มี new DMA request ถูกป่อยออกไปยัง to the DMA controller ถ้า the DDS bit ถูกเคลียร์เป็น 0 ใน the ADC_CR2 register
     (สิ่งนี้หลีกเลี่ยงการสร้าง an overrun error). อย่างไรก็ตาม the DMA bit จะไม่ถูกเคลียร์โดย hardware. มันต้องถูกเขียนเป็น 0, จาก
     นั้นเป็น 1 เพื่อสตาร์ท a new transfer.
•   Requests สามารถถูกสร้างต่อไปได้ถ้า the DDS bit ถูกเซ็ตเป็น 1. สิ่งนี้ยอมให้กำหนดค่า the DMA ใน double-buffer circular
     mode.

tha

เพื่อกู้คืน the ADC จาก OVR state เมื่อ the DMA ถูกใช้, ทำตามขั้นตอนข้างล่าง:
1.   กำหนดค่าเริ่มต้นใหม่e the DMA (ปรับ destination address และ NDTR counter)
2.   เคลียร์ the ADC OVR bit ใน ADC_SR register
3.   ทริก the ADC เพื่อสตาร์ท the conversion.

tha

15.8.2 Managing a sequence of conversions without using the DMA

ถ้า the conversions ช้าพอ, the conversion sequence สามารถถูกจัดการโดย the software. ในกรณีนี้ the EOCS bit ต้องถูกเซ็ตใน the ADC_CR2 register สำหรับ the EOC status bit ที่จะถูกเซ็ตที่ the end ของแต่ละ conversion, และไม่เฉพาะที่ the end ของ the sequence. เมื่อ EOCS = 1, overrun detection ถูกเปิดใช้งานโดยอัตโนมัติ. ดังนั้น, แต่ละครั้งที่ a conversion หนึ่งเสร็จสมบูรณ์, EOC จะถูกเซ็ตและ the ADC_DR register สามารถถูกอ่าน. The overrun management เป็นอย่างเดียวกันกับเมื่อ the DMA ถูกใช้.

ในการกู้คืน the ADC จาด OVR state เมื่อ the EOCS ถูกเซ็ต, ทำตามขั้นตอนข้างล่าง:
1.   เคลียร์ the ADC OVR bit ใน ADC_SR register
2.   ทริก the ADC เพื่อสตาร์ท the conversion.

tha

15.8.3 Conversions without DMA and without overrun detection

มันอาจเป็นประโยชน์ที่ปล่อยให้ the ADC แปลงหนึ่งชาแนลหรือมากกว่าโดยไม่มีการอ่าน the data ในแต่ละครั้ง (เช่นถ้ามี an analog watchdog ). สำหรับสิ่งนั้น, the DMA ต้องถูกปิดการใช้งาน (DMA = 0) และ the EOC bit ต้องถูกเซ็ตที่ the end ของ a sequence เท่านั้น (EOCS = 0). ในการกำหนดค่านี้, overrun detection ถูกปิดใช้งาน