May 24th, 2003, 07:31 PM
Hi, i haven't posted in a while. I need to know if any of you has ever done any programs for an UART? I need to finish a program (in C) for school in which I need to transfer files through a null modem, any help or tips will be appreciated. I am pretty sure my program sends data (i have debugged extensively), my problem right now is in the receiving part.
May 24th, 2003, 07:58 PM
Yep, I have
Sounds pretty low-level. I take it you're using rs232 or something compatible. Can't you just hook your apparatus up to a PC and write some software which emulates the device you want to talk to?
I cannot advise you unless you state
- What your platform is (microcontroller, microprocessor, 8 bit, 16 bit?)
- What your application is (i.e. what device you're trying to talk to, what protocol you intend to use)
- What electrical standard you're using (I assume seeing as you mention "null modem", it's rs232)
Oh yes, and stating what UART it is might help too!
May 24th, 2003, 08:37 PM
UART- universal asynchronous reciever transmitter, it is the piece of hardware used to control serial communications, on serial ports. The address of an uart is your com port address ie: 0x3f8, to access different registers on the uart you add an offset to your address to reach the desired regs to do different functions: choose speed, parity, data field size etc. I have already defined that.
I don't need to emualte the rs 232 protocol. I just need to write some code to trasnmit any file byte by byte from one pc to another using a null modem cable, its like creating my own protocol, much simpler than rs 232. I am using Turbo C compiler, I am sure it could be done using assembly but now I am sticking to C which lets you go pretty low level.
May 24th, 2003, 09:32 PM
Right. I know what UART stands for but I didn't realise you were using PC hardware, I assumed it was some sort of embedded system using an 8 or 16bit CPU in C or assembly.
There are many different UARTS, but the ones PCs have in (or modern hardware emulates anyway) are fairly well documented.
RS232 is an electrical standard, you will definitely be using it. Creating your own protocol at this level involves soldering.
There are usually two ways to go to receive bytes with a UART
Cons: if you stop polling for too long (i.e. more than the hardware buffer), you miss stuff.
Cons: Requires some assembly and knowedge of the platform, i.e. how to catch interrupts. Programming interrupts requires synchronisation to ensure that you don't try and access the same area at the same time between an interrupt and foreground task.
I have programmed UARTs on 8-bit platforms before, they (6850) only had a 1 byte buffer, so you had to respond quickly otherwise data would get lost.
You typically had to implement your own software buffer, because processing a message usually takes longer than the time before the second byte of the next message arrives.
If you're using a fast machine and short, easy messages, you may not need interrupts (polling might be fast enough).
On the other hand, if you're doing IO in DOS, that is incredibly slow, so you will definitely need interrupts (unless you plan on reading the file into memory entirely before saving it out)