I have compiled and uploaded the MicroPython built for Nucleo (with one modification described in viewtopic.php?f=12&t=7637 ).
However, when testing CAN, I have found that the base clock for CAN is 8 MHz instead of 100MHz, even though the pyb.freq reports:
Code: Select all
>>> pyb.freq()
(400000000, 200000000, 100000000, 100000000)
Code: Select all
can.init(pyb.CAN.NORMAL,extframe=False,prescaler=8,sjw=1,bs1=7,bs2=2)
When I tried to set the filter as described in documentation ( http://docs.micropython.org/en/v1.12/li ... b.CAN.html ), I get the following error:
Code: Select all
>>> can.setfilter(0, CAN.LIST16, 0, (123, 124, 125, 126))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'CAN' has no attribute 'LIST16'
Code: Select all
#define LIST16 (1)
Code: Select all
>>> can.setfilter(0, 1, 0, (123, 124, 125, 126))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: CAN filter parameter error
Analysis of that function have shown, that the above filter definition does not work for FDCAN controller available in STM32H7 chips:
Code: Select all
#if MICROPY_HW_ENABLE_FDCAN
FDCAN_FilterTypeDef filter = {0};
filter.IdType = FDCAN_STANDARD_ID;
// TODO check filter index
filter.FilterIndex = args[ARG_bank].u_int;
// Check filter mode
if (((args[ARG_mode].u_int != FDCAN_FILTER_RANGE) &&
(args[ARG_mode].u_int != FDCAN_FILTER_DUAL) &&
(args[ARG_mode].u_int != FDCAN_FILTER_MASK))) {
goto error;
}
Code: Select all
#define FDCAN_FILTER_RANGE ((uint32_t)0x00000000U) /*!< Range filter from FilterID1 to FilterID2 */
#define FDCAN_FILTER_DUAL ((uint32_t)0x00000001U) /*!< Dual ID filter for FilterID1 or FilterID2 */
#define FDCAN_FILTER_MASK ((uint32_t)0x00000002U) /*!< Classic filter: FilterID1 = filter, FilterID2 = mask */
#define FDCAN_FILTER_RANGE_NO_EIDM ((uint32_t)0x00000003U) /*!< Range filter from FilterID1 to FilterID2, EIDM mask not applied */
Code: Select all
>>> can.setfilter(0, 0, 0, (0x100,0x120))
>>>
Yet another remark. It seems that `rxcallback` method doesn't work. I had to poll for received messages:
Code: Select all
while True:
if can.any(0):
print(can.recv(0))
Wojtek