Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - tha

#3513
ARM Processors / Re: STM32F1 USART
January 17, 2021, 09:59:22 AM
Configurable stop bits

จำนวนของ stop bits ที่จะถูกส่งพร้อมกับทุกๆ character สามารถถูกโปรแกรมใน Control register 2, bits 13,12.
1.    1 stop bit: นี้เป็นค่าเริ่มต้น.
2.    2 stop bits: นี้ถูกรองรับโดย USART ปกติ, single-wire และ modem modes.
3.    0.5 stop bit: ถูกใช้เมื่อ receiving data ใน Smartcard mode.
4.    1.5 stop bits: ถูกใช้เมื่อ transmitting and receiving data in Smartcard mode

An idle frame transmission จะรวม the stop bits เข้าด้วย.

A break transmission จะเป็น 10 low bits ตามด้วยจำนวนที่กำหนดค่าได้ของ stop bits (เมื่อ m = 0) และ 11 low bits ตามด้วยจำนวนที่กำหนดค่าได้ของ stop bits (เมื่อ m = 1). มันเป็นไปไม่ได้ที่จะส่ง long breaks (break ของความยาวที่มากกว่า 10/11 low bits).



ขั้นตอน:
1.    เปิดการใช้งาน the USART โดยการเขียน the UE bit ใน USART_CR1 register เป็น 1.
2.    โปรแกรม the M bit ใน USART_CR1 เพื่อกำหนด the word length
3.    โปรแกรมจำนวนของ stop bits ใน USART_CR2
4.    เลือก DMA enable (DMAT) ใน USART_CR3 ถ้า Multi buffer Communication ถูกนำมาใช้. กำหนดค่า the DMA register
       ดังอธิบายใน multibuffer communication.
5.    เลือก the desired baud rate โดยใช้ the USART_BRR register.
6.    เซ็ต the TE bit ใน USART_CR1 เพื่อส่ง an idle frame เป็น first transmission.
7.    เขียน the data ที่จะส่งใน the USART_DR register (นี้จะเคลียร์ the TXE bit). ทำซ้ำอย่างนี้สำหรับแต่ละ data ที่จะถูกส่งในกรณี
       ของ single buffer.
8.    หลังจากการเขียน the last data ลงใน the USART_DR register, คอยจนกระทั่ง TC=1. นี้แสดงให้เห็นว่า the transmission
       ของ the last frame เสร็จสมบูรณ์. นี้ถูกต้องการอย่างเช่นเมื่อ the USART ถูกปิดการใช้งานหรือเข้าสู่ the Halt mode เพื่อหลีก
       เลี่ยงการเสียหาย the last transmission.
#3514
ARM Processors / Re: STM32F1 USART
January 17, 2021, 09:03:35 AM
27.3.2 Transmitter

The transmitter สามารถส่ง data words ของอย่างใดอย่างหนึ่ง 8 หรือ 9 bits ขึ้นอยู่กับ the M bit status. เมื่อ the transmit enable bit (TE) ถูกเซ็ต, the data ใน the transmit shift register ถูกส่งออกไปบน the TX pin และ the corresponding clock pulses ถูกส่งออกไปบน the CK pin.

Character transmission

ในระหว่าง a USART transmission, data เลื่อนออก least significant bit เป็นอันดับแรกไปบน the TX pin. ในโหมดนี้, the USART_DR register ประกอบด้วย a buffer (TDR) ระหว่าง the internal bus และ the transmit shift register (ดู Figure 279).

ทุกๆ character ถูกนำหน้าด้วย a start bit, ซึ่งเป็น a logic level low เป็นเวลา one bit period. The character ถูกปิดท้ายด้วย จำนวนที่กำหนดค่าได้ของ stop bits.

The following stop bits ถูกรองรับโดย USART: 0.5, 1, 1.5 and 2 stop bits.

Note: The TE bit ไม่ควรถูกรีเซ็ตในระหว่าง transmission of data. การรีเซ็ต the TE bit ในระหว่าง the transmission จะทำความ
           เสียหายให้ the data บน the TX pin ดังที่ the baud rate counters จะได้รับการแช่แข็ง. The current data ที่กำลังถูกส่งจะ
           สูญหาย.

            An idle frame จะถูกส่งหลังจาก the TE bit ถูก enabled.
#3515
ARM Processors / Re: STM32F1 USART
January 17, 2021, 05:04:11 AM
27.3.1 USART character description

Word length อาจถูกเลือกให้เป็นอย่างใดอย่างหนึ่ง 8 หรือ 9 bits โดยการโปรแกรม the M bit ใน the USART_CR1 register (ดู Figure 280).

