STM32F1 USB

Started by tha, April 01, 2021, 07:19:59 AM

Previous topic - Next topic

tha

Bit 2 LP_MODE: Low-power mode
mode นี้ถูกใช้เมื่อ the suspend-mode power constraints ต้องการให้ all static power dissipation ถูกหลีกเลี่ยง, ยกเว้นสิ่งเดียวที่จำเป็นต้องจ่ายไฟให้ the external pull-up resistor. เงื่อนไขนี้ควรถูกเข้าสู่เมื่อ the application พร้อมที่จะหยุด all system clocks, หรือลดความถี่ของมันเพื่อให้ตรงตาม the power consumption requirements ของ the USB suspend condition. The USB activity ในระหว่าง the suspend mode (WKUP event) จะรีเซ็ตบิตนี้แบบอะซิงโครนัส (มันสามารถถูกรีเซ็ตโดย software ได้อีกด้วย)
     0: ไม่มี Low-power mode.
     1: เข้าสู่ Low-power mode

Bit 1 PDWN: Power down
บิตนี้ถูกใช้เพื่อปิด all USB-related analog parts อย่างสมบูรณ์ถ้ามันถูกต้องการเพื่อจะปิดการใช้งาน the USB peripheral อย่างสมบูรณ์ไม่ว่าด้วยเหตุผลใดก็ตาม. เมื่อบิตนี้ถูกเซ็ต, the USB peripheral ถูกตัดการเชื่อมต่อจาก the transceivers และมันไม่สามารถถูกใช้.
     0: ออกจาก Power Down.
     1: เข้าสู่ Power down mode.

Bit 0 FRES: Force USB Reset
     0: เคลียร์ USB reset.
     1: บังคับ a reset ของ the USB peripheral, เหมือนจริงๆกับ a RESET signalling บน the USB. The USB peripheral ถูกยึด
         อยู่ใน RESET state จนกระทั่ง software เคลียร์บิตนี้. A "USB-RESET" interrupt ถูกสร้างขึ้น, ถ้าเปิดการใช้งาน.

tha

USB interrupt status register (USB_ISTR)

Address offset: 0x44
Reset value: 0x0000 0000



register นี้บรรจุสถานะของ all the interrupt sources ที่ยอมให้ application software ตัดสินใจ, ซึ่ง events ที่ทำให้เกิด an interrupt request.

ส่วนบนของ register นี้บรรจุ single bits, แต่ละของพวกมันแสดง a specific event. บิตเหล่านี้ถูกเซ็ตโดย the hardware เมื่อ the related event เกิดขึ้น; ถ้าบิตที่ตรงกันใน the USB_CNTR register ถูกเซ็ต, a generic interrupt request ถูกสร้างขึ้น. The interrupt routine, ตรวจสอบแต่ละบิต, จะดำเนินการ all necessary actions, และสุดท้ายมันจะเคลียร์ the serviced bits. ถ้าพวกมันอันไหนไม่ถูกเคลียร์, the interrupt ถูกพิจารณาว่ายังคง pending, และ the interrupt line จะถูกเก็บ high อีกครั้ง. ถ้าหลายบิตถูกเซ็ตพร้อมกัน, มีเพียง a single interrupt ที่จะถูกสร้างขึ้น.

tha

Endpoint transaction completion สามารถถูกจัดการในวิธีต่างๆเพื่อลด interrupt response latency. The CTR bit ถูกเซ็ตโดย the hardware ทันทีที่ an endpoint สำเร็จเสร็จสมบูรณ์ a transaction, สร้างขึ้น a generic interrupt request ถ้าบิตที่ตรงกันใน USB_CNTR ถูกเซ็ต. An endpoint dedicated interrupt condition ถูกทำให้ทำงานเป็นอิสระจาก the CTRM bit ใน the USB_CNTR register. ทั้งสอง interrupt conditions ยังคงทำงานจนกว่า software จะเคลียร์ the pending bit ใน the corresponding USB_EPnR register (the CTR bit จริงๆแล้วเป็น a read only bit). สำหรับ endpoint-related interrupts, the software สามารถใช้ the Direction of Transaction (DIR) และ EP_ID read-only bits เพื่อวินิจฉัย, ซึ่ง endpoint ได้ทำ the last interrupt request แล้วและได้เรียก the corresponding interrupt service routine แล้ว.


