I have two MCP2515 connected to one crystal like in datasheet - first MCP have crystal, second MCP was connect OSC1 to CLKOUT first MCP but it doesn't work. I use MCP CAN library by Cory J Fowler.
Probably CLKOUT was default off. I try to change MCP register but I'm not sure how to do it.
I tried to do that:
Additionally, the setMode function is hard coded to only write to bits 7-5 REQOP[2:0] of the CANCTRL register. Have a look at the source code its only three files and straightforward code.
The clock out is enabled by default but divided by 8. It is intended to be used as clock for a microcontroller for cost sensitive applications and therefore needs to be enabled at power up. Otherwise the microcontroller might not be able not start up, if it does not have a internal RC oscillator.
@mikb55
SOF_DISABLE is in the CNF3 register and CLKOUT_ENABLE, CLKOUT_PS1 is in the CANCTRL register. I must set this register, but i don't know how to do it.
I tried to do that with mcp2515_modifyRegister function but when i try compile program i have error - mcp2515_modifyRegister was private function.
@Klaus_K
I was analyzing the library and I see functions for modifying bits but I can't call it.
MCP_CAN the library is set to SOF_ENABLE by default. I checked it with a logical analyzer.
The microcontroller has its own crystal 16MHz, two MCP2515 Has one crystal 8MHz.
lumos___:
I tried to do that with mcp2515_modifyRegister function but when i try compile program i have error - mcp2515_modifyRegister was private function.
Change the private/public visibility in the header file.
It is disabled. SOF was more useful to me early on. The easiest/fastest way to modify that library would be to do the following:
In the following function:
/*********************************************************************************************************
** Function name: mcp2515_configRate
** Descriptions: Set baudrate
*********************************************************************************************************/
INT8U MCP_CAN::mcp2515_configRate(const INT8U canSpeed, const INT8U canClock)
{ ...
Change:
mcp2515_setRegister(MCP_CNF3, cfg3);
To:
mcp2515_setRegister(MCP_CNF3, (cfg3 & 0x7F));
However, you are right that this should be exposed as a function in some manner though. I'll have to think about how to architect that into the library.