faraz Guest
|
Cant able to get response from MCP2515 |
Posted: Mon Jun 30, 2008 9:55 am |
|
|
Hi , i am doing my master Thesis in a German Company. I have a problem with MCP2515 cCan controller, I write a code to interface with Renesas H8SX 1657 controller and i checked every think is right, Command, data and modes are correct but MCP2515 can not response.
i just want to get response from Can controller, in my case nothing is happening :( , i use bit banging instead of Usart .
my code is .
Code: | void init_MCP2515_communication(void)
{
SPI_Init();
}
unsigned char read_can_reg(unsigned char adr)
{
unsigned char ret;
SPI_CS_CAN = 0; //Enable Can controller
SPI_WriteC(MCP_READ);
SPI_WriteC(adr);
ret=SPI_Read();
SPI_CS_CAN = 1;
return ret;
}
void write_can_reg(unsigned char adr, unsigned char dat)
{
SPI_CS_CAN = 0;
SPI_WriteC(MCP_WRITE);
SPI_WriteC(adr);
SPI_WriteC(dat);
SPI_CS_CAN = 1;
}
int main(void) {
init_MCP2515_communication();
write_can_reg(0x0F,0x80); //set configuration mode
write_can_reg(0x2A,3); //set cnf1 bits
Test=0x00;
write_can_reg(0x0F,0x00); //set normal mode
Test=read_can_reg(0x2A);
return 0
} |
Thanks very much if somebody help me out. |
|