Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C programing problems.

Status
Not open for further replies.

Chenbh

Newbie level 6
Joined
Sep 22, 2010
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,371
(I wasn't sure where to ask the questions...sorry if I got to the wrong forum.)
Hello..I'm new to electronics and to this site.
I'm studying C prgraming at school (the level isn't going to get higher than 1+1:D) ,at school,we can send data through the LPT port without any problem (just add ntport.h to project).When I do the same thing at home - I'm experiencing problems.
I use:
*Windows 7 32 Bit
*Microsoft Visual C++ 2010 Express

When I use the Outport or _outp command the compiler gets to the line which has this command and shuts the application down.
it just alarms me that the application stopped and Windows is trying to get a solution to the problem (does it realy search? :p).

I've found the inpout32.dll file but I don't know what do I need to do with it.
the NTPORT.H doesn't do the job,so maybe I did something wrong with adding it to the project or including it in the application.
__________
ANOTHER QUESTION:
Can the software that I'm using export a .hex file to get it burned into a microcontroller?

if not:
The second problem:
when I'm using Keil µvision 4,it shows me: "error 56: can't open file" what can I do? I've tried to open lots of projects and tried to compile lots of basic softwares with different commands and functions.
__________
If I want to get to the 21st century. and replace the LPT with a USB...what should I learn? I really want to get in that topic,I have some ideas for nice devices for me to build when I'll know more.

*sorry for my English,I'm doing my best to talk well.

Thanks in advance,
Chen
 

your post needs some more information.
ntport.h includes code for accessing the i/o port.

did you compiled the program? was there any error ?

you mentioned that the computer shutdown and gives messages etc...
is this after compiling and running the exe file?

inpout32.dll does the same thing. ntport requires administraive privilage but inpout32 dont require that.
 

your post needs some more information.
ntport.h includes code for accessing the i/o port.

did you compiled the program? was there any error ?

you mentioned that the computer shutdown and gives messages etc...
is this after compiling and running the exe file?

inpout32.dll does the same thing. ntport requires administraive privilage but inpout32 dont require that.

When I'm compiling the application with the Outport(0x378,0xXX) an error occures,it says that the symbol is unresolved.
no,the computer doesn't shut down,only the project .exe shuts down and windows tells it's looking for solution for the problem (like any unresponding program),it shuts down when it runs the line with the outp function.

what should I do with the inpout? just put it in the System directory? no any reboot? additional files or any editing for the software?

I'm thinking about getting a USB to LPT cable..will it work for 8 leds connected to the data pins? if yes...how can I find the right port to mention in the software?

---------- Post added at 16:03 ---------- Previous post was at 15:56 ----------

error lnk2019: Unresolved external symbol _outport(at)8 referenced in function _main

sorry for the double post,i couldn't edit!
 

the error during compilation is because you have not linked the ntport.lib .

by linking that library there will not be errors.

for testing the i/o port access programs , first make sure that
no error during compilation.

usb cannot be programmed by new programmers to usb .
though lpt is old , first understand your task basics .
then you can move further.
 

I thought i got the answer but now it only outputs FF or 00...
My I/O range is 03BC-03BE.
I'm trying to make a running light for 6 LEDS:

Code:
#include<stdio.h>
#include<windows.h>
#include <conio.h>
#include "NTPORT.H"
void main()
{
	int q, a[6]={1,2,4,8,16,32};
 while (1){
	for(q=0;q<6;q++){
Outp(0x3BE,a[q]);
printf("%d\n",a[q]);
	Sleep(400);
	}
	for(q=0;q<4;q++){
	Outport(0x3BE,a[4-q]);
	printf("%d\n",a[4-q]);
	Sleep(400);
	}
 }
}
 
Last edited:

you have not specified anything about the compilation errors or no error.

i assume that there is nil compilation error ,

my doubt is that you are trying to output to lpt1 ?
then 3be is not the addresss.
 

the LEDs turn on and off..so I think I've entered te right port.(or not?)
there are no errors and no warnings.
I don't know what to do.
I've connected every Led to a port of data (pins 2-7 for 6 leds) and their cathodes - to the Ground (pin 25) .
 
Last edited:

try 378 for port address.
and the dely is only 400 milliseconds.
use 2 to 3 seconds to test .
Sleep(2000)
 

378 isn't in the range,and I've tried itust to be sure,still doesn't work.
I've tried to send 01,02,03,04,etc...nothing works but FF and 00.
 

for lpt1 3be is odd.
check with 'system--->controlpanel' on the lpt1 port address in your pc.

for testing blinking ,

send 01 to one pin.
delay
send 00 to the same pin
delay

then loop
test only one pin on lpt connector,
 

I've checked and told you...3BC-3BE is the range

01 to 00 to 01 to 00
and than 02,04,08 (with delays)?
did it..nothing goes right. I have no clue,they only work all at once,any other combinations aren't working :/
 

try to run as admin. right-click your Microsoft Visual C++ 2010 Express shortcut, run as admin. open your project then try to recompile again.
 

**broken link removed**
That's how I connect the LEDS. I used resistors but left 'em because the voltage is low already.
I'll try some solutions,and update you.
 

Thanks,problem solved. now which software should I use to burn an application into a micro-controller? is there any other software than Keil?
 

glad to hear that problem is solved.
but you have not mentioned how ?
it will be useful for others .

and which microcontroller are you talking about ?
have you the hex file ready ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top