473,382 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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 1607
horace1
1,510 Expert 1GB
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
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...
9
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...
16
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...
6
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...
1
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...
3
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...
11
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...
0
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...
11
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.