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 support@ccsinfo.com

streams?

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



Joined: 14 Jun 2006
Posts: 31

View user's profile Send private message

streams?
PostPosted: Wed Jun 14, 2006 8:59 pm     Reply with quote

Hello,

I am a <newbie> to the CCS and the PIC world. I have spent the last year in C++ and VC++, but never really dealt much with C.

So, I am rusty in C since all I was used to was, some C structures, classes, virtual functions, ADTs, Inheritance, WIN32 and its API, handlers and so forth!

At this point, I am embarassed to ask some questions, for this is why, today! I have purchased the "PICmicro MCU C: An introduction to Programming the MicroChip PIC in CCS by Nidel Gardner" handbook.

So, excuse me if my questions sound like "I need to read a book on C" type of tone! However, I am trying to catch up as most as I can.

I just got the CCS kit for the PIC16f877A micro controller a few days ago and I must say, I am full of questions!

Question#1:
I don't know about you guys but, I have looked in my C book and I have never seen the following syntax used with the colon and a number at the end of the structures member variables:

struct xxx
{ int data: 4; //I guess this sets up a default value of 4 to data?
int rw : 1;
}

What does the ": 4;" stand for?

Question #2:
I find it weird that when we want to get a character from an rs232 port we use getc() which is a built in function and when we want to get an integer we have to fetch a function called get_int() in the INPUT.C file? Why couldn't the get_int() or the get_long be part of the built in functions? I am just curious on this one! I don't mind if this is the way it is, but I would like to know if there is any patrticular reason!

Question #3:
I am not familiar with streams asides from the breif descriptions that I have read on them. I often see samples like this:

#use rs232(baud=9600, xmit=pin_c6, rcv=pin_c7,stream=HOSTPC)

what is the stream of HOSTPC and where is "HOSTPC" defined or "GPS" for that matter? I know that a stream must be a constant byte, but I just would like to know what these constants mean exactly and where can I find the full listing of available streams for my PIC.

Question#4:
I have read that pointers to functions are not allowed, however, is it okay to use the full extent of pointers as in regular C ex: an array of pointers to strings as so:

char *xxx[] = {"abc", "hij"};

or declarations of pointers to string constants as so:

char *yyy = ("abc");

Just asking?

Question #5:
I have verbally contacted CCS on this one, and I am supposed to e-mail them but I just haven't had the time yet to do so. However I will take a stab at it and see if anyone has run into this problem.

I was using the rs232 from an example in the sample booklet, when I decided to change the data bits from 8 to 7 in the serial port monitor and modified my #use rs232 to 7 bits instead of 8 as so:

#use rs232(baude=9600,xmit=PIN_C6,rcv=PIN_C7,BITS=7);

This did not work! I don't know why, If anyone knows I would appreciate their input.

Question#6:
What's a brownout!


I have so much to get used to so I will probably be back.

Thankyou all for your generous help!

This is the first time I use this sight, so I don't know how friendly the gurus of this technology are, however I hope to hear from you all!

Thanking all in advance for your feedback!

Best regards
Roberto
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 14, 2006 9:26 pm     Reply with quote

Quote:
struct xxx
{ int data: 4;
int rw : 1;
}
What does the ": 4;" stand for?

At the following link, scroll down to the section on Bit Fields:
http://www.cs.cf.ac.uk/Dave/C/node13.html


Quote:
#use rs232(baud=9600, xmit=pin_c6, rcv=pin_c7,stream=HOSTPC)

what is the stream of HOSTPC and where is "HOSTPC" defined or "GPS" for that matter? I know that a stream must be a constant byte, but I just would like to know what these constants mean exactly and where can I find the full listing of available streams for my PIC.

It's just a unique identifier name. It's not defined elsewhere.
You define it when you put it in the #use rs232() statement.


Quote:
#use rs232(baude=9600,xmit=PIN_C6,rcv=PIN_C7,BITS=7);
This did not work! I don't know why, If anyone knows I would appreciate their input.

Aside from the typos, the PIC data sheet (for the 16F877) says it
only supports 8 or 9 bits:
Quote:
TX9: 9-bit Transmit Enable bit
1 = Selects 9-bit transmission
0 = Selects 8-bit transmission
rougie



Joined: 14 Jun 2006
Posts: 31

View user's profile Send private message

rougie
PostPosted: Wed Jun 14, 2006 10:07 pm     Reply with quote

Thankyou Avatar!

I will make note of this!

Kind regards
Robert
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