Gert B Frobe wrote:
> Is it possible to grab the serial port using C?
Yes, but you need to platform specific, non-portable code.
> If so, can I control each line seperatley?
Yes. Most serial ports are character based.
> I need to control the serial port in such a way
> to get bit by bit transmission out. I am controlling a serial eeprom
> with the port, at least I want to, and it needs to have each bit
> clocked in. Hence, the bit by bit Tx. So I need to be able to send out
> one bit and clock after that and so on for each bit.
This is what a UART or USART does. With one of these devices,
you just place a character into the transmission register and
it clocks out the bits at the correct speed (baud) as well as
adding parity (if used) and stop bits.
> Any links or example would be appreciated.
> TIA,
> Gert
Some processors allow you to output to given pins.
You need at least two pins: clock and transmit.
Controlling these pins highly depends on your platform.
On some, this process involves writing to memory;
while on others, you have to use specific processor
instructions (such as writing to a device). An 8051
processor uses a different scheme than an ARM processor.
For memory access, just assign a pointer and dereference
the pointer:
unsigned char * const Uart_tx_reg = (unsigned char * const) 0x40000;
*Uart_tx_reg = 'a';
The receive pointer should be declared as 'volatile'
since it changes values without the program's knowledge.
I've had to access serial EEPROMs before, each one
different depending on how the H/W folks connected
it.
--
Thomas Matthews
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html