Skip to content

A default for oscillator frequency can be determined by looking at F_CPU #20

Open
@leres

Description

@leres

I'm using something similar to:

#if F_CPU == 20000000UL
#define MCP_SPEED MCP_20MHZ
#elif F_CPU == 16000000UL
#define MCP_SPEED MCP_16MHZ
#elif F_CPU == 8000000UL
#define MCP_SPEED MCP_8MHZ
#else
#error "Unsupported F_CPU value"
#endif
[...]
mcp2515.setBitrate(CAN_500KBPS, MCP_SPEED);

But it wouldn't be difficult to change the default speed from 16MHz to a speed based on the arduino clock. I'm happy to make the changes and issue a pull request if this is interesting.

Also you could free up some program memory by changing setBitrate() to conditionally compiling the canClock cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions