View previous topic :: View next topic |
Author |
Message |
balaji
Joined: 30 Mar 2010 Posts: 21
|
PIC16F877A SPI interface |
Posted: Tue Mar 30, 2010 11:16 am |
|
|
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
|
|
Posted: Tue Mar 30, 2010 12:25 pm |
|
|
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
|
|
Posted: Tue Mar 30, 2010 12:41 pm |
|
|
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
|
|
Posted: Wed Mar 31, 2010 1:33 am |
|
|
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
|
|
Posted: Thu Apr 01, 2010 6:47 am |
|
|
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
|
|
Posted: Thu Apr 01, 2010 1:23 pm |
|
|
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. |
|
|
|