Hi Christopher,
That Microchip code doesn't make any sense at all in this context. I see a lot of USB references but nothing about the MSSP module or the MCP2515.
But I took another look at your code.... At the very beginning, in the INITIALIZE MCP2515 section you have this piece of code:
Code:
LOW CS
SSPBUF = MCPRST ' COMMAND TO RESET THE MCP2515
PIR1.3 = 0
WHILE PIR1.3=0 :WEND
HIGH CS
I then went to see exactly what MCPRST was and the only thing I found in your code was an alias to PortC.0 so what's happening in that piece of code is that the PIC reads PortC.0 and then the result of that read operation (1 or 0) to SSPBUF. To reset the device you either pull the hardware reset line LOW or send $C0 over SPI.
Properly resetting the device automatically puts in the configuration mode so therotically you shouldn't need to put it in that mode directly after a (proper) reset. Then your comments says that you're writing to "part of baudrate" or something but $07 is the EXTENDED IDENTIFIER LOW register receiver 1, $03 is EXTENDED IDENTIFIER LOW register for receiver 0 and I can't even find what $BA is.
OK, moving to MAIN then....
You send the command to write then you send the value 0 to CANINTE at adress $02, that all seems OK to me if disabling interrupts is what you want to do.
Next you set the TXB0CTRL register for a high priority message and request it to send. Then you write the TRANSMIT BUFFER STANDARD IDENTIFIER register. I have no idea what these does so I'm going to asume it's correct. Then, you tell it you want to send a single byte by writing the value 1 to TXB0DLC and then you write the actual data.
Personally I would've thought you should first load the data to be sent THEN tell the device to send it. Ie write TXB0CTRL after you've loaded the data but the way you have it might be correct.
OK, that's it for now. It feels like your pretty close.
/Henrik.
Bookmarks