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

#byte PORTB=6 ?

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



Joined: 14 Jun 2005
Posts: 64

View user's profile Send private message

#byte PORTB=6 ?
PostPosted: Fri Oct 28, 2005 3:57 pm     Reply with quote

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 28, 2005 4:08 pm     Reply with quote

You can also use the CCS output_b() function. Example:

Code:
output_b(data);
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Oct 28, 2005 4:42 pm     Reply with quote

Quote:
What I want is to send data to a Port. The data originates in a 24LC128 and should come thru the PICF877A and out again parallel-y as 8 bits on portB. The manual doesn't explain portb well enough for me. It says use if you want to use any pin on the port, but I want to use every pin.
Can someone please explain this to me and also tell me if this is what this (mine or Joshua's) code does?
Yes, the program below is writing 8-bits of data to port B.

The hardware in the PIC processor is overlayed on the RAM memory, this technique is called Memory Mapped I/O. The Port B on the PIC16F877A is mapped to memory address 6, so when you are reading/writing data to address 6 you are actually accessing port B.

Code:
#byte PORTB=6

This line creates an 8 bit data pointer with the name PORTB to address 6, the hardware address of port b.

Code:
portb = data;
With the previous declaration for PORTB this will output the contents of data to port b.


Code:
set_tris_b(0);
Be aware that the CCS compiler might change these settings when calling one of the CCS supplied I/O functions. When manually configuring the TRIS registers you should also configure #use fast_io.

Or forget all the above and use the output_b() function as suggested by PCM.

Code:
#include <16F877.h>
Change this to use the 16F877A.
SophE
Guest







PostPosted: Fri Oct 28, 2005 4:51 pm     Reply with quote

Ckielstra- that was exactly what I was looking for. Thanks (also to PCM).
I don't have a library for 16F877A, I just use the one for 16F877 and it seems to work OK. I'm using compiler version IDE 3.24 or PCB 3.136- not sure which # is the version.
SophE
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Oct 29, 2005 10:55 am     Reply with quote

Quote:

I don't have a library for 16F877A, I just use the one for 16F877 and it seems to work OK.

To know the difference between 16F877 and 16F877A read this:

http://ww1.microchip.com/downloads/en/DeviceDoc/39591a.pdf

Quote:

I'm using compiler version IDE 3.24 or PCB 3.136- not sure which # is the version.

Open the generated .lst file after compiling, in the very first line youŽll see the version.

CCS PCB C Compiler, Version 3.136, xxxxx

IDE 3.24 Your editor development enviroment version


Humberto
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