Jyothi@Pic
New Member
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
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
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 want to know if this configuration is correct .
please some body help me