air1kdf
- 15th December 2005, 02:37
I have been reading a lot of posts on here absorbing information like a sponge, so I thought that I could give back a little. I wanted to send serial data via hserout. All is well. I'm using a 4 Mhz oscillator with a 16F876A chip. The serial data thing was suprpising for me when sending a word. I wanted to save some bandwidth, so I'm sending binary data. If you specify.
hserout [MyWord]
It will only send the LowByte. So you will need to send it as...
hserout [MyWord.lowbyte, MyWord.highbyte]
or
hserout [MyWord.Byte0, MyWord.Byte1]
First the connect string needs to be a little different in VB. I use this.
MSComm1.Settings = "19200,n,8,1"
MSComm1.DTREnable = False
MSComm1.RThreshold = 1
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeBinary
MSComm1.CommPort = 4
MSComm1.PortOpen = True
Private Sub MSComm1_OnComm()
Dim ByteArray() As Byte
Select Case MSComm1.CommEvent
Case comEvReceive
ByteArray = MSComm1.Input
...
This is the VB function that I wrote.
'Convert 2 bytes into a 4 byte vb long
Private Function MakeWord(LowByte As Byte, HighByte As Byte) As Long
MakeWord = (HighByte * &H100&) Or LowByte
End Function
Now I am new to PIC programming, but am a professional programmer. There may be a register to set or something to send the whole word in one shot. But I noticed that every example that I saw here used DEC MyWord, #MyWord, or something similiar, which kills bandwidth.
This information would have saved me a couple of days. Enjoy!
Regards,
Kurt
hserout [MyWord]
It will only send the LowByte. So you will need to send it as...
hserout [MyWord.lowbyte, MyWord.highbyte]
or
hserout [MyWord.Byte0, MyWord.Byte1]
First the connect string needs to be a little different in VB. I use this.
MSComm1.Settings = "19200,n,8,1"
MSComm1.DTREnable = False
MSComm1.RThreshold = 1
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeBinary
MSComm1.CommPort = 4
MSComm1.PortOpen = True
Private Sub MSComm1_OnComm()
Dim ByteArray() As Byte
Select Case MSComm1.CommEvent
Case comEvReceive
ByteArray = MSComm1.Input
...
This is the VB function that I wrote.
'Convert 2 bytes into a 4 byte vb long
Private Function MakeWord(LowByte As Byte, HighByte As Byte) As Long
MakeWord = (HighByte * &H100&) Or LowByte
End Function
Now I am new to PIC programming, but am a professional programmer. There may be a register to set or something to send the whole word in one shot. But I noticed that every example that I saw here used DEC MyWord, #MyWord, or something similiar, which kills bandwidth.
This information would have saved me a couple of days. Enjoy!
Regards,
Kurt