STM32F1 DAC

Started by tha, October 17, 2020, 08:36:45 AM

Previous topic - Next topic

tha

12 Digital-to-analog converter (DAC)
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers ที่ the Flash memory density ย่านระหว่าง 16 and 32 Kbytes.
Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers ที่ the Flash memory density  ย่านระหว่าง  64 and 128 Kbytes.
High-density devices are STM32F101xx and STM32F103xx microcontrollers ที่ the Flash memory density  ย่านระหว่าง  256 and 512 Kbytes.
XL-density devices are STM32F101xx and STM32F103xx microcontrollers ที่ the Flash memory density  ย่านระหว่าง  768 Kbytes and 1 Mbyte.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
section นี้ใช้กับ connectivity line, high-density and XL-density STM32F101xx and STM32F103xx devices เพียงอย่างเดียว.

12.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

12.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 สำหรับแต่ละชาแนล)
• External triggers for conversion (ทริกเกอร์ภายนอกสำหรับการแปลง)
• Input voltage reference VREF+ (แรงดันอ้างอิงอินพุท VREF+)

The block diagram ของ a DAC channel ถูกแสดงใน Figure 40 และ the pin description ถูกให้ไว้ใน Table 73.



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

12.3 DAC functional description
12.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 ถูกรีเซ็ต.

12.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

12.3.3 DAC data format
ขึ้นอยู่กับโหมดกำหนดค่าที่เลือก (the selected configuration mode), the data จะต้องถูกเขียนในรีจีสเตอร์ที่ระบุ (the specified
register) ดังอธิบายข้างล่างนี้:

• Single DAC channelx, มีความเป็นไปได้สามประการ:
     – 8-bit right alignment: ผู้ใช้ต้องโหลด data ลงใน DAC_DHR8Rx [7:0] bits (เก็บลงใน  DHRx[11:4] bits)
     – 12-bit left alignment: ผู้ใช้ต้องโหลด data ลงใน DAC_DHR12Lx [15:4] bits (เก็บลงใน DHRx[11:0] bits)
     – 12-bit right alignment: ผู้ใช้ต้องโหลด data ลงใน DAC_DHR12Rx [11:0] bits (เก็บลงใน DHRx[11:0] bits)

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



• 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 nonmemory-mapped registers). The DHR1 and DHR2 registers ก็จะถูกโหลดลงใน the DOR1 and DOR2 registers, ตามลำดับ, โดยอัตโนมัติ, โดย software trigger หรือโดย an external event trigger อย่างใดอย่างหนึ่ง.




tha

12.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_DHR12LD).

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

12.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

12.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 events ที่เป็นไปได้, ที่จะทริกการแปลง, ดังแสดงใน Table 74.



แต่ละเวลาที่ 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 ถูกเลือก, ใช้เวลาเพียง 1 APB1 clock cycle สำหรับ DAC_DHRx-to-DAC_DORx register transfer


tha

12.3.7 DMA request
แต่ละ DAC channel มีความสามารถทาง DMA. 2 DMA channels ถูกใช้เพื่อบริการ DAC channel DMA requests.

A DAC DMA request ถูกทำให้เกิดขึ้นเมื่อ an external trigger (แต่ไม่ใช่ a software trigger) เกิดขึ้นขณะที่ the DMAENx bit ถูกเซ็ต. ค่าของ the DAC_DHRx register จะถูกส่งถ่ายไปยัง the DAC_DORx register.

ใน dual mode, ถ้าทั้งสอง DMAENx bits ถูกเซ็ต, two DMA requests ถูกทำให้เกิดขึ้น. ถ้ามีเพียง one DMA request ถูกต้องการ, you ควรเซ็ตเพียง the corresponding DMAENx bit. อย่างนี้, the application สามารถจัดการทั้งสอง DAC channels ใน dual mode โดยการใช้ one DMA request และ a unique(หนึ่งเดียว) DMA channel.

The DAC DMA request ไม่ถูกเรียงคิวดังนั้นถ้า a second external trigger มาถึงก่อนการตอบรับของ the last request, เมื่อนั้น the new request จะไม่ถูกบริการและไม่มีข้อผิดพลาดถูกรายงาน