tha

ผู้ใช้สามารถเลือกลำดับความสำคัญที่เกี่ยวข้องกันของ pending USB_ISTR events ที่พร้อมกันโดยระบุลำดับขั้นที่ software ตรวจสอบ USB_ISTR bits ใน an interrupt service routine. เฉพาะบิตที่เกี่ยวข้องกับ events, ที่ถูกให้บริการ, จะถูกเคลียร์. ที่ the end of the service routine, interrupt อื่นจะถูกร้องขอ, เพื่อให้บริการ the remaining conditions.

เพื่อหลีกเลี่ยงการเคลียร์เทียมของบางบิต, ขอแนะนำให้เคลียร์พวกมันด้วยคำสั่ง load ที่ทุกบิตซึ่งต้องไม่ถูกเปลี่ยนแปลงเมื่อถูกเขียนด้วย 1, และทุกบิตจะถูกเคลียร์เมื่อถูกเขียนด้วย '0 (บิตเหล่านี้สามารถถูกเคลียร์โดย software เท่านั้น). Read-modify-write cycles ควรถูกหลีกเลี่ยงเนื่องจากระหว่าง the read and the write operations บิตอื่นอาจจะถูกเซ็ตโดย the hardware และ the next write จะเคลียร์มันก่อนที่ the microprocessor จะมีเวลาให้บริการ the event.

tha

Bit 15 CTR: Correct transfer
บิตนี้ถูกเซ็ตโดย the hardware เพื่อแสดงให้เห็นว่า an endpoint สำเร็จเสร็จสมบูรณ์ a transaction; โดยใช้ DIR and EP_ID bits software สามารถกำหนดซึ่ง endpoint ที่ร้องขอ the interrupt. บิตนี้ถูกอ่านได้เพียงอย่างเดียว.

Bit 14 PMAOVR: Packet memory area over / underrun
บิตนี้ถูกเซ็ตถ้า the microcontroller ไม่สามารถตอบสนองให้ทันเวลาต่อ an USB memory request. The USB peripheral จัดการ event นี้ด้วยวิธีต่อไปนี้: ในระหว่าง reception an ACK handshake packet ไม่ถูกส่ง, ในระหว่าง transmission a bit-stuff error ถูกบังคับบน the transmitted stream; ในทั้งสองกรณ๊ the host จะลองทำ the transaction อีกครั้ง. The PMAOVR interrupt ไม่ควรเกิดขึ้นในระหว่าง normal operations. เนื่องจาก the failed transaction ถูกทำอีกครั้งโดย the host, the application software มีโอกาศเร่งความเร็ว device operations ในระหว่างการจัดการ interrupt นี้, เพื่อให้พร้อมสำหรับ the next transaction retry; อย่างไรก็ตามสิ่งนี้จะไม่เกิดขึ้นในระหว่าง Isochronous transfers (ไม่มี isochronous transaction ถูกทำอีกครั้งอีกต่อไป) นำมาซึ่งการสูญเสียของ data ในกรณีนี้. บิตนี้ถูกอ่าน/เขียนได้แต่มีเพียง '0 เท่านั้นที่สามารถถูกเขียนและการเขียน '1 ไม่มีผลอะไร.

tha

