STM32F7 16 Digital-to-analog converter (DAC)

Started by tha, November 29, 2022, 07:32:26 AM

Previous topic - Next topic

tha

16 Digital-to-analog converter (DAC)

16.1 DAC introduction

The DAC module เป็น a 12-bit, voltage output digital-to-analog converter. The DAC สามารถถูกกำหนดค่าใน 8- หรือ 12-bit mode และอาจถูกใช้ร่วมกับ the DMA controller. ใน 12-bit mode, the data สามารถถูกวางแนวชิดซ้ายหรือชิดขวา. The DAC มี two output channels, แต่ละตัวมี converter ของตัวเอง. ใน dual DAC channel mode, การแปลงสามารถถูกทำได้อย่างอิสระหรือพร้อมกัน เมื่อทั้งสอง channels ถูกจัดกลุ่มเข้าด้วยกันสำหรับ synchronous update operation. An input reference pin VREF+ (แชร์กับ ADC) มีให้ใช้งานสำหรับความละเอียดที่ดีกว่า.

tha

16.2 DAC main features

•   2 DAC converters: แต่ละตัวมี 1 output channel
•   วางแนวชิดซ้ายหรือชิดขวาใน 12-bit mode
•   Synchronized update capability (ความสามารถในการอัพเดตที่ซิงโครไนซ์กัน)
•   Noise-wave generation (การสร้างคลื่นรบกวน)
•   Triangular-wave generation (การสร้างคลื่นสามเหลี่ยม)
•   Dual DAC channel สำหรับการแปลงแบบอิสระหรือพร้อมกัน
•   DMA capability for each channel(ความสามารถทาง DMA สำหรับแต่ละชาแนล)
•   DMA underrun error detection
•   External triggers for conversion (ทริกเกอร์ภายนอกสำหรับการแปลง)
•   Input voltage reference VREF+ (แรงดันอ้างอิงอินพุท VREF+)

Figure 93 แสดง the block diagram of a DAC channel และ Table 102 ให้ the pin description.




Note: ทันทีที่ DAC channelx ถูกเปิดใช้งาน, the corresponding GPIO pin (PA4 or PA5) จะถูกต่อโดยอัตโนมัติกับ the analog
          converter output (DAC_OUTx). เพื่อหลีกเลี่ยง parasitic consumption, the PA4 or PA5 pin ก่อนอื่นควรถูกกำหนดค่า
          เป็น analog (AIN).


tha

16.3 DAC functional description

16.3.1 DAC channel enable

แต่ละ DAC channel สามารถถูก powered on โดยการเซ็ต ENx bit ที่ตรงกันของมันใน the DAC_CR register. The DAC channel จากนั้นจะถูกเปิดใช้งานหลังจาก a startup time tWAKEUP.

Note: The ENx bit เปิดใช้งาน the analog DAC Channelx macrocell เพียงอย่างเดียว. The DAC Channelx digital
           interface ถูกเปิดใช้งานได้ถึงแม้ว่า the ENx bit ถูกรีเซ็ต.


16.3.2 DAC output buffer enable

The DAC รวม output buffers สองตัวที่สามารถถูกใช้เพื่อลด the output impedance, และเพื่อขับโหลดภายนอกโดยตรงโดยไม่มีการเพิ่ม an external operational amplifier. แต่ละ DAC channel output buffer สามารถถูกเปิดช้งานและปิดใช้งานโดยใช้ the corresponding BOFFx bit ใน the DAC_CR register.



tha

16.3.3 DAC data format

ขึ้นอยู่กับ the selected configuration mode, the data จะต้องถูกเขียนลงใน the specified register ดังอธิบายข้างล่างนี้:
•   Single DAC channelx, มีความเป็นไปได้สามประการ:
     –   8-bit right alignment: the software ต้องโหลด data ลงใน DAC_DHR8Rx [7:0] bits (ถูกเก็บลงใน  DHRx[11:4]
          bits)
     –   12-bit left alignment: the software ต้องโหลด data ลงใน DAC_DHR12Lx [15:4] bits (ถูกเก็บลงใน DHRx[11:0]
          bits)
     –   12-bit right alignment: the software ต้องโหลด data ลงใน DAC_DHR12Rx [11:0] bits (ถูกเก็บลงใน DHRx[11:0]
          bits)

ขึ้นอยู่กับ the loaded DAC_DHRyyyx register, the data ที่ถูกเขียนโดยผู้ใช้จะถูกเลื่อนและเก็บลงใน the corresponding DHRx (Data Holding Registerx, ซึ่งเป็น internal non-memory-mapped registers). The DHRx register จากนั้นก็จะถูกโหลดลงใน the DORx register โดยอัตโนมัติ, โดย software trigger หรือโดย an external event trigger อย่างใดอย่างหนึ่ง.


tha

