Page 1 of 1

CAN words

Posted: Fri Nov 17, 2017 7:27 pm
by steved
Minor points:

1. All the CAN test projects for different processors use the same setup values (with one exception - 32L4, IIRC), yet the processors have varying clock speeds. So the comment as to '500kHz baud rate' can't always be correct
2. Probably impossible to implement sensibly, but the CAN setup values should ideally be calculated using the actual clock tree configuration (although I wonder how much people change things from the settings in the demo they picked as a starting point). Perhaps just a note to say that the config needs updating dependent on configured clock dividers, and maybe give the settings the current values assume.
3. There's a lot of use of canTransmit() and canReceive(), which I understand to be deprecated in favour of canTransmitTimeout() and canReceiveTimeout().

Re: CAN words

Posted: Mon Dec 31, 2018 11:14 am
by Giovanni
bump

Re: CAN words

Posted: Mon Dec 31, 2018 7:23 pm
by faisal
The configuration should be in portab.c/.h .

I usually declare the PeriphalConfig struct in the application code, along with the platform independent fields. Then use a macro in portab.h which defines the platform dependent fields.

Code: Select all

CANConfig can1cfg
{
     /* platform independent fields (none for CAN) */
     PORTAB_CAN1_CONFIG, /* platform dependent fields defined in portab.h */
}


I like doing it this way instead of declaring the peripheral structures entirely in portab.c and exporting them via a global. Less code to duplicate, fewer globals, and leverages the platform independent layer of the HAL.

Re: CAN words

Posted: Sun Nov 10, 2019 10:19 am
by Giovanni
bump