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

PIC16F877A SPI interface

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



Joined: 30 Mar 2010
Posts: 21

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

PIC16F877A SPI interface
PostPosted: Tue Mar 30, 2010 11:16 am     Reply with quote

Hai,
I am developing a project RFID system based on 16F877A (master) and CLRC632 (slave) using SPI interface. Pls help me what are pins in 16F877A should be connected to slave and SSP registers to initialize.
John A.D.M



Joined: 30 Mar 2010
Posts: 2

View user's profile Send private message

PostPosted: Tue Mar 30, 2010 12:25 pm     Reply with quote

PIC16F877A
Port A

SPI slave select input - a5 (active low)

Port C

SPI CLOCK -- c3
SPI IN ------- c4
SPI OUT ----- c5

The pin layout will change depending on your MCU package

CLRC632
Pin 13 --- Master In Slave Out (MISO), SPI interface
Pin 21 --- Not Slave Select: strobe for the SPI communication
Pin 22 --- Master Out Slave In, SPI interface
Pin 24 --- Serial Clock: Clock for the SPI interface

http://pdf1.alldatasheet.com/datasheet-pdf/view/196701/PHILIPS/CLRC632.html
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 30, 2010 12:41 pm     Reply with quote

Pin A5 is only used if the PIC is an SPI Slave. But you're using the PIC
as the Master. In that case, any i/o pin can be used for the Slave Select
signal going to the slave device. You can use pin C2 for this.
balaji



Joined: 30 Mar 2010
Posts: 21

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

PostPosted: Wed Mar 31, 2010 1:33 am     Reply with quote

John A.D.M wrote:
PIC16F877A
Port A

SPI slave select input - a5 (active low)

Port C

SPI CLOCK -- c3
SPI IN ------- c4
SPI OUT ----- c5

The pin layout will change depending on your MCU package

CLRC632
Pin 13 --- Master In Slave Out (MISO), SPI interface
Pin 21 --- Not Slave Select: strobe for the SPI communication
Pin 22 --- Master Out Slave In, SPI interface
Pin 24 --- Serial Clock: Clock for the SPI interface

http://pdf1.alldatasheet.com/datasheet-pdf/view/196701/PHILIPS/CLRC632.html








Sir,
I have connected as you mentioned. but still we get every time a different value after reset.
pls tell me about mode select:
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)

what mode i should select? my SCK pin should should be low only during data transmission.

pls help
balaji



Joined: 30 Mar 2010
Posts: 21

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

PostPosted: Thu Apr 01, 2010 6:47 am     Reply with quote

PCM programmer wrote:
Pin A5 is only used if the PIC is an SPI Slave. But you're using the PIC
as the Master. In that case, any i/o pin can be used for the Slave Select
signal going to the slave device. You can use pin C2 for this.


Dear Sir,

I have used C2 pin also but i didn`t get the result. I always get some repeated value for all the registers.

pls help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 01, 2010 1:23 pm     Reply with quote

Post your driver routines and a test program. Here's an example of
what I mean by that. The program shown in the link below has routines
to initialize the SPI, configure the A/D chip, and read from the A/D chip.
It also a loop in main(), to read the A/D every 1/2 second and display
the results.
http://www.ccsinfo.com/forum/viewtopic.php?t=41059&start=1

Post your test program that is very similar to that format. It must be
compilable. That means it has the #include, #fuses, #use delay(),
all variable declarations, and it compiles with no errors.

Don't put in any useless CCS Wizard code, that disables Timers, etc.,
that are already disabled upon power-on anyway. Wizard code just
gets in the way of understanding the actual real code in your program,
that performs the functions of the program.

Also post your compiler version.
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