473,811 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

paralell port: I have got few errors on this piece of code below, please help

6 New Member
Expand|Select|Wrap|Line Numbers
  1. #include <dos.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <time.h>
  5.  
  6. #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
  7.  
  8. #define DATA PORTADDRESS+0
  9. #define STATUS PORTADDRESS+1
  10. #define CONTROL PORTADDRESS+2
  11.  
  12. void lcd_init(void);
  13. void lcd_write(char char2write);
  14. void lcd_putch(char char2write);
  15. void lcd_puts(char * str2write);
  16. void lcd_goto(int row, int column);
  17. void lcd_clear(void);
  18. void lcd_home(void);
  19. void lcd_cursor(int cursor);
  20. void lcd_entry_mode(int mode);
  21.  
  22.  
  23. void main(void)
  24. {
  25. lcd_init();
  26. lcd_goto(1,1);
  27. lcd_puts("Welcome To");
  28. lcd_goto(1,0);
  29. lcd_puts("electroSofts.com");
  30.  
  31. while(!kbhit() ) //wait until a key is pressed...
  32. {}
  33.  
  34. }
  35.  
  36. void lcd_init()
  37. {
  38.  
  39. outportb(CONTROL, inportb(CONTROL) & 0xDF);
  40. //config data pins as output
  41.  
  42. outportb(CONTROL, inportb(CONTROL) | 0x08);
  43. //RS is made high: control (register select)
  44.  
  45. lcd_write(0x0f);
  46. delay(20);
  47. lcd_write( 0x01);
  48. delay(20);
  49. lcd_write( 0x38);
  50. delay(20);
  51.  
  52. }
  53.  
  54. void lcd_write(char char2write)
  55. {
  56.  
  57. outportb(DATA, char2write);
  58. outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
  59. delay(2);
  60. outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
  61. delay(2);
  62.  
  63. }
  64.  
  65. void lcd_putch(char char2write)
  66. {
  67.  
  68. outportb(CONTROL, inportb(CONTROL) & 0xF7);
  69. //RS=low: data
  70. lcd_write(char2write);
  71.  
  72. }
  73.  
  74. void lcd_puts(char *str2write)
  75. {
  76.  
  77. outportb(CONTROL, inportb(CONTROL) & 0xF7);
  78. //RS=low: data
  79. while(*str2write)
  80. lcd_write(*(str2write++));
  81.  
  82. }
  83.  
  84. void lcd_goto(int row, int column)
  85. {
  86.  
  87. outportb(CONTROL, inportb(CONTROL) | 0x08);
  88. if(row==2) column+=0x40;
  89. /* Add these if you are using LCD module with 4 columns
  90. if(row==2) column+=0x14;
  91. if(row==3) column+=0x54;
  92. */
  93. lcd_write(0x80 | column);
  94.  
  95. }
  96.  
  97. void lcd_clear()
  98. {
  99.  
  100. outportb(CONTROL, inportb(CONTROL) | 0x08);
  101. lcd_write(0x01);
  102.  
  103. }
  104.  
  105. void lcd_home()
  106. {
  107.  
  108. outportb(CONTROL, inportb(CONTROL) | 0x08);
  109. lcd_write(0x02);
  110.  
  111. }
  112.  
  113. void lcd_entry_mode(int mode)
  114. {
  115.  
  116. /*
  117. if you dont call this function, entry mode sets to 2 by default.
  118. mode: 0 - cursor left shift, no text shift
  119. 1 - no cursor shift, text right shift
  120. 2 - cursor right shift, no text shift
  121. 3 - no cursor shift, text left shift
  122. */
  123. outportb(CONTROL, inportb(CONTROL) | 0x08);
  124. lcd_write(0x04 + (mode%4));
  125.  
  126. }
  127.  
  128. void lcd_cursor(int cursor)
  129. {
  130.  
  131. /*
  132. set cursor: 0 - no cursor, no blink
  133. 1 - only blink, no cursor
  134. 2 - only cursor, no blink
  135. 3 - both cursor and blink
  136. */
  137.  
  138.  
  139. outportb( CONTROL, inportb(CONTROL) | 0x08 );
  140. lcd_write( 0x0c + (cursor%4));
  141.  
  142. }
  143.  
  144. --------------------------------------------------------------------------------
  145.  
Mar 16 '07 #1
1 1622
horace1
1,510 Recognized Expert Top Contributor
using Turbo C V3.0 this code compiles and links OK

Have not tried to run it!

what is your problem?
Mar 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
9096
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the same port to change the direction of the robot. The trajectory frame is managed by an applet, and the project works good when the applet is called by a html document allocated in the same local machine under W98 where the classes and the serial port...
9
8445
by: MNQ | last post by:
Hi All I want to use my parallel port of my PC to control some external devices. I am writing a program in ANSI C using the PacificC compiler. What I need to know is how to access the parallel port ie to send data and to read the state of the parallel port including the control lines. Can anyone help/point me in the correct direction? I have tried the help files and the internet but am unable to find anything relevant. Thanks in...
16
7539
by: halukg | last post by:
I am trying to send a 6 byte char array from the serial port in new C# 2005 Express: com.Write(new string(new char { (char)34, (char)14, (char)192, (char)51, (char)0, (char)0 }, 0, 6)); I am receiving 34,14,63,51,0,0 from the port as I connected Tx and Rx pins to each other by using the following code: private void com_DataReceived(object sender, SerialDataReceivedEventArgs e) {
6
3129
by: kai | last post by:
Hi, I was tring to run an example (HelloWorld.aspx) from MSPrss book, I get this message: "ASP.NET Development Server faild to start listening port 1034. Error message: An attempt was made to access a socket in a way fobidden by its access permissions."
1
10921
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o errors 2) My Nokia 6600 prompted me the message "Accept Connection request from DEMON?" note: DEMON is my computers name. 3) Using my Nokia 6600, I hit the button that refers to the "Yes"
3
5141
by: vorange | last post by:
Hello, I have a problem I have been unable to solve for quite some time now. I'm using the Serialport class and opening the port and writing a byte to it. The byte is successfully received by the other device. The other device then sends back a response. But what I get back is the same character I sent! e.g. if i send 2, i get back 2. What is going on here? Why are things being echoed back. My code is
11
12339
by: Phoe6 | last post by:
Hi, The following piece of code works properly when my proxy password contains characters etc. But when my proxy password contained something like '|\/|' , the httplib incorrectly indentified it as separator. How do I resolve this issue. <code> # Proxy Address PROXY_IP = "1.1.9.8:80"
0
1438
by: mmcgee00 | last post by:
Hi, Currently, I am trying to get different service banner by connecting to different ports using python (code below). The versions I am working with are python 4.2.1 and fedora core 4. I am trying to reproduce a very small piece of nmap, since nmap has to get a port's banner in order to figure out the version. However, I haven't been entirely successful. *******************************************************
11
4382
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some mistakes, i'm using cygwin on a windows pc and it seems that some functions cause stack overflows so am using fgets instead of fgetc (don't know y it solved the problem but that part is working). my problem now is that i am reading strings a few...
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.