View previous topic :: View next topic |
Author |
Message |
Sophi
Joined: 14 Jun 2005 Posts: 64
|
#byte PORTB=6 ? |
Posted: Fri Oct 28, 2005 3:57 pm |
|
|
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 28, 2005 4:08 pm |
|
|
You can also use the CCS output_b() function. Example:
|
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Oct 28, 2005 4:42 pm |
|
|
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.
This line creates an 8 bit data pointer with the name PORTB to address 6, the hardware address of port b.
With the previous declaration for PORTB this will output the contents of data to port b.
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. |
|
![](templates/subSilver/images/spacer.gif) |
SophE Guest
|
|
Posted: Fri Oct 28, 2005 4:51 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Oct 29, 2005 10:55 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|