Electoday 2025

ไมโครคอนโทรลเลอร์ => ARM Processors => Topic started by: tha on October 17, 2020, 08:36:45 AM

Title: STM32F1 DAC
Post by: tha on October 17, 2020, 08:36:45 AM
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) มีให้ใช้สำหรับความละเอียดที่ดีกว่า.
Title: Re: STM32F1 DAC
Post by: tha on October 17, 2020, 08:59:29 AM
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.

(https://i.imgur.com/4opmgLf.png)

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) ก่อน.
Title: Re: STM32F1 DAC
Post by: tha on October 17, 2020, 09:48:06 AM
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.
Title: Re: STM32F1 DAC
Post by: tha on October 17, 2020, 11:46:40 AM
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 อย่างใดอย่างหนึ่ง.

(https://i.imgur.com/c5WMs8c.png)

• 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 อย่างใดอย่างหนึ่ง.

(https://i.imgur.com/kHjTYbr.png)

Title: Re: STM32F1 DAC
Post by: tha on October 17, 2020, 01:13:03 PM
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.

(https://i.imgur.com/c340FHo.png)
Title: Re: STM32F1 DAC
Post by: tha on October 17, 2020, 03:27:14 PM
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
Title: Re: STM32F1 DAC
Post by: tha on October 18, 2020, 07:09:43 AM
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.

(https://i.imgur.com/HZ91mqY.png)

แต่ละเวลาที่ 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

Title: Re: STM32F1 DAC
Post by: tha on October 18, 2020, 07:58:01 AM
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 จะไม่ถูกบริการและไม่มีข้อผิดพลาดถูกรายงาน
Title: Re: STM32F1 DAC
Post by: tha on October 19, 2020, 07:30:53 AM
12.3.8 Noise generation
เพื่อสร้าง a variable-amplitude pseudonoise, a Linear Feedback Shift Register มีให้ใช้. The DAC noise generation ถูกเลือกโดยการเซ็ต WAVEx[1:0] เป็น "01". The preloaded value (ค่าที่โหลดไว้ล่วงหน้า)ใน the LFSR คือ 0xAAA. register นี้ถูกปรับปรุง, three APB1 clock cycles หลังจากแต่ละ trigger event, ตามด้วย a specific calculation algorithm.

(https://i.imgur.com/GWiWx77.png)

The LFSR value, ที่อาจถูก masked บางส่วนหรือทั้งหมดโดยใช้ the MAMPx[3:0] bits ใน the DAC_CR register, จะถูกเพิ่มไปยัง the DAC_DHRx contents โดยไม่ล้น(overflow) และค่านี้จากนั้นจะถูกเก็บลงใน the DAC_DORx register.

ถ้า LFSR คือ 0x0000, a '1' ถูก injected ลงในมัน (antilock-up mechanism).

เป็นไปได้ที่จะรีเซ็ต LFSR wave generation โดยการรีเซ็ต the WAVEx[1:0] bits.

(https://i.imgur.com/GUzYtkl.png)

Note: DAC trigger ต้องถูกเปิดการใช้งานสำหรับ noise generation, โดยการเซ็ต the TENx bit ใน the DAC_CR register.
Title: Re: STM32F1 DAC
Post by: tha on October 19, 2020, 08:27:59 AM
12.3.9 Triangle-wave generation
เป็นไปได้ที่จะเพิ่ม a small-amplitude triangular waveform บน a DC หรือ slowly varying signal. DAC triangle-wave generation ถูกเลือกโดยการเซ็ต WAVEx[1:0] เป็น "10". The amplitude ถูกกำหนดค่าผ่านทาง the MAMPx[3:0] bits ใน the DAC_CR register. An internal triangle counter ถูกเพิ่ม three APB1 clock cycles หลังจากแต่ละ trigger event. ค่าของ counter นี้จากนั้นถูกเพิ่มลงใน the DAC_DHRx register โดยไม่ล้น(overflow) และผลรวมถูกเก็บลงใน the DAC_DORx register. The triangle counter ถูกเพิ่มขึ้นขณะที่มันน้อยกว่า the maximum amplitude กำหนดโดย the MAMPx[3:0] bits. เมื่อ the configured amplitude ถูกถึง, the counter ถูกลดลงจนถึง 0, จากนั้นก็เพิ่มขึ้นอีกครั้งและดำเนินไปตามนี้.

เป็นไปได้ที่จะรีเซ็ต triangle wave generation โดยการรีเซ็ต WAVEx[1:0] bits.

(https://i.imgur.com/gkOV4Rs.png)

(https://i.imgur.com/gRqFmPc.png)

Note: DAC trigger ต้องถูกเปิดการใช้งานสำหรับ noise generation, โดยการเซ็ต the TENx bit ใน the DAC_CR register.

MAMPx[3:0] bits ต้องถูกกำหนดค่าก่อนการเปิดการใช้งาน the DAC, มิฉะนั้นมันไม่สามารถถูกเปลี่ยนได้.
Title: Re: STM32F1 DAC
Post by: tha on October 19, 2020, 11:17:08 AM
12.4 Dual DAC channel conversion
เพื่อใช้ the bus bandwidth อย่างมีประสิทธิภาพใน applications ที่ต้องการ the two DAC channels ในเวลาเดียวกัน, 3 dual registers ถูกทำให้เป็นผล: DHR8RD, DHR12RD and DHR12LD. A unique register access จากนั้นถูกต้องการเพื่อขับทั้งสอง DAC channels ในเวลาเดียวกัน. Eleven possible conversion modes สามารถทำได้กับการใช้ the two DAC channels และ dual
registers เหล่านี้. อย่างไรก็ตาม the conversion modes ทั้งหมดสามารถถูกได้มาโดยใช้ DHRx registers แยกกันต่างหากถ้าจำเป็น.

โหมดทั้งหมดถูกอธิบายใน the paragraphs ข้างล่างนี้.

12.4.1 Independent trigger without wave generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 และ TEN2
• กำหนดค่าแหล่งทริกที่ต่างกันโดยการเซ็ตค่าที่ต่างกันใน the TSEL1[2:0] และ TSEL2[2:0] bits
• โหลด the dual DAC channel data ลงใน the desired DHR register (DAC_DHR12RD, DAC_DHR12LD หรือ
   DAC_DHR8RD)

เมื่อ a DAC channel1 trigger มาถึง, the DHR1 register ถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา).

เมื่อ a DAC channel2 trigger มาถึง, the DHR2 register ถูกส่งถ่ายลงใน DAC_DOR2 (three APB1 clock cycles ต่อมา).

12.4.2 Independent trigger with same LFSR generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 และ TEN2
• กำหนดค่าแหล่งทริกที่ต่างกันโดยการเซ็ตค่าที่ต่างกันใน the TSEL1[2:0] และ TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "01" ด้วย the same(เดียวกัน) LFSR mask value ใน the
   MAMPx[3:0] bits
• โหลด the dual DAC channel data ลงใน the desired(ที่ต้องการ) DHR register (DHR12RD, DHR12LD or DHR8RD)

เมื่อ a DAC channel1 trigger มาถึง, the LFSR1 counter, ด้วย the same mask, ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา). จากนั้น the LFSR1 counter ถูก updated.

เมื่อ a DAC channel2 trigger มาถึง, the LFSR2 counter, ด้วย the same mask, ถูกเพิ่มไปยัง the DHR2 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2 (three APB1 clock cycles ต่อมา). จากนั้น the LFSR2 counter ถูก updated.
Title: Re: STM32F1 DAC
Post by: tha on October 20, 2020, 06:59:19 AM
12.4.3 Independent trigger with different LFSR generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 และ TEN2
• กำหนดค่าแหล่งทริกที่ต่างกันโดยการเซ็ตค่าที่ต่างกันใน the TSEL1[2:0] และ TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "01"  และเซ็ต different LFSR masks values (ค่าบัง LFSR ที่ต่าง
   กัน) ใน the MAMP1[3:0] และ MAMP2[3:0] bits
• โหลด the dual DAC channel data ลงใน the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or
   DAC_DHR8RD)

เมื่อ a DAC channel1 trigger มาถึง, the LFSR1 counter, ด้วย the mask กำหนดค่าโดย MAMP1[3:0], ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1
(three APB1 clock cycles ต่อมา). จากนั้น the LFSR1 counter ถูก updated.

เมื่อ a DAC channel2 trigger มาถึง, the LFSR2 counter, ด้วย the mask กำหนดค่าโดย MAMP2[3:0], ถูกเพิ่มไปยัง the DHR2 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2
(three APB1 clock cycles ต่อมา). จากนั้น the LFSR2 counter ถูก updated.

12.4.4 Independent trigger with same triangle generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 และ TEN2
• กำหนดค่าแหล่งทริกที่ต่างกันโดยการเซ็ตค่าที่ต่างกันใน the TSEL1[2:0] และ TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "1x" และ the same maximum amplitude value ใน the
   MAMPx[3:0] bits
• โหลด the dual DAC channel data ลงใน the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or
   DAC_DHR8RD)

เมื่อ a DAC channel1 trigger มาถึง, the DAC channel1 triangle counter, ด้วย the same triangle amplitude, ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา). The DAC channel1 triangle counter จากนั้นถูก updated.

เมื่อ a DAC channel2 trigger มาถึง, the DAC channel2 triangle counter, ด้วย the same triangle amplitude, ถูกเพิ่มไปยัง the DHR2 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2 (three APB1 clock cycles ต่อมา). The DAC channel2 triangle counter จากนั้นถูก updated.
Title: Re: STM32F1 DAC
Post by: tha on October 20, 2020, 07:16:05 AM
12.4.5 Independent trigger with different triangle generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 และ TEN2
• กำหนดค่าแหล่งทริกที่ต่างกันโดยการเซ็ตค่าที่ต่างกันใน the TSEL1[2:0] และ TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "1x" และเซ็ต different maximum amplitude values ใน the
   MAMP1[3:0] และ MAMP2[3:0] bits
• โหลด the dual DAC channel data ลงใน the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or
   DAC_DHR8RD)

เมื่อ a DAC channel1 trigger มาถึง, the DAC channel1 triangle counter, ด้วย a triangle amplitude กำหนดค่าโดย  MAMP1[3:0], ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา). The DAC channel1 triangle counter จากนั้นถูก updated.

เมื่อ a DAC channel2 trigger มาถึง, the DAC channel2 triangle counter, ด้วย a triangle amplitude กำหนดค่าโดย MAMP2[3:0], ถูกเพิ่มไปยัง the DHR2 register part และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2 (three APB1 clock cycles ต่อมา). The DAC channel2 triangle counter จากนั้นถูก updated.

12.4.6 Simultaneous software start
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• โหลด the dual DAC channel data ไปยัง the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or
   DAC_DHR8RD)

