3319 views|3 replies

2

Posts

0

Resources
The OP
 

Shared serial port problem [Copy link]

      Seeing that everyone is tossing Tesla coils, I have nothing to do and want to teach a lesson to my not-so-good refrigerator at home. The refrigerator was originally a three-door computer version refrigerator, but the refrigerator compartment was full of ice (without stopping). After careful observation, it was found that the temperature detected by the 6-year-old microcontroller was deviated, and the detected temperature was higher than the actual temperature. I thought about adding a temperature correction compensation, the actual working time of each room, the working time of the compressor this time, and remote viewing in conjunction with the serial port wireless module... Now the problem is that the refrigerator uses two PIC16F690 microcontrollers, one for input and display, and one for main control. The microcontroller has only one serial port, and the communication between the two microcontrollers has been used. I want to use the IO port to simulate the serial port, but it is troublesome and I heard that it is easy to make mistakes. Suddenly, I thought, can I use the bidirectional 74HC245 to solve the problem. The hand-drawn picture is attached. Professionals and amateurs, please help to see if it is feasible.

共享串口.jpg (343.54 KB, downloads: 0)

共享串口.jpg
This post is from Microchip MCU

Latest reply

It is definitely possible to simulate the serial port with IO. Now there is no IO available?   Details Published on 2018-6-27 16:53
 

4005

Posts

0

Resources
2
 
Wow, you are awesome, you can DIY home appliances!
This post is from Microchip MCU
 
 
 

31

Posts

0

Resources
3
 
  Serial port programming involves many problems. For real-time acquisition systems, serial port programming must obey the system timer acquisition rhythm. In this way, receiving serial port data through events and then delaying will cause many problems. Serial port data usually does not arrive at one time. For a relatively long data, the serial port event may be triggered two or three times. If each event is triggered, it must be delayed (using system.threading.thread.sleep(500) to delay 500 milliseconds), causing thread blocking. After three times, the delay is 1500 milliseconds, which is bound to have a great impact on the acquisition that requires a timing rhythm. Therefore, consider storing in batches, and then use the termination bit to determine whether the reading is completed. The following reference method can be used in the middle of the receiving function logic. Paimingxincheng Tel: 400-693-8369 private void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { byte[] bytin = new byte[this.comPort.BytesToRead]; comPort.Read(bytin, 0, bytin.Length);//Read serial port datafor (int i = 0; i < bytin.Length; i++) bufferList.Add(bytin[i]);//Store in the cache array in order//When the number of cached data bits is equal to the expected number of bits, it is considered that the reception is completeif (bufferList.Count==this.recieveByteNum) { IEnumerator ie=bufferList.GetEnumerator(); byte[] tmpbyte=new byte[this.recieveByteNum]; for(int i=0;ie.MoveNext();i++) tmpbyte[i]=(byte)ie.Current; doSomethingElse(); } }
This post is from Microchip MCU
 
Personal signaturehttps://www.iczoom.com
 
 

189

Posts

5

Resources
4
 
It is definitely possible to simulate the serial port with IO. Now there is no IO available?
This post is from Microchip MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list