- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In a working design I configured my UART core so that it uses CTS/RTS.
But I do not get a simple design running that shall only send integers from a Windws hyperterminal to via the Nios core and back to the hyperterminal. I have double-checked that the CTS/RTS-pins are connected as stated in the Stratix II development board, which I am using. Also I have the same baud rate (115200). On the hyperterminal I have selected "Flow Control: Hardware". However, nothing happens. Can somebody help? Below is the code of my program, which works without CTS/RTS - Hardware Flow Control. # include <stdio.h># include "system.h"# include "alt_types.h"# include <time.h># include <sys/alt_timestamp.h> int main() { int x; FILE* infile; FILE* outfile; infile = fopen("/dev/uart1", "r"); outfile = fopen("/dev/uart1", "w"); printf("System ready!\n"); fprintf(outfile, "System ready!\n\r"); while(1) { // fprintf(outfile,"New Number: "); if (fscanf(infile, "%d", &x)) { fprintf(outfile, "Received: %d\r\n", x); printf("Received: %d\r\n", x); } } return 0; }Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One deviec shall not be open twice before it was closed.
Maybe, io_file = fopen("/dev/uart1", "rw"); .... I just reply it without confirming anything, so please look up some DATASHEET.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use a terminal program (e.g. BRAY's TERMINAL) where you can switch on/off
RTS and where you can see the state of CTS. see file altera_avalon_uart_regs.h you can check CTS at nios side with... uartstatus=IORD_ALTERA_AVALON_UART_STATUS(UART_1_BASE); if(uartstatus&ALTERA_AVALON_UART_STATUS_CTS_MSK) { ... // cts is set (low) } you can set RTS with ... ctrl=IORD_ALTERA_AVALON_UART_CONTROL(UART_1_BASE); ctrl|=ALTERA_AVALON_UART_CONTROL_RTS_MSK; // ctrl&=~ALTERA_AVALON_UART_CONTROL_RTS_MSK; // to clear IOWR_ALTERA_AVALON_UART_CONTROL(UART_1_BASE,ctrl) if CTS is not set, the fast driver will not send any byte, RTS is ignored by the driver, you have to handle it by yourself.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry there was something wrong in my last answer,
the commands to set/reset RTS conflict with the fast driver of the uart. After checking the documetation, There is no information how RTS and CTS is used by the HAL ! There is no description, which flags of the termios structure are supported. How can I set/reset RTS from application ???- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Anyway Fischer,
thanks for your reply that helped me to find Bray's terminal. At least I no now that my NiosCore works with "clean" CTS/RTS mode. But in many applications (hyperterminal, matlab) there is the option "FlowControl = Hardware" and this seems not to be clean CTS/RTS, because the communication is simply dying... Alchemist P.S: It seems, Altera tries to hide "unimportant details" from the user. However, sometimes some of these details are needed...- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I learned a new term reading this post so now I'm curious..... what is "clean" CTS/RTS mode? (I know flow control but what do you mean by "clean"???). By clean if you mean a clean signal ........ RS232 has never been known to be "clean".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
make sure you set the tx fifo in the com port properties to 1. Do this through control panel - system - device manager.
This is because, when it's more than 1 (typically 14/16), the PC continues to send data after you raise CTS. It continues until its FIFO is emptied. Thus you would experience Rx overruns on your embedded device.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by badomen@Jun 23 2005, 11:12 AM i learned a new term reading this post so now i'm curious..... what is "clean" cts/rts mode? (i know flow control but what do you mean by "clean"???). by clean if you mean a clean signal ........ rs232 has never been known to be "clean". --- Quote End --- Hej BadOmen, with "clean" I meant that only the CTS/RTS and TxD and RxD are used. It is maybe a strange and unofficial term, but since i now have problems with tools like "Hyperterminal" and also "Matlab", where you just specify "FlowControl = Hardware" and do not really know, which pins take part in the communication, I think the term is justified... (When assigning CTS/RTS in a more advanced terminal program, the communication works). By the way, maybe someone has a experiences with Matlab and CTS/RTS-communication with Nios. I read the Matlab documentation, but did not get it working. Here are my matlab commands (but I tried other as well): >> s2 = serial('COM2'); >> set(s2, 'BaudRate', 115200); >> set(s2, 'FlowControl', 'hardware'); >> set(s2, 'DataTerminalReady', 'off'); >> fopen(s2) >> fprintf(s2, '%d', 3); Matlab "freezes" after execution of these commands... So, if somebody has a good idea, it would be great...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if you use RTS&CTS Handshake and you set hyperterminal to flowcontrol,
perhaps it also wants to handle DTR/DSR/CD Signals. assuming 9 PIN SUB-D at the PC side, make a bridge between PINS 4 -> 6+1, so the PC sets DATA TERMINAL READY(PIN4) and gets back DATA SET READY(PIN6) + CARRIER DETECT(PIN1) see also http://www.hardwarebook.net/cable/serial/n...lmodem9to9.html (http://www.hardwarebook.net/cable/serial/nullmodem9to9.html)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok I find THE solution: RST/CTS flow control works well. This my code:
int main() { char* msg = "Detected the character 't'.\n"; FILE* fp; char prompt = 0; fp = fopen("/dev/uart", "r+"); unsigned int uart_status; unsigned int uart_ctrl; if(fp) { while(prompt != 'v') { prompt = getc(fp); if(prompt == 't') { fwrite(msg, strlen(msg), 1, fp); } } fprintf(fp, "Closing the UART file.\n"); fclose(fp); } return(0); } This code works under Hyper Terminal with "hardware" flow control. I found the error. It iwas an Altera error. You just have to change : CTS: PIN L15 (instead of PIN K15) RTS: PIN K15 (instead of PIN L15) for the Altera DSP Stratix II Evaluation Board.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your code, what do you mean by "'" ?
and how are you checking for an incoming RTS and setting ur own RTS(sending CTS) signal?- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page