Bit 13 ERR: Error
flag นี้ถูกเซ็ตเมื่อหนึ่งของ the errors ที่แสดงรายการข้างล่างนี้เกิดขึ้น :
NANS: No ANSwer. หมดเวลาสำหรับ a host response ได้หมดลง.
CRC: Cyclic Redundancy Check error. หนึ่งของ the received CRCs, อย่างใดอย่างหนึ่งใน the token หรือใน the data, ผิด.
BST: Bit Stuffing error. A bit stuffing error ถูกตรวจพบแล้วที่ใดที่หนึ่งใน the PID, data, และ/หรือ CRC.
FVIO: Framing format Violation. A non-standard frame ถูกรับแล้ว (EOP ไม่อยู่ในตำแหน่งที่ถูก, wrong token sequence, ฯลฯ).
The USB software สามารถเพิกเฉย errors โดยปกติ, เนื่องจาก the USB peripheral และ the PC host จัดการ retransmission ในกรณีของ errors ในวิธีที่โปร่งใสเต็มที่. interrupt นี้สามารถมีประโยชน์ในระหว่าง the software development phase, หรือเพื่อมอนิเตอร์คุณภาพของ transmission บน the USB bus, เพื่อ flag ปัญหาที่เป็นไปได้ไปยังผู้ใช้ (อย่างเช่น loose connector, too noisy environment, broken conductor ใน the USB cable และอื่นๆ). บิตนี้ถูกอ่าน/เขียนได้แต่มีเพียง '0 เท่านั้นสามารถถูกเขียนและการเขียน '1 ไม่มีผลอะไร.

tha

Bit 12 WKUP: Wakeup
บิตนี้ถูกเซ็ตเป็น 1 โดย the hardware เมื่อ, ในระหว่าง suspend mode, กิจกรรมถูกตรวจพบว่าปลุก the USB peripheral. event นี้เคลียร๋แบบอซิงโครนัส the LP_MODE bit ใน the CTLR register และทำให้ทำงาน the USB_WAKEUP line, ซึ่งสามารถถูกใช้เพื่อแจ้งให้ทราบส่วนที่เหลือของ the device (อย่างเช่น wakeup unit) เกี่ยวกับการสตาร์ทของ the resume process. บิตนี้ถูกอ่าน/เขียนได้แต่มีเพียง '0 เท่านั้นสามารถถูกเขียนและการเขียน '1 ไม่มีผลอะไร.

Bit 11 SUSP: Suspend mode request
บิตนี้ถูกเซ็ตโดย the hardware เมื่อไม่มีการรับส่งข้อมูลถูกรับเป็นเวลา 3mS, แสดงให้เห็น a suspend mode request จาก the USB bus. The suspend condition check ถูกเปิดการใช้งานทันทีหลังจาก USB reset ใดๆและมันถูกปิดการใช้งานโดย the hardware เมื่อ the suspend mode ทำงาน (FSUSP=1) จนกระทั่ง the end of resume sequence. บิตนี้ถูกอ่าน/เขียนได้แต่มีเพียง '0 เท่านั้นสามารถถูกเขียนและการเขียน '1 ไม่มีผลอะไร.

tha

Bit 10 RESET: USB reset request
เซ็ตเมื่อ the USB peripheral ตรวจพบ an active USB RESET signal ที่ inputs ของมัน. The USB peripheral, ในการตอบสนองต่อ a RESET, เพียงแค่รีเซ็ต internal protocol state machine ของมัน, สร้างขึ้น an interrupt ถ้า RESETM enable bit ใน the USB_CNTR register ถูกเซ็ต. Reception and transmission ถูกปิดการใช้งานจนกระทั่ง the RESET bit ถูกเคลียร์. All configuration registers ไม่รีเซ็ต: the microcontroller ต้องเคลียร์อย่างชัดแจ้ง registers เหล่านี้ (นี้เพื่อให้แน่ใจว่า the RESET interrupt สามารถถูกจัดส่งอย่างปลอดภัย, และ transaction ใดๆทันทีที่ตามด้วย a RESET สามารถถูกทำให้เสร็จสมบูรณ์). The function address and endpoint registers ถูกรีเซ็ตโดย an USB reset event.
บิตนี้ถูกอ่าน/เขียนได้แต่มีเพียง '0 เท่านั้นสามารถถูกเขียนและการเขียน '1 ไม่มีผลอะไร.