Tags: 18fxx, driverthat, hii, interfacing, matlab, pic, port, programming, serial, usb, via, view

Serial Port send the same data

On Programmer » Matlab

2,010 words with 1 Comments; publish: Wed, 07 May 2008 22:03:00 GMT; (200218.75, « »)

Hi:

I'm interfacing a PC with the pic 18FXX via USB. I'm using a driver

that makes the USB port view as a COM port.

When I send data from the pic y have no problem with it; but when I

send data to the pic using the comand "fwrite" or "fprintf" I always

get a zero value. I suspect that Matlab adds bytes at the beginning

of the stream with 0 value.

At the pic I'm reading one char (a byte).

Does anybody know how Matlab frame it?

Thanks

All Comments

Leave a comment...

  • 1 Comments
    • "Marttin" <mttoliveri.matlab.todaysummary.com.gmail.com> wrote in message

      news:ef3ca5f.-1.matlab.todaysummary.com.webcrossing.raydaftYaTP...

      > Hi:

      > I'm interfacing a PC with the pic 18FXX via USB. I'm using a driver

      > that makes the USB port view as a COM port.

      > When I send data from the pic y have no problem with it; but when I

      > send data to the pic using the comand "fwrite" or "fprintf" I always

      > get a zero value. I suspect that Matlab adds bytes at the beginning

      > of the stream with 0 value.

      > At the pic I'm reading one char (a byte).

      > Does anybody know how Matlab frame it?

      > Thanks

      Hi Marttin

      You may want to check that your serial port settings match your PIC's serial

      port settings.

      With a loopback connector on a serial port, fwrite appears to behave as you

      expect:

      Serial Port Object : Serial-COM4

      Communication Settings

      Port: COM4

      BaudRate: 9600

      Terminator: 'LF'

      Communication State

      Status: open

      RecordStatus: off

      Read/Write State

      TransferStatus: idle

      BytesAvailable: 1

      ValuesReceived: 0

      ValuesSent: 1

      ans =

      97

      ans =

      a

      Serial Port Object : Serial-COM4

      Communication Settings

      Port: COM4

      BaudRate: 9600

      Terminator: 'LF'

      Communication State

      Status: open

      RecordStatus: off

      Read/Write State

      TransferStatus: idle

      BytesAvailable: 0

      ValuesReceived: 1

      ValuesSent: 1

      #1; Wed, 07 May 2008 22:04:00 GMT