• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

problem in interfacing mcp2515 with at89s8252

Status
Not open for further replies.
Hi,

I am trying to interface at89s8252 microcontroller with mcp2515.

mcp2515 is connected with 8mhz crystel frequency and microcontroller with 11.0592mhz. mcp2515 has hardware reset circuit also.

spi configuration is like below

Code:
void SPI_init()
{
	P1=0x24;
	SCK=HIGH;				 //clock high
	SS=HIGH;				 //chip select high
	MOSI=HIGH;				 //master out slave in high
	MISO=HIGH; 				 //master in slave out high
	//SPCR=0X55;	 			 //mode1
	//SPCR=0XD5;
	//intr=1;	 
}


unsigned char SPI_send(unsigned char a)
{
	unsigned char dat=0,bit_var=0;
	MISO=1;
	SPDR=a;				  		//load data to data register
	while((SPSR&0x80)==0);		//checking for transmit flag
	Delay1mSec();
	//bit_var=(SPSR&0x80);
	dat=SPDR;				    //read data from data register
	return(dat);			    //return data

}*/

void main()
{

        
         SPI_init();


         while(1)
         {

                         SS=LOW;						//Select MCP2510
		d = SPI_send(0xC0);			//Reset Command
		SS=HIGH;

		SS=HIGH;
		Delay1mSec();
		SS=LOW;
		d =SPI_send (0x02);			//write command
		d =SPI_send (0x0f);	
    	             d =SPI_send (0x80);			//configuratrion mode
		SS=HIGH;	 

		SS=HIGH;
		Delay1mSec();
		SS=LOW;						//chip select
		d=SPI_send(0x03);			//read command
		d=SPI_send(0x0f);		  	//BUFFER 0
		//d0=SPI_send(0x00);	    //data
		SS=HIGH;
               }
}
i am trying to check the status by reading the data from D0 pin the data read is empty.


i want to know if this configuration is correct .

please some body help me
 

sohaib.qamar

New Member
MCP2515 not working

hi

i just want to know about the status of your MCP2515 working, i am in a kind of same problem.

i have interfaced MCP2515 with ATmega32(AVR), m using AVR as master & MCP2515 as a slave. The problem is that i m not receiving any data on Master In Slave Out (MISO) line of AVR. Infact, i m not receiving any data from MCP2515, i have checked my hardware & software as far as i come to know from both datasheets but still m not able to figure out the actual problem i m facing regarding that issue...


any help will be really appreciated :)

Regards
Sohaib.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top