RS485 communication must have been known to everyone, when learning RS232, will take 485 (RS485 will be replaced with 485 below) and its comparison. 485 advantages and disadvantages do not say, there are online.
I use the STM32 library function 485 communication, so the following will talk about STM32 serial 485 dual-machine communication principle:
485 and 232 are based on the serial port communication interface, and are consistent in data receiving and sending operations. But the communication mode between them is quite different ~! 232 is full duplex (example: A->B at the same time B->A, instantaneous synchronization) mode of operation, and 485 is half duplex (can not be received at the time of collection, receive Can not send) work mode. In the 232 communication, the host can receive the data sent from the slave at the same time when sending data; but in the 485 communication, the sending and receiving will go through the mode bit switch, for example, when sending data, the mode will be set to '1' ', indicated as a transmission mode, can not be received at this time; when receiving data, the mode position '0' is indicated as a receiving mode, and cannot be transmitted at this time.
Before talking about the principle of STM32 serial port to achieve 485 dual-computer communication, first review the interrupt knowledge points in the serial port:
There are many types of interrupts in the serial port. Here mainly speaking two kinds: Receive data interrupt and send data to finish interrupt. These two interrupts are closely related to the two flag bits: RXNE (Read Data Register Not Empty) and TC (Send Complete). For example, when receiving data (RXNE, read data register is not empty), we want to generate an interrupt. At the end of the transmission data (TC, transmission is completed) an interrupt is generated. Both interrupt generation methods are configured in the open serial interrupt function (USART_ITConfig();). And in the interrupt status function (USART_ITStatus();) to determine whether to send interrupt or interrupt.
note:
01. Someone asked when interrupts were generated, did not see the program clear the interrupt flag, ah, it has not been interrupted? There are two official ways to clear the interrupt flag (the book also has): 1, as soon as possible to read USART_DR (data register), this bit can be cleared by reading USART_DR; 2. It can directly write '0' to this bit and clear it directly. 02. The serial baud rate of the two boards must be the same, otherwise the desired data will not be available.
STM32 serial port realizes the principle of 485 dual-computer communication (library function):
1, in the main function, scan the button. Once key0 is pressed, the first five bytes of data are stored in the rs485buf[] array, and then RS485_Send_Data(rs485buf,5) is called; the function sends 5 bytes of data to the serial port.
2. Enter RS485_Send_Data(); In the function, first set the 485 to the sending mode (RS485_TX_EN=1) through the flag bit, and then cycle 5 times. Pass the 5 bytes of data through the library function: USART_Send_Data(); Send to USART_DR Register (automatically send), finally set 485 to receive mode (RS485_TX_EN=0) by the flag bit.
3, the first two are sent. It is now receiving. The main function passes RS485_Receive_Data(); it keeps receiving. 4, enter the RS485_Receive_Data (); function, if you have not pressed the button, it will not send data, it will not generate a receive interrupt, it will not write data to our defined receive buffer (RS485_RX_BUF [64]) . RS485_RX_CNT counter value is also '0', corresponding to the if statement in the RS485_Receive_Data(); function will not enter the inside (red box in the figure below)
If the button is pressed, data will be sent, a receive interrupt will be generated, and data will be written to the defined receive buffer (RS485_RX_BUF[64]). The value of the RS485_RX_CNT counter will also start incrementing, corresponding to RS485_Receive_Data( ); The function will enter the if statement inside, from the previously defined receive buffer (RS485_RX_BUF [64]) inside to take data.
5. Finally, the retrieved data (received data) is displayed.
Microphone:
Microphone is a kind of electrets microphone unit for audio input. It is a transducer which can transduce audio signal into electric signal. It is also called receiver. It is widely used in many industries which need audio input.
Our main microphones include:
1) From the diameter: we have microphones in 4mm~10mm.
2) From the direction, we have omni-direactional and one-directional micphones.
FAQ
Q1. What
is the MOQ?
XDEC: 2000pcs for one model.
Q2. What is the delivery lead time?
XDEC: 15 days for normal orders, 10 days for urgent orders.
Q3. What are the payment methods?
XDEC: T/T, PayPal, Western Union, Money Gram.
Q4. Can you offer samples for testing?
XDEC: Yes, we offer free samples.
Q5. How soon can you send samples?
XDEC: We can send samples in 3-5 days.
Electric Microphones,Usb Microphone,Digital Microphone,Stage Microphone
Shenzhen Xuanda Electronics Co., Ltd. , https://www.xdecspeaker.com