|
|
View previous topic :: View next topic |
Author |
Message |
sonya27y Guest
|
MScomm1 with PICC |
Posted: Wed Mar 28, 2007 2:27 am |
|
|
I am writing a code in PICC to receive RS232 data 9600,N,8,1 from Visual Basic 5 or 6. I am using the simple PICC command:
if (InByte = 0X02)
{
putc(0x0A);
delay_us (700);
Temp = InByte ; // both are bytes char
}
to receive data via RS232 in PICC. What Visual Basic command code should I use to send InByte from within VB? How it should be defined?
How about sending from PICC and receiving from VB?
I am using MSComm1 VB command. |
|
|
Ttelmah Guest
|
|
Posted: Wed Mar 28, 2007 2:52 am |
|
|
First comment. Nothing you show in the posted code, _receives_ characters, yet you say you are using this 'to receive data via RS232 in PICC'...
Look at getc.
You are already 'sending data'. This is what _putc_ does...
The MSCOMM control in VB, is not the greatest serial handler around (it explains a lot of serial problems in application!), but can work well if handled carefully. There are two different setup 'modes' for the control (text or binary). Probably the easiest to use, will be 'text', and if you have the control called 'MSCom', set in this mode, then:
MSCom.output = chr$(&H0A)
Will send the same decimal '10' character, as the putc(0xa) shown in your C.
Best Wishes |
|
|
davekelly
Joined: 04 Oct 2006 Posts: 53 Location: Berkshire, England
|
Re: MScomm1 with PICC |
Posted: Wed Mar 28, 2007 7:43 am |
|
|
sonya27y wrote: |
if (InByte = 0X02)
{
putc(0x0A);
delay_us (700);
Temp = InByte ; // both are bytes char
}
|
Another small comment: the test for equality should use '==', else it is an assignment. ie use
Code: |
if (InByte == 0X02)
{
...
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|