[PIC] PIC16F887 SPI interfacing with MCP3550.

Status
Not open for further replies.

ismbn

Full Member level 3
Joined
Feb 11, 2012
Messages
160
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,308
Location
Mumbai. india
Visit site
Activity points
2,444
Hello All.

i am now for PIC microcontroller. I tried allot but the SPI is not working.
my aplication is take the data form MCP3550. and show on 4 digit 7 segment.
i am just getting the problem in communication between PIC16F887 and MCP3550.
please guide me how to make alive the communication between them.
this is the simple code the i an trying to read the data and show it on PORTD.
Please help me....


Code:
#include <pic.h>
void my_delay(char x)
{
char q,w;
for (q=0;q < 255; q++)
for(w=0;w<x;w++);
}
char x;
void main()
{
TRISC = 0b10010111;;
TRISA = 0x01;
TRISD=0;

	SSPSTAT |= 0b10000000;
	SSPCON	|= 0b00100100;
while(1){
	my_delay(10);
x  = SSPBUF;
PORTD = x;
}
}
am i correct????
 

I am guessing one the registers haven't been setup for the correct SPI communication.

From the datasheet, "When using the SSP module in SPI slave mode and SS enabled, the A/D converter must be set to one of the followed modes, where PCFG3CFG0 = 0100,0101,1110,1111." It appears you are in slave mode so this could be the issue.

"SS must have TRISA<5> set and register ADCON1 must be set in a way that pin RA5 is configured as a digital I/O"
 

@cl10greg ,Thank you so much for the replay Sir.
the datasheet seem to very difficult to read an understand. Sir can you please show me how to configure it.
i want uC in Master mode. the ADC Controlling by SS bit.
Thanks Once again.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…