ในการกำหนดค่านี้, one APB1 clock cycle ต่อมา, the DHR1 and DHR2 registers  ถูกส่งถ่ายลงใน DAC_DOR1 and DAC_DOR2, ตามลำดับ.
Title: Re: STM32F1 DAC
Post by: tha on October 20, 2020, 07:31:44 AM
12.4.7 Simultaneous trigger without wave generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 และ TEN2
• กำหนดค่าแหล่งทริกเดียวกันสำหรับทั้งสอง DAC channels โดยการเซ็ตค่าเดียวกันใน the TSEL1[2:0] and TSEL2[2:0] bits
• โหลด the dual DAC channel data ไปยัง the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or
   DAC_DHR8RD)

เมื่อ a trigger มาถึง, the DHR1 and DHR2 registers ถูกส่งถ่ายลงใน DAC_DOR1 and DAC_DOR2, ตามลำดับ (หลังจาก three APB1 clock cycles).

12.4.8 Simultaneous trigger with same LFSR generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 and TEN2
• กำหนดค่าแหล่งทริกเดียวกันสำหรับทั้งสอง DAC channels โดยการเซ็ตค่าเดียวกันใน the TSEL1[2:0] and TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "01" และ the same LFSR mask value ใน the MAMPx[3:0] bits
• โหลด the dual DAC channel data ไปยัง the desired DHR register (DHR12RD, DHR12LD or DHR8RD)

