Click here to Skip to main content
12,896,826 members (56,953 online)
Rate this:
Please Sign up or sign in to vote.
See more: C

can some one tell me what is the below code doing?

outportb ((*com)+3,inport((*com)+3)|0x80);

also i want to know,
1- Write a single line of code to set the size of Word Length to 8-bits to be used in serial communication for data transmission

2- Write a single line of code to set the size of Stop bits equals 3 in serial port communication.

3- Write a single line of code to turn ON the parity bit and use Even parity.

4- In the following piece of code, the Baud rate being used is 1200. Modify it in a way such that we shall have Baud Rate of 2400.

outportb ((*com)+3,inport((*com)+3)|0x80);
outportb ( (*com),0x60);
outportb( (*com) +1, 0x00);
Posted 17-Jan-13 3:26am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The first line reads a byte from the Line Control Register of an UART device, sets the highest bit (the DLAB = Divisor Latch Access Bit), and writes the resulting byte back to the register. When doing so, you can access the Divisior Latch registers. In your second code block this is done by passing the 16-bit value 0x0060 to the Divisor Latch low and high byte registers. This will set the baud rate. After doing so, the DLAB bit should be cleared.

Writing code to perform the other requested tasks will be similar by reading the appropiate registers, setting or clearing bits, and writing the new value back to the register. Because the other registers can be accessed without setting a specific access bit, this can be done using a single line of code.

To know the port adresses (register offsets) and bit masks, read about UART devices (e.g. this page[^] which may be better understable than an UART data sheet).
Faisalabadians 17-Jan-13 10:16am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100