2727 views|2 replies

1w

Posts

25

Resources
The OP
 

Fast CRC calculation on STM32H7/F7 with micropython [Copy link]

 

From: https://forum.micropython.org/viewtopic.php?t=8316&p=47337#p47337

STM32H7/F7 supports custom polynomials, so it can calculate multiple CRCs, while STM32F4 can only calculate the fixed CRC32.

    @micropython.viper
    def __stm_crc_16(self, data, size : int) -> int: # private
        ptr32(stm.CRC + stm.CRC_CR)[0] = (1 << 3) | 1 # Reset and put into 1 byte per write mode.
        crc8 = ptr8(stm.CRC + stm.CRC_DR)
        d = ptr8(data)
        for i in range(size):
            crc8[0] = d[i]
        return ptr32(stm.CRC + stm.CRC_DR)[0]

    if omv.board_type() == "H7":
        stm.mem32[stm.RCC + stm.RCC_AHB4ENR] = stm.mem32[stm.RCC + stm.RCC_AHB4ENR] | (1 << 19) # Enable CRC clock 
        stm.mem32[stm.CRC + stm.CRC_POL] = 0x1021
    elif omv.board_type() == "F7":
        stm.mem32[stm.RCC + stm.RCC_AHB1ENR] = stm.mem32[stm.RCC + stm.RCC_AHB1ENR] | (1 << 12) # Enable CRC clock 
        stm.mem32[stm.CRC + stm.CRC_POL] = 0x1021

Latest reply

Watch it several times   Details Published on 2020-6-19 22:53
 
 

18

Posts

10

Resources
2
 

I don't quite understand.

 
 
 

3

Posts

0

Resources
3
 

Watch it several times

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list