•   Dual DAC channels, มีความเป็นไปได้สามประการ:
     –   8-bit right alignment: data สำหรับ DAC channel1 ถูกโหลดลงใน DAC_DHR8RD [7:0] bits (ถูกเก็บลงใน
          DHR1[11:4] bits) และ data สำหรับ DAC channel2 ถูกโหลดลงใน DAC_DHR8RD [15:8] bits (ถูกเก็บลงใน
          DHR2[11:4] bits)
     –   12-bit left alignment: data สำหรับ DAC channel1 ถูกโหลดลงใน DAC_DHR12LD [15:4] bits (ถูกเก็บลงใน
          DHR1[11:0] bits) และ data สำหรับ DAC channel2 ถูกโหลดลงใน DAC_DHR12LD [31:20] bits (ถูกเก็บลงใน
          DHR2[11:0] bits)
     –   12-bit right alignment: data สำหรับ DAC channel1 ถูกโหลดลงใน DAC_DHR12RD [11:0] bits (ถูกเก็บลงใน
          DHR1[11:0] bits) และ data สำหรับ DAC channel2 ถูกโหลดลงใน DAC_DHR12RD [27:16] bits (ถูกเก็บลงใน
          DHR2[11:0] bits)

ขึ้นอยู่กับ the loaded DAC_DHRyyyD register, the data  ที่ถูกเขียนโดยผู้ใช้จะถูกเลื่อนและเก็บลงใน the DHR1 and DHR2 (Data Holding Registers, ซึ่งเป็น internal non-memory-mapped registers). The DHR1 and DHR2 registers จากนั้นก็จะถูกโหลดลงใน the DOR1 and DOR2 registers, ตามลำดับ, โดยอัตโนมัติ, โดย software trigger หรือโดย an external event trigger อย่างใดอย่างหนึ่ง.


tha

16.3.4 DAC conversion

The DAC_DORx ไม่สามารถถูกเขียนได้โดยตรงและ data transfer ใดๆไปยัง the DAC channelx ต้องถูกกระทำโดยการโหลด the DAC_DHRx register (เขียนไปยัง DAC_DHR8Rx, DAC_DHR12Lx, DAC_DHR12Rx, DAC_DHR8RD, DAC_DHR12LD or DAC_DHR12RD).

Data ที่เก็บใน the DAC_DHRx register จะถูกส่งถ่ายโดยอัตโนมัติไปยัง the DAC_DORx register หลังจาก 1 APB1 clock cycle, ถ้าไม่มี hardware trigger ถูกเลือก (TENx bit ใน DAC_CR register ถูกรีเซ็ต). อย่างไรก็ตาม, เมื่อ a hardware trigger ถูกเลือก (TENx bit ใน DAC_CR register ถูกเซ็ต) และ a trigger เกิดขึ้น, การส่งถ่ายจะถูกกระทำ 3 APB1 clock cycles ต่อมา.

เมื่อ DAC_DORx ถูกโหลดด้วย the DAC_DHRx contents, the analog output voltage จะพร้อมใช้งานหลังจากช่วงเวลา tSETTLING ซึ่งขึ้นอยู่กับ the power supply voltage และ the analog output load.



tha

16.3.5 DAC output voltage

Digital inputs ถูกแปลงเป็น output voltages บน a linear conversion ระหว่าง 0 และ VREF+.

The analog output voltages บนแต่ละ DAC channel pin ถูกกำหนดโดยสมการ

DACoutput = VREF x DOR/4096

tha

16.3.6 DAC trigger selection

ถ้า the TENx control bit ถูกเซ็ต, conversion สามารถจะถูกทริกโดย an external event (timer counter, external interrupt line). The TSELx[2:0] control bits เป็นตัวกำหนดว่าอันไหนจาก 8 possible events ที่จะทริกการแปลงดังแสดงใน Table 103.



แต่ละครั้งที่ a DAC interface ตรวจพบ a rising edge บน the selected timer TRGO output, หรือ บน the selected external interrupt line 9, the last data ที่เก็บลงใน the DAC_DHRx register จะถูกส่งถ่ายลงใน the DAC_DORx register. The DAC_DORx register ถูกอัฟเดต three APB1 cycles หลังจาก the trigger เกิดขึ้น.

ถ้า the software trigger ถูกเลือก, the conversion สตาร์ททันที่ที the SWTRIG bit ถูกเซ็ต. SWTRIG ถูกรีเซ็ตโดย hardware ทันทีที่ the DAC_DORx register ถูกโหลดแล้วเสร็จด้วย the DAC_DHRx register contents(สิ่งที่จุอยู่ภายใน).

Note:  TSELx[2:0] bit ไม่สามารถถูกเปลี่ยนเมื่อ the ENx bit ถูกเซ็ต.

           เมื่อ software trigger ถูกเลือก, การส่งถ่ายจาก the DAC_DHRx register ไปยัง the DAC_DORx register จะใช้เวลาเพียง
           1 APB1 clock cycle.