เมื่อ a trigger มาถึง, the LFSR1 counter, ด้วย the same mask, ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา). The LFSR1 counter จากนั้นถูก updated. ในเวลาเดียวกัน, the LFSR2 counter, ด้วย the same mask,  ถูกเพิ่มไปยัง the DHR2 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2 (three APB1
clock cycles ต่อมา). The LFSR2 counter จากนั้นถูก updated.
Title: Re: STM32F1 DAC
Post by: tha on October 20, 2020, 12:41:46 PM
12.4.9 Simultaneous trigger with different LFSR generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 and TEN2
• กำหนดค่าแหล่งทริกเดียวกันสำหรับทั้งสอง DAC channels โดยการเซ็ตค่าเดียวกันใน the TSEL1[2:0] and TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "01" และเซ็ต different LFSR masks values โดยใช้ the
   MAMP1[3:0] และ MAMP2[3:0] bits
• โหลด the dual DAC channel data ลงใน the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or
   DAC_DHR8RD)

เมื่อ a trigger มาถึง, the LFSR1 counter, ด้วย the mask กำหนดค่าโดย MAMP1[3:0] , ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา). The LFSR1 counter จากนั้นถูก updated.

ในเวลาเดียวกัน, the LFSR2 counter, ด้วย the mask  กำหนดค่าโดย MAMP2[3:0] , ถูกเพิ่มไปยัง the DHR2 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2 (three APB1 clock cycles ต่อมา). The LFSR2 counter จากนั้นถูก updated.

