delorie.com/archives/browse.cgi | search |
From: | Clemens Valens <c DOT valens AT mindless DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Using the modem control and status registers |
Organization: | http://www.remarq.com: The World's Usenet/Discussions Start Here |
X-Originating-Host: | 195.154.148.69 |
X-Wren-Trace: | cNn+3svZheTfnI37yZWYgpyKmYmGiMiVj4KWi4mUmdmHhsyWhsyYmYSMhZKBwIrNlsPU2suI/fHVxJfUxpzewpKa190= |
Message-ID: | <933079897.24959@www.remarq.com> |
References: | <379CC17D DOT 8BD04B6F AT hotmail DOT com> |
Lines: | 54 |
Date: | Tue, 27 Jul 1999 04:51:32 -0800 |
NNTP-Posting-Host: | 10.0.3.195 |
X-Complaints-To: | wrenabuse AT remarq DOT com |
X-Trace: | WReNphoon3 933080190 10.0.3.195 (Tue, 27 Jul 1999 05:56:30 PDT) |
NNTP-Posting-Date: | Tue, 27 Jul 1999 05:56:30 PDT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
How do you synchronize the transmitter and the receiver? You want something like a software UART. Here the receiver monitors the input (usually through an interrupt) and when it sees a predetermined change in level (the startbit) it starts a sample timer. After half a bitlength the receiver samples the input and that will be the value of the received bit. This is repeated one bitlenght later, etc., until all the bits have been received. For instance: #define word_lenght 12 #define bit_lenght 37 #define half_bit_length (bit_length>>1) int index; serial_word bit[word_length]; void startbit_isr() { index = 0; start_sample_timer(half_bit_length); clear_interrupt(); } void sample_timer_isr() { bit[index++] = sample_input(); if (index<word_length) { start_sample_timer(bit_length); } clear_interrupt(); } int main(void) { install_interrupt_stuff_etc(); /* Wait for word to arrive. */ index = 0; while (index<wordlength); do_something_with_received_bits(); return 0; } For this you need accurate timers on both sides. Also, you can do it with polling, but I don't recommend it. Clemens * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free!
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |