2008-06-17 21:56:17 RS232 on stamp board.
DAVID ZHOU (CHINA)
Message: 57437
In my project, I want implement CTS signal and RTS signal in RS232 interface. But I find nothing on this topic , can anybody show it to me ? Thanks.
I have seen the schematic of my stamp board, it use two GPIO for this two signal. So how should I do?
Thanks in advance!
QuoteReplyEditDelete
2008-06-17 22:21:51 Re: RS232 on stamp board.
Robin Getz (UNITED STATES)
Message: 57442
David:
The UART on the BF537 does not support hardware flow control, so we emulate it with GPIOs. You can pick these via Kconfig.
-Robin
QuoteReplyEditDelete
2008-06-17 23:05:23 Re: RS232 on stamp board.
DAVID ZHOU (CHINA)
Message: 57446
Hi Robin,
Thanks! I have already config it in Kconfig. But I still do not know how to use it. Could you show it to me ?
QuoteReplyEditDelete
2008-06-18 00:43:09 Re: RS232 on stamp board.
Mike Frysinger (UNITED STATES)
Message: 57448
what are you looking for ? you set the two gpio pins to use in the kconfig and then wire things up correctly. then it behaves exactly like normal CTS/RTS.
QuoteReplyEditDelete
2008-06-18 01:59:11 Re: RS232 on stamp board.
DAVID ZHOU (CHINA)
Message: 57451
Hi Mike,
Thanks! You mean that I need to request the two gpios and then set/clear it ?
I mean that I just do it in my user space program. Do you offer any interface for us to control it? Like ioctl and thing like that.
Another question, I just use ttyBFX to control the serial ports and when I need to transmit some data, I just use write system call to do it. But I find that there may be some buffer between my write and the real hardware. When my write call return, the data may not send to hardware to send out. So how should I do to know all the datas are sent into hardware and sent out ?
QuoteReplyEditDelete
2008-06-18 02:06:44 Re: RS232 on stamp board.
Mike Frysinger (UNITED STATES)
Message: 57454
GPIO based CTS/RTS operates exactly the same as normal. there is nothing special you need to do in order to emulate things with GPIO other than to enable the option in the kernel configuration menu.
if you arent familiar with how to use a serial port, then please read the documentation about termios:
http://docs.blackfin.uclinux.org/doku.php?id=serial_driver
QuoteReplyEditDelete
2008-06-18 03:06:03 Re: RS232 on stamp board.
DAVID ZHOU (CHINA)
Message: 57457
Hi Mike,
Thank you very much ! I have already see that docs.
Now I meet one problem, I use ttyBF1 to transmit data and I also config ttyBF1 to raw mode.
in my use space program:
step1: set gpio to 1
step 2: write datas to ttyBF1 // use write system call
step 3: set gpio to 0
I use scope to minitor the gpio line and the serial port TX line. Only find that:
GPIO line change from 1 to 0 before all of the datas appear on the TX line of UART1 .
I alse examine the write system call, it returns OK. That means that when write system call return, the data may still buffered. So what should I do to make sure all the data are sent to TX line before set gpio into 0?
Thanks! Any one who know please help me ! Thanks!
QuoteReplyEditDelete
2008-06-18 04:52:06 Re: RS232 on stamp board.
Mike Frysinger (UNITED STATES)
Message: 57502
read the documentation referred to in the wiki. things will always be queued up unless you use the proper termios functions.
QuoteReplyEditDelete
2008-08-08 03:46:43 Re: RS232 on stamp board.
DAVID ZHOU (CHINA)
Message: 60141
Hi Mike and All,
I have read the TTY documents and still have problem. It is probaly something wrong in your serial port driver or tty driver. I have used tcdrain() function which will make all data transfered.
This is the defination of tcdrain:
tcdrain() waits until all output written to the object referred to by fd has been transmitted.
But according my test: After tcdrain() returned, there are still one or two bytes not written into UART's UART_THR register.
I also have used scope to capture the data wave on the Tx line of the UART.
Do your driver have any interface to let me know all the data I wrote into ttyBFX have been send into hardware and transmit out of the chip ?
Thanks a lot !
QuoteReplyEditDelete
2008-08-08 10:50:51 Re: RS232 on stamp board.
Mike Frysinger (UNITED STATES)
Message: 60171
we've tested tcdrain() heavily in 2008R1+ and are confident it works fine. if you review the driver, you'll see that it tests the TEMT bit which corresponds to everything being shifted out of the FIFO and the shift register.
you'd have to provide a reproducible test case in order for us to look at it.
QuoteReplyEditDelete
2008-08-10 22:30:15 回复: Re: RS232 on stamp board.
DAVID ZHOU (CHINA)
Message: 60213
Thanks a lot, Mike !
My test case is :
1. open ttyBF1, set ttyBF1 into RAW mode( ignore all control chars of serical port )
2. ioctl set GPIO PG0 into 1
3. write data into ttyBF1 .(test different length of data)
4. call tcdrain()
5. ioctl set GPIO PG0 into 0
6. repeat 1 to 5
I used scope to monitor PG0 and UART1 TX pin. Only find that for short length of data, most of the times are OK, But if the
length of the data reaches 100 to 200 bytes, it can be obvious seen form the scope many times: GPIO PG0 's falling edge will be in front of the last one or two bits of the last byte from the UART'S TX pin. I confused with this problem for a long time.