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

16c745 printf

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



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

16c745 printf
PostPosted: Wed Dec 22, 2004 1:44 pm     Reply with quote

In this 16c745 chip there is RX, TX as well as D+, D-, I think they all use printf, out, puts and getc, gets() to send and receive data from another computer or PIC, so how to separate them, I mean how can I know it is RS232 communication or USB communication? an dHow can specify to do RS232 communication and USB communication?

By the way, My best wishes for a Merry Christmas and Happy new year for every one in this forum, special thanks to Mark, PCM, SherpaDoug, rwyoung, dyeatman,ckielstra,Humberto, John Morley, rnielsen, Haplo, padamo, etc.......... Thank you for helping me when I was lost in my PIC advantures. I find a lot of fan to being with you! and Hope you guys continue to helping me in the coming new year!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 22, 2004 2:13 pm     Reply with quote

Look in the CCS manual for functions that work with the RS232 pins,
such as printf, putc, getc, kbhit, etc.

Look in the CCS example file, USB.C, for functions that work with
the USB pins, such as usb_puts, usb_gets, usb_kbhit, etc.
hillcraft



Joined: 22 Sep 2003
Posts: 101
Location: Cape Town (South africa)

View user's profile Send private message Send e-mail Visit poster's website

USB Commands
PostPosted: Thu Dec 23, 2004 12:35 am     Reply with quote

USB is not documented in the manuals. USB does not use the standard RS232 print and get functions.

Here is a code snippet that shows the difference.

while (true) {
cKey = 0;

if (kbhit(PORT_PC))
cKey = fgetc(PORT_PC);

usb_put_packet(1, USB_OUT_DATA, USB_EP1_TX_SIZE, TOGGLE);
....

You must take a look at the USB drivers and examples supplied with CCS.

Another thing to do to get going quickly is to study the HID USB implentation. All the documents are available for download at www.usb.org
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 8:21 am     Reply with quote

usb_puts(int8 endpoint, int8 * ptr, int16 len,int8 packet_size,int8 timeout);
usb_gets(int8 endpoint, int8 * ptr, int8 max);
usb_put_packet(int8 endpoint, int8 * ptr, int8 len,PID_TOGGLE tg1);
usb_get_packet(int8 endpoint, int8 * ptr, int8 max);

I learn from the sample to send data as int8 and the function are defined as int8.

first of all, all data all define as int8 *ptr, this is good for int8 data, how about char string[length], if I want to send data as "this is a test for usb", how should I do it,

second what is the difference between usb_put_packet() and usb_puts();
usb_gets() and usb_get_packet(), please provide short examples
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jan 26, 2005 8:29 am     Reply with quote

young wrote:
usb_puts(int8 endpoint, int8 * ptr, int16 len,int8 packet_size,int8 timeout);
usb_gets(int8 endpoint, int8 * ptr, int8 max);
usb_put_packet(int8 endpoint, int8 * ptr, int8 len,PID_TOGGLE tg1);
usb_get_packet(int8 endpoint, int8 * ptr, int8 max);

I learn from the sample to send data as int8 and the function are defined as int8.

first of all, all data all define as int8 *ptr, this is good for int8 data, how about char string[length], if I want to send data as "this is a test for usb", how should I do it,

second what is the difference between usb_put_packet() and usb_puts();
usb_gets() and usb_get_packet(), please provide short examples


char and int8 are the same for CCS so no problem. But had there been one, you could cast the pointer to the data as (int8*) and adjusted the length to reflect the actual number of bytes being sent.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 8:41 am     Reply with quote

Thank you Mark:
usb_put_packet() sends one packet to the host, a packet is 8 byte maximum right, so if I send some string less that 8 byte, I should use usb_put_packet(), if I am sending some string large than 8 byte as "try usb123.9", I should use
char data[13]="try usb123.9"
usb_puts(EP1,(int8*)data,13,2,50);

because data has 13 byte include end of the string, and since it is 13, it will be in 2 packets, and timeout could be what ever? Am I right, please correct me?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jan 26, 2005 8:54 am     Reply with quote

I haven't used the CCS USB (or any other except the FTDI chip) so I will let someone else answer that.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 10:47 am     Reply with quote

Hi: hillcraft and PCM:

Would you please give some advice on this question? I really get confused by this four functions and the relationship between packet and message, and byte?
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 12:09 pm     Reply with quote

It looks like that packet_size is a number from 0-8
for the exmple I gaven it should be

usb_puts(EP1,data,packet_size,0); size could be any number from 1 to 8, right?
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