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().
CAN words
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: CAN words
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.
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.
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.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Who is online
Users browsing this forum: No registered users and 51 guests