STM32F7 16 Digital-to-analog converter (DAC)

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

Previous topic - Next topic

tha

16.3.7 DMA request

แต่ละ DAC channel มี a DMA capability. Two 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 ถูกต้องการ, คุณควรเซ็ตเฉพาะ the corresponding DMAENx bit. อย่างนี้, the application สามารถจัดการทั้งสอง DAC channels ใน dual mode โดยการใช้ one DMA request และ a unique(หนึ่งเดียว) DMA channel

tha

DMA underrun

The DAC DMA request ไม่ได้ถูกเรียงคิวดังนั้นถ้า a second external trigger มาถึงก่อนการตอบรับสำหรับ the first external trigger ถูกรับ (first request), ดังนั้นจะไม่มี new request ถูกปล่อยออกและ the DMA channelx underrun flag DMAUDRx ใน the DAC_SR register จะถูกเซ็ต, รายงาน the error condition. DMA data transfers จากนั้นจะถูกปิดใช้งานและไม่มี DMA request ตัวต่อไปถูกปฏิบัติ. The DAC channelx ต่อเนื่องแปลง old data.

The software ควรเคลียร์ the DMAUDRx flag โดยการเขียน "1", เคลียร์ the DMAEN bit ของ the used DMA stream และเริ่มต้นใหม่ทั้ง DMA and DAC channelx เพื่อสตาร์ทใหม่ the transfer อย่างถูกต้อง. The software ควรแก้ไข the DAC trigger conversion frequency หรือทำให้เบาลง the DMA workload เพื่อหลีกเลี่ยง a new DMA underrun. สุดท้าย, the DAC conversion จะสามารถถูกกลับมาทำงานต่อโดยการเปิดใช้งานทั้ง DMA data transfer และ conversion trigger.

สำหรับแต่ละ DAC channelx, an interrupt จะถูกสร้างด้วยถ้า corresponding DMAUDRIEx bit ของมันใน the DAC_CR register ถูกเปิดใช้งาน.

tha

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



The LFSR value, ที่อาจถูกบังบางส่วนหรือทั้งหมดโดยใช้ 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.



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


tha

16.3.9 Triangle-wave generation

มันเป็นไปได้ที่จะเพิ่ม a small-amplitude triangular waveform บน a DC หรือเปลี่ยนแปลงสัญญานอย่างช้าๆ. 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.



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

            MAMPx[3:0] bits ต้องถูกกำหนดค่าก่อนการเปิดการใช้งาน the DAC, มิฉะนั้นมันไม่สามารถถูกเปลี่ยนได้.

tha

16.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 ข้างล่างนี้.

tha

16.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 ต่อมา).

tha

16.4.2 Independent trigger with single 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 จะถูกอัฟเดต.

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

tha

16.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 จะถูกอัฟเดต.

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