12.4.10 Simultaneous trigger with same triangle generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 and TEN2
• กำหนดค่าแหล่งทริกเดียวกันสำหรับทั้งสอง DAC channels โดยการเซ็ตค่าเดียวกันใน the TSEL1[2:0] and TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "1x"  และ the same maximum amplitude value โดยใช้ the
   MAMPx[3:0] bits
• โหลด the dual DAC channel data ลงใน the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or
   DAC_DHR8RD)

เมื่อ a trigger มาถึง, the DAC channel1 triangle counter, ด้วย the same triangle amplitude, ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา). The DAC channel1 triangle counter จากนั้นถูก updated.

ในเวลาเดียวกัน, the DAC channel2 triangle counter, ด้วย the same triangle amplitude, ถูกเพิ่มไปยัง the DHR2 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2 (three APB1 clock cycles ต่อมา). The DAC channel2 triangle counter จากนั้นถูก updated.

12.4.11 Simultaneous trigger with different triangle generation
เพื่อกำหนดค่า the DAC ใน conversion mode นี้, ลำดับดังต่อไปนี้ถูกต้องการ :
• เซ็ต the two DAC channel trigger enable bits TEN1 and TEN2
• กำหนดค่าแหล่งทริกเดียวกันสำหรับทั้งสอง DAC channels โดยการเซ็ตค่าเดียวกันใน the TSEL1[2:0] and TSEL2[2:0] bits
• กำหนดค่า the two DAC channel WAVEx[1:0] bits เป็น "1x" และเซ็ต different maximum amplitude values ใน the
   MAMP1[3:0] และ MAMP2[3:0] bits
• Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD,
   DAC_DHR12LD or DAC_DHR8RD)

