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

About the ports

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



Joined: 08 Dec 2005
Posts: 5

View user's profile Send private message

About the ports
PostPosted: Fri Dec 16, 2005 10:47 am     Reply with quote

I have been looking around the forum for info and I have found alot. But not where I can read about the ports. In many examples people point to PortA, PortB with a number like
#byte PortB=6, where can I find the adress to the corresponding port?

Another thing, this #byte command why use it, it is declared as an int so why not use the int instead?

Greatful for any answare.
Ttelmah
Guest







PostPosted: Fri Dec 16, 2005 11:14 am     Reply with quote

First part. The chip's data sheet.
Second part. These a fixed 'registers' in the processor. If you create a variable, it talks to the user RAM. The byte definition, creates a 'dummy' register, which talks to a specified address. You can use the int definition, like this:
Code:

int8 PORTA;
#locate PORTA=0x6


This declares an integer variable called 'PORTB', and then tells the compiler to put this at address 6. The #byte declaration, does both parts in one line.

Best Wishes
Ttelmah
Guest







PostPosted: Fri Dec 16, 2005 11:26 am     Reply with quote

Other than not being able to tell my 'PORTA', from my 'PORTB', hopefully the rest makes sense.....

Best Wishes
husq



Joined: 08 Dec 2005
Posts: 5

View user's profile Send private message

Thanks!!
PostPosted: Fri Dec 16, 2005 11:28 am     Reply with quote

You say data sheet, I was looking at it and is it in the I/O part, discribed as bit6, bit5 etc?
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Dec 16, 2005 11:54 am     Reply with quote

I don't know what chip you using. but lets say the 16F877A
This is the spec.
http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf
Goto page 19
You will see port A at 0x5
trisA at 0x85 and a whole lot more.


I think of the #byte as an overlay.
#byte Tims_great_8bit_variable = 0xF83
//note: no semicolon 83=D0 on a 18F452
This overlays the variable on the pins,.. so to speak
You still have to set the tris correctly.
then on outputs if you set the variable, the pins are set.
on input.. the variable is the value of the digital voltage at the pins.
Does that make sense?
husq



Joined: 08 Dec 2005
Posts: 5

View user's profile Send private message

Absolutly
PostPosted: Fri Dec 16, 2005 12:07 pm     Reply with quote

Thank you very much, it all makes sense now!
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