串口不发送号码“255”。到pic18f2550微芯片 [英] Serial port not sending number "255" to pic18f2550 microchip

查看:70
本文介绍了串口不发送号码“255”。到pic18f2550微芯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vb express 2010

我可以将除255以外的所有数字发送到pic18f2550微芯片。

所以所有8位都在使用。 com1.ReadTimeout = 10000

baudRate = 128000 parity = IO.Ports.Parity.None dataBits = 8

com1 = My.Computer.Ports.OpenSerialPort(port,baudRate, parity,dataBits)

Dim processerse_CMD()As Byte = {w}

com1.Write(processer_CMD,0,processer_CMD.Length)工作正常a到Z

Threading.Thread.Sleep(35)



Dim process_CMD()As Byte = {255} == ====== 不工作 = 25511111111

com1.Write(process_CMD,0,process_CMD.Length)

线程。 Thread.Sleep(35)



Dim processs_CMD()By Byte = {247} ======== 工作正常 0到25411111110

com1.Write(processs_CMD,0,processs_CMD.Length)

Threading.Thread.Sleep(35)



收到所有罚款,包括255



我的尝试:



尝试了不同的发送方式,例如Assci 255 =:y ;; Threading.Thread.Sleep

改变了微芯片的时间和延迟。但没有任何意义,因为很多

数字在开头和结尾使用数字1。(11110111= 247)11111111= 255

解决方案

从另一端检查开始:串口通常不区分字符,拒绝一些字符,因此另一端更有可能因某些原因丢弃它 - 检查是否存在选择作为中断条件(这通常需要一个帧错误,因为停止位是错误的,但如果你有错误的波特率,奇偶校验或类似的可能)



所以首先从PIC回显字符,并检查你的软件是否正在接收它们 - 发送每个字节并确认它们都没问题,然后再开始假设SerialPort类的一些奇怪的属性。 / BLOCKQUOTE>

vb express 2010
I can send every number except "255" to a pic18f2550 microchip.
So all eight bits are being used. com1.ReadTimeout = 10000
baudRate = 128000 parity = IO.Ports.Parity.None dataBits = 8
com1 = My.Computer.Ports.OpenSerialPort(port, baudRate, parity, dataBits)
Dim processer_CMD() As Byte = {w}
com1.Write(processer_CMD, 0, processer_CMD.Length) WORKS OK "a to Z"
Threading.Thread.Sleep(35)

Dim process_CMD() As Byte = {255} ======== NOT WORKING = 255 "11111111"
com1.Write(process_CMD, 0, process_CMD.Length)
Threading.Thread.Sleep(35)

Dim processs_CMD() As Byte = {247} ======== WORKS OK "0 to 254" "11111110"
com1.Write(processs_CMD, 0, processs_CMD.Length)
Threading.Thread.Sleep(35)

Receives all numbers fine including "255"

What I have tried:

Tried different many ways of sending such as Assci 255= :y ;; Threading.Thread.Sleep
Changed timing and delay in microchip. But does not make any sense, since many
numbers use a number "1" at the start and end.("11110111"= 247) "11111111" = 255

解决方案

Start by checking at the other end: serial ports don't usually discriminate between characters, and refuse some so it's more likely that the other end is discarding it for some reason - check if it is being picked up as a "break" condition (which would normally require a framing error in that the stop bit would be wrong, but if you have the wrong baud rate, parity, or similar it's possible)

So start by echoing characters back from the PIC, and check that your software is receiving them all - send every byte possible and confirm they are all fine before you start assuming some weird property of the SerialPort class.


这篇关于串口不发送号码“255”。到pic18f2550微芯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