CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PORT

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








PORT
PostPosted: Tue Sep 15, 2009 7:14 am     Reply with quote

How I can send or receive information through the LPT and COM
Guest








PostPosted: Tue Sep 15, 2009 7:33 am     Reply with quote

windows api && pony express ??
Guest








PostPosted: Tue Sep 15, 2009 4:58 pm     Reply with quote

Thanks
But I ask about the commands programming in c
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Sep 15, 2009 5:45 pm     Reply with quote

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








PostPosted: Wed Sep 16, 2009 3:29 am     Reply with quote

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







PostPosted: Wed Sep 16, 2009 5:33 am     Reply with quote

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








PostPosted: Wed Sep 16, 2009 9:10 am     Reply with quote

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







PostPosted: Wed Sep 16, 2009 9:51 am     Reply with quote

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








PostPosted: Thu Sep 17, 2009 1:27 pm     Reply with quote

Thanks Ttelmah
I will be glad to receive more comments about the programming.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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