Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C
hi,
 
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 4:26am

1 solution

Rate this: bad
good
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 http://retired.beyondlogic.org/serial/serial.htm#12[^] which may be better understable than an UART data sheet).
  Permalink  
Comments
Faisalabadians at 17-Jan-13 10:16am
   
thanks

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

  Print Answers RSS
0 OriginalGriff 275
1 Maciej Los 230
2 Sergey Alexandrovich Kryukov 185
3 Afzaal Ahmad Zeeshan 152
4 ProgramFOX 130
0 OriginalGriff 6,524
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,218
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2014
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