เมื่อ a trigger มาถึง, the DAC channel1 triangle counter, ด้วย a triangle amplitude กำหนดค่าโดย MAMP1[3:0], ถูกเพิ่มไปยัง the DHR1 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR1 (three APB1 clock cycles ต่อมา). จากนั้น the DAC channel1 triangle counter ถูก updated.

ในเวลาเดียวกัน, the DAC channel2 triangle counter, ด้วย a triangle amplitude กำหนดค่าโดย MAMP2[3:0], ถูกเพิ่มไปยัง the DHR2 register และผลรวมจะถูกส่งถ่ายลงใน DAC_DOR2 (three APB1 clock cycles ต่อมา). จากนั้น the DAC channel2 triangle counter ถูก updated.
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 09:25:52 AM
12.5 DAC registers
The peripheral registers ต้องถูกเข้าถึงโดย words (32-bit).

(https://i.imgur.com/IMoyHv5.png)

Bits 31:29 Reserved.
Bit 28 DMAEN2: DAC channel2 DMA enable
บิตนี้ถูกเซ็ตและเคลียร์โดย software.
     0: DAC channel2 DMA mode ปิดการใช้งานอยู่
     1: DAC channel2 DMA mode เปิดการใช้งานอยู่

Bit 27:24 MAMP2[3:0]: DAC channel2 mask/amplitude selector
บิตเหล่านี้ถูกเขียนโดย software เพื่อเลือกการบัง(mask) ใน wave generation mode หรือ amplitude ใน triangle generation mode.
     0000: ไม่บัง bit0 ของ LFSR/ Triangle Amplitude เท่ากับ 1
     0001: Unmask bits[1:0] of LFSR/ Triangle Amplitude equal to 3
     0010: Unmask bits[2:0] of LFSR/ Triangle Amplitude equal to 7
     0011: Unmask bits[3:0] of LFSR/ Triangle Amplitude equal to 15
     0100: Unmask bits[4:0] of LFSR/ Triangle Amplitude equal to 31
     0101: Unmask bits[5:0] of LFSR/ Triangle Amplitude equal to 63
     0110: Unmask bits[6:0] of LFSR/ Triangle Amplitude equal to 127
     0111: Unmask bits[7:0] of LFSR/ Triangle Amplitude equal to 255
     1000: Unmask bits[8:0] of LFSR/ Triangle Amplitude equal to 511
     1001: Unmask bits[9:0] of LFSR/ Triangle Amplitude equal to 1023
     1010: Unmask bits[10:0] of LFSR/ Triangle Amplitude equal to 2047
     ≥ 1011: Unmask bits[11:0] of LFSR/ Triangle Amplitude equal to 4095

Bit 23:22 WAVE2[1:0]: DAC channel2 noise/triangle wave generation enable
บิตเหล่านี้ถูก set/reset โดย software.
     00: wave generation ปิดการใช้งานอยู่
     01: Noise wave generation เปิดการใช้งานอยู่
     1x: Triangle wave generation เปิดการใช้งานอยู่
Note: ถูกใช้เพียงถ้า bit TEN2 = 1 (DAC channel2 trigger enabled)

Bits 21:19 TSEL2[2:0]: DAC channel2 trigger selection
บิตเหล่านี้เลือก the external event ใช้เพื่อทริกเกอร์ DAC channel2
     000: Timer 6 TRGO event
     001: Timer 3 TRGO event ใน connectivity line devices, Timer 8 TRGO ใน high-density และ XL-density devices
     010: Timer 7 TRGO event
     011: Timer 5 TRGO event
     100: Timer 2 TRGO event
     101: Timer 4 TRGO event
     110: External line9
     111: Software trigger
Note: ถูกใช้เพียงถ้า bit TEN2 = 1 (DAC channel2 trigger enabled)

Bit 18 TEN2: DAC channel2 trigger enable
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable DAC channel2 trigger
     0: DAC channel2 trigger ปิดการใช้งานอยู่และ data ที่เขียนลงใน DAC_DHRx register ถูกส่งถ่าย one APB1 clock cycle ต่อ
         มาไปยัง the DAC_DOR2 register.
     1: DAC channel2 trigger เปิดการใช้งานอยู่และ data ส่งถ่ายจาก DAC_DHRx register ถูกส่งถ่าย three APB1 clock cycles
         ต่อมาไปยัง the DAC_DOR2 register.
Note: เมื่อ software trigger ถูกเลือก, มันใช้เวลาเพียง one APB1 clock cycle สำหรับ DAC_DHRx ไปยัง DAC_DOR2 register transfer.

Bit 17 BOFF2: DAC channel2 output buffer disable
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable DAC channel2 output buffer.
     0: DAC channel2 output buffer เปิดการใช้งานอยู่
     1: DAC channel2 output buffer ปิดการใช้งานอยู่

Bit 16 EN2: DAC channel2 enable
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable DAC channel2.
     0: DAC channel2 disabled
     1: DAC channel2 enabled

Bits 15:13 Reserved.

Bit 12 DMAEN1: DAC channel1 DMA enable
This bit is set and cleared by software.
     0: DAC channel1 DMA mode disabled
     1: DAC channel1 DMA mode enabled

Bits 11:8 MAMP1[3:0]: DAC channel1 mask/amplitude selector
บิตเหล่านี้ถูกเขียนโดย software เพื่อเลือกการบัง(mask) ใน wave generation mode หรือ amplitude ใน triangle generation mode.
     0000: ไม่บัง bit0 of LFSR/ Triangle Amplitude เท่ากับ 1
     0001: Unmask bits[1:0] of LFSR/ Triangle Amplitude equal to 3
     0010: Unmask bits[2:0] of LFSR/ Triangle Amplitude equal to 7
     0011: Unmask bits[3:0] of LFSR/ Triangle Amplitude equal to 15
     0100: Unmask bits[4:0] of LFSR/ Triangle Amplitude equal to 31
     0101: Unmask bits[5:0] of LFSR/ Triangle Amplitude equal to 63
     0110: Unmask bits[6:0] of LFSR/ Triangle Amplitude equal to 127
     0111: Unmask bits[7:0] of LFSR/ Triangle Amplitude equal to 255
     1000: Unmask bits[8:0] of LFSR/ Triangle Amplitude equal to 511
     1001: Unmask bits[9:0] of LFSR/ Triangle Amplitude equal to 1023
     1010: Unmask bits[10:0] of LFSR/ Triangle Amplitude equal to 2047
     ≥ 1011: Unmask bits[11:0] of LFSR/ Triangle Amplitude equal to 4095

Bits 7:6 WAVE1[1:0]: DAC channel1 noise/triangle wave generation enable
บิตเหล่านี้ถูก set/reset โดย software.
     00: wave generation disabled
     01: Noise wave generation enabled
     1x: Triangle wave generation enabled
Note: ถูกใช้เพียงถ้า bit TEN1 = 1 (DAC channel1 trigger enabled)

Bits 5:3 TSEL1[2:0]: DAC channel1 trigger selection
บิตเหล่านี้เลือก the external event ใช้เพื่อทริกเกอร์ DAC channel1
     000: Timer 6 TRGO event
     001: Timer 3 TRGO event ใน connectivity line devices, Timer 8 TRGO ใน high-density และ XL-density devices
     010: Timer 7 TRGO event
     011: Timer 5 TRGO event
     100: Timer 2 TRGO event
     101: Timer 4 TRGO event
     110: External line9
     111: Software trigger
Note: ถูกใช้เพียงถ้า bit TEN1 = 1 (DAC channel1 trigger enabled)

Bit 2 TEN1: DAC channel1 trigger enable
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable DAC channel1 trigger
     0: DAC channel1 trigger ปิดการใช้งานอยู่และ data ที่เขียนลงใน DAC_DHRx register ถูกส่งถ่าย one APB1 clock cycle ต่อ
         มาไปยัง the DAC_DOR1 register.
     1: DAC channel1 trigger เปิดการใช้งานอยู่และ data ส่งถ่ายจาก DAC_DHRx register ถูกส่งถ่าย three APB1 clock cycles
         ต่อมาไปยัง the DAC_DOR1 register.
Note: เมื่อ software trigger ถูกเลือก, มันใช้เวลาเพียง one APB1 clock cycle สำหรับ DAC_DHRx ไปยัง DAC_DOR1 register transfer.

Bit 1 BOFF1: DAC channel1 output buffer disable
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable DAC channel1 output buffer.
     0: DAC channel1 output buffer enabled
     1: DAC channel1 output buffer disabled

Bit 0 EN1: DAC channel1 enable
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable DAC channel1.
     0: DAC channel1 disabled
     1: DAC channel1 enabled
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 09:48:09 AM
(https://i.imgur.com/ZFwSUYy.png)

Bits 31:2 Reserved.
Bit 1 SWTRIG2: DAC channel2 software trigger
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable the software trigger.
     0: Software trigger disabled
     1: Software trigger enabled
Note: บิตนี้ถูก reset โดย hardware (one APB1 clock cycle ต่อมา) ทันทีที่ the DAC_DHR2 register value ถูกโหลดไปยัง the DAC_DOR2 register.

Bit 0 SWTRIG1: DAC channel1 software trigger
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable the software trigger.
     0: Software trigger disabled
     1: Software trigger enabled
Note: บิตนี้ถูก reset โดย hardware (one APB1 clock cycle ต่อมา) ทันทีที่ the DAC_DHR1 register value ถูกโหลดไปยัง the DAC_DOR1 register.
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 09:53:21 AM
(https://i.imgur.com/B2lC5iQ.png)

Bits 31:12 Reserved.
Bit 11:0 DACC1DHR[11:0]: DAC channel1 12-bit right-aligned data
บิตเหล่านี้ถูกเขียนโดย software ซึ่งระบุ 12-bit data สำหรับ DAC channel1.
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 09:56:29 AM
(https://i.imgur.com/rYJvGap.png)

Bits 31:16 Reserved.
Bit 15:4 DACC1DHR[11:0]: DAC channel1 12-bit left-aligned data
บิตเหล่านี้ถูกเขียนโดย software ซึ่งระบุ 12-bit data สำหรับ DAC channel1.
Bits 3:0 Reserved.
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 09:59:38 AM
(https://i.imgur.com/KhXzuHy.png)

Bits 31:8 Reserved.
Bits 7:0 DACC1DHR[7:0]: DAC channel1 8-bit right-aligned data
     บิตเหล่านี้ถูกเขียนโดย software ซึ่งระบุ 8-bit data สำหรับ DAC channel1.
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 10:03:22 AM
(https://i.imgur.com/NEysuSp.png)
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 10:05:58 AM
(https://i.imgur.com/CWwDFJq.png)
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 10:09:06 AM
(https://i.imgur.com/9ZcH98u.png)
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 10:14:31 AM
(https://i.imgur.com/95kLzRa.png)

ปล. ก็จบไปอีกตอน เอาอะไรต่อดีหล่ะ TIM1&TIM8 เลยนะ จะเอาอะไรก็บอกมา พรุ่งนี้ค่อยแปล
Title: Re: STM32F1 DAC
Post by: tha on October 21, 2020, 06:54:21 PM
Bit 11:0 DACC1DOR[11:0]: DAC channel1 data output
     บิตเหล่านี้ถูกอ่านได้เพียงอย่างเดียว, มันบรรจุ data output สำหรับ DAC channel1.

ปล. ไม่ได้แปลไว้ใช่ไหม แปลสักหน่อย