The TX pin อยู่ใน low state ในระหว่าง the start bit. มันอยู่ใน high state ในระหว่าง the stop bit.

An Idle character ถูกตีความหมายว่าเป็นเฟรมทั้งหมดของ" 1" ตามด้วย the start bit ของ the next frame ซึ่งบรรจุ data (จำนวนของ "1" 's จะรวมถึงจำนวนของ stop bits).

A Break character ถูกตีความหมายบนการรับ "0"s สำหรับ a frame period. ที่ the end of the break frame the transmitter แทรกอย่างใดอย่างหนึ่ง 1 or 2 stop bits (logic "1" bit) เพื่อ acknowledge the start bit.

Transmission and reception ถูกขับโดย a common baud rate generator, the clock สำหรับแต่ละตัวนั้นถูกสร้างขึ้นเมื่อ the enable bit ถูกเซ็ตสำหรับ the transmitter and receiver ตามลำดับ

รายละเอียดของแต่ละ block ถูกให้ไว้ด้านล่างนี้.

#3516
ARM Processors / Re: STM32F1 USART
January 16, 2021, 11:44:41 AM
27.3 USART functional description

The interface ถูกต่อภายนอกไปยัง device อื่นโดย three pins (ดู Figure 279). Any USART bidirectional communication ต้องการอย่างต่ำ two pins: Receive Data In (RX) และ Transmit Data Out (TX):

RX: Receive Data Input เป็น the serial data input. Oversampling techniques ถูกใช้สำหรับการกู้คืน data โดยการแยกแยะระหว่าง valid incoming data และ noise.

TX: Transmit Data Output. เมื่อ the transmitter ถูกปิดการใช้งาน, the output pin คืนกลับไปยัง IO port configuration ของมัน. เมื่อ the transmitter ถูกเปิดการใช้งานและไม่มีอะไรถูกส่ง, the TX pin จะอยู่ที่ high level. ใน single-wire และ smartcard modes, IO นี้ถูกใช้ส่งและรับ the data (ที่ USART level, data จากนั้นถูกรับบน SW_RX).

ผ่านทางพินเหล่านี้, serial data ถูก transmitted และ received ใน normal USART mode เป็น frames ประกอบด้วย:
•    An Idle Line ก่อนที่จะ transmission หรือ reception
•    A start bit
•    A data word (8 or 9 bits) least significant bit first(เป็นอันดับแรก)
•    0.5,1, 1.5, 2 Stop bits แสดงให้เห็นว่า the frame เสร็จสมบูรณ์
•    interface นี้ใช้ a fractional baud rate generator - ด้วย a 12-bit เป็นตัวเลขที่อยู่ทางขวาของจุดและ 4-bit เป็นเศษส่วน
•    A status register (USART_SR)
•    Data register (USART_DR)
•    A baud rate register (USART_BRR) - 12-bit เป็นตัวเลขที่อยู่ทางขวาของจุดและ 4-bit เป็นเศษส่วน
•    A Guardtime Register (USART_GTPR) ในกรณีของ Smartcard mode.

อ้างอิงถึง Section 27.6: USART registers สำหรับคำจำกัดความของแต่ละบิต

พินต่อไปนี้ถูกต้องการเพื่อเชื่อมต่อใน synchronous mode:
•    CK: Transmitter clock output. พินนี้ส่งออก the transmitter data clock สำหรับ synchronous transmission ตรง
      กันกับ SPI master mode (ไม่มี clock pulses บน start bit และ stop bit, และ a software มีทางเลือกที่จะส่ง a clock pulse
      บน the last data bit). ใน parallel data สามารถถูกรับแบบ synchronously บน RX. นี้สามารถถูกใช้เพื่อควบคุม peripherals ที่
      มี shift registers (ตัวอย่างเช่น LCD drivers). The clock phase และ polarity โปรแกรมได้ทาง software. ใน Smartcard
      mode, CK สามารถจัดให้มี the clock ไปยัง the smartcard.

พินต่อไปนี้ถูกต้องการใน Hardware flow control mode:
•    CTS: Clear To Send บล็อก the data transmission ที่ the end of the current transfer เมื่อ high
•    RTS: Request to send แสดงให้เห็นว่า the USART พร้อมที่จะรับ a data (เมื่อ low).

#3517
ARM Processors / Re: STM32F1 USART
January 16, 2021, 09:44:34 AM
27.2 USART main features

•    Full duplex, asynchronous communications
•    NRZ standard format (Mark/Space)
•    Fractional baud rate generator systems
      –    A common programmable transmit and receive baud rates สูงถึง 4.5 MBits/s
•    Programmable data word length (8 or 9 bits)
•    กำหนดค่าได้ stop bits - รองรับสำหรับ 1 or 2 stop bits
•    LIN Master Synchronous Break send capability and LIN slave break detection capability
      –    13-bit break generation and 10/11 bit break detection เมื่อ USART เป็น hardware ที่กำหนดค่าสำหรับ LIN
•    Transmitter clock output for synchronous transmission
•    IrDA SIR Encoder Decoder
      –    รองรับสำหรับ 3/16 bit duration for normal mode
•    Smartcard Emulation Capability
      –    The Smartcard interface รองรับ the asynchronous protocol Smartcards ตามที่กำหนดใน ISO 7816-3 standards
      –    0.5, 1.5 Stop Bits for Smartcard operation
•    Single wire half duplex communication
•    กำหนดค่าได้ multibuffer communication โดยใช้ DMA (direct memory access)
      –    Buffering ของ received/transmitted bytes ใน reserved SRAM โดยใช้ centralized DMA
•    Separate(แยกกัน) enable bits สำหรับ Transmitter and Receiver
•    Transfer detection flags:
      –    Receive buffer full
      –    Transmit buffer empty
      –    End of Transmission flags
•    Parity control:
      –    Transmits parity bit
      –    Checks parity of received data byte
•    Four error detection flags:
      –    Overrun error
      –    Noise error
      –    Frame error
      –    Parity error
•    Ten interrupt sources with flags:
      –    CTS changes
      –    LIN break detection
      –    Transmit data register empty
      –    Transmission complete
      –    Receive data register full
      –    Idle line received
      –    Overrun error
      –    Framing error
      –    Noise error
      –    Parity error
•    Multiprocessor communication - เข้าสู่ mute mode ถ้า address match ไม่เกิดขึ้น
•    Wake up from mute mode (by idle line detection or address mark detection)
•    Two receiver wakeup modes: Address bit (MSB, 9th bit), Idle line
#3518
ARM Processors / STM32F1 USART
January 16, 2021, 07:14:07 AM
27 Universal synchronous asynchronous receiver transmitter (USART)

Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
High-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.
XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 768 Kbytes and 1 Mbyte.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.

ส่วนนี้ใช้กับตระกูล STM32F10xxx ทั้งหมดเว้นแต่จะระบุไว้เป็นอย่างอื่น

27.1 USART introduction

The universal synchronous asynchronous receiver transmitter (USART) เสนอวิธีการที่หยืดหยุ่นของ full-duplex data exchange กับ external equipment ที่ต้องการ an industry standard NRZ asynchronous serial data format. The USART เสนอ a very wide range ของ baud rates โดยใช้ a fractional baud rate generator.

มันรองรับ synchronous one-way communication และ half-duplex single wire communication. มันยังรองรับ the LIN (local interconnection network), Smartcard Protocol และ IrDA (infrared data association) SIR ENDEC specifications, และ modem operations (CTS/RTS). มันยอมให้ multiprocessor communication

High speed data communication สามารถเป็นได้โดยการใช้ the DMA สำหรับ multibuffer configuration.
#3519
ARM Processors / STM32F1 Programming Manual
January 16, 2021, 06:11:52 AM
PM0056
Programming manual
STM32F10xxx/20xxx/21xxx/L1xxxx
Cortex®-M3 programming manual


Introduction

programming manual นี้จัดให้มีข้อมูลสำหรับ application และ system-level software developers. มันให้คำอธิบายอย่างเต็มของ the STM32F10xxx/20xxx/21xxx/L1xxxx Cortex®-M3 processor programming model, instruction set และ core peripherals

The STM32F10xxx/20xxx/21xxx/L1xxxx Cortex®-M3 processor คือ a high performance 32-bit processor ถูกออกแบบมาสำหรับ the microcontroller market. มันเสนอประโยชน์อย่างมีนัยสำคัญแก่นักพัฒนา, ได้แก่
•    processing performance ที่โดดเด่นรวมกันกับ a fast interrupt handling
•    Enhanced system debug พร้อมด้วย extensive breakpoint และ trace capabilities
•    Efficient processor core, system and memories
•    Ultra-low-power consumption พร้อมด้วย integrated sleep modes
•    Platform security
#3520
ARM Processors / Re: STM32F1 I2C
January 15, 2021, 10:18:45 AM