|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
PORT |
Posted: Tue Sep 15, 2009 7:14 am |
|
|
How I can send or receive information through the LPT and COM |
|
|
Guest
|
|
Posted: Tue Sep 15, 2009 7:33 am |
|
|
windows api && pony express ?? |
|
|
Guest
|
|
Posted: Tue Sep 15, 2009 4:58 pm |
|
|
Thanks
But I ask about the commands programming in c |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Sep 15, 2009 5:45 pm |
|
|
This forum is for programming Microchip brand Microcontrollers using CCS Info's PIC-C Compiler.
If you'd like to know how to access a PC's parallel or serial port, I would recommend you visit Microsoft's website (for developers) or download a free distribution of Linux.
With Linux, there is plenty of free source code (minicom for example) that can demonstrate access to serial ports. (not to mention lots of languages like TCL, Perl or Python that are way easier to use than 'C' for the average newcomer to programming)
I'm sure LPT ports are similar in ease of obtaining example source (for Linux).
Good luck and happy trails!
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Guest
|
|
Posted: Wed Sep 16, 2009 3:29 am |
|
|
I use CCS and I don't want to buy or learn other language
I want to understand How I can send or receive information through the LPT and COM with CCS |
|
|
Ttelmah Guest
|
|
Posted: Wed Sep 16, 2009 5:33 am |
|
|
Your question makes no sense really.
A PIC, doesn't have 'LPT', or 'COM' (though it does have part of the hardware toprovide a serial port, which is what 'COM' on a PC implies), hence there is no ability in CCS C, to talk to 'LPT or COM'....
If you are wanting to send data to a PC COM port, then you need a MAX232 added to the PIC, the #USE RS232 line, and putc/getc, to transfer the characters. If you wanted to receive data from an LPT port on a PC, you would need added hardware (if using the standard driver), to ensure that the data is not acknowledged till it has been read by the PIC. Bi-directional communications would need custom drivers at the PC. It can be done, but is fairly complex.
Best Wishes |
|
|
Guest
|
|
Posted: Wed Sep 16, 2009 9:10 am |
|
|
Thanks Ttelmah
Can you expand your answer?
How I can transfer characters in CCS?
What hardware I need to added in order to receive data from LPT port?
What drivers I need to add in order to receive Bi-directional communications?
Thanks again |
|
|
Ttelmah Guest
|
|
Posted: Wed Sep 16, 2009 9:51 am |
|
|
To talk to the com port on a PC, you need a MAX232 or equivalent level translator/inverter, connected to the PIC UART pins (preferably).
Several standard circuits have been published in the past.
To talk to the LPT port, would depend on other things:
Receiving data as a 'printer', or using a custom driver?.
Using a custom driver, you can do this with no extra hardware.
As an LPT, you would need eight PIC data lines for the data, the PIC interrupt line to the PC strobe pin, and a single SR latch resettable by one more pin on the PIC, set by the 'strobe' line from the PC, with it's out fed back to the 'ack' line on the PC. One more PIC pin feeding the busy line on the PC, and hardwire the paper end, error, and select lines to their 'OK' state (paper end, low, error high, select high).
Then when the PIC interrupts, you read the eight bits of data, and immediately reset the latch. If you want to stop transmission, turn the busy line 'on' (high), till you are ready for more data, then drop it again.
Without the SR latch, unless your code is very fast, you can be too slow to handle the data. This takes 'ack' immediately to the busy state, and since you don't clear it till you are in the interrupt, you can decide before doing so, whether to pause transmission with the busy line.
This is for handling reception of data using SPP only. Going to the other port modes gets harder....
Best Wishes |
|
|
Guest
|
|
Posted: Thu Sep 17, 2009 1:27 pm |
|
|
Thanks Ttelmah
I will be glad to receive more comments about the programming. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|