F407_05_位带操作
发布日期:2021-05-07 14:37:20 浏览次数:19 分类:精选文章

本文共 1878 字,大约阅读时间需要 6 分钟。

?????????

??GPIOF?ODR?????

???LED??????GPIOF?ODR????????????????????

  • ?ODR?????????GPIOF_ODR??????????GPIOF_ODR????0x40021400 + 0x14?

  • ??ODR????????????????bit9????

  • ????????bit9???0?????????*GPIOF_ODR = (*GPIOF_ODR) & (~(1 << 9))?

  • ??ODR?????????????

  • ?????????????????????????????????????????????????????????

    Cortex-M4?????

    ?Cortex-M4?????????Peripheral??????????????

  • ????Bit Band Region??

    • ??4??????????
    • ????????????????
  • ??????Bit Band Alias??

    • ???????????????
    • ???????????????????????
  • ?????1bit????

    ??????????????????????????????

    unsigned int *room = (unsigned int *)(0x42000000);
    *room = 1; // ????0x40000000~0x40000004?bit0??1

    ??????????????????????????

    ?GPIOF?ODR?bit9????????

    ??GPIOF_ODR????0x40021400 + 0x14??????????????????????

  • ????????

    ????? = (0x40021414 - 0x40000000) * 32 + 0x42000000
    ???0x40021414?GPIOF_ODR??????????

  • ??bit9???

    bit9?? = (0x40021414 - 0x40000000) * 32 + 0x42000000 + 4 * 9
    ???4 * 9???bit9??bit???4????

  • ?????

    ??????? = 0x42000000 + ((????? - 0x40000000) * 32) + (??? * 4)

    ??LED

    unsigned int *GPIOF_ODR = (unsigned int *)(((0x40021400 + 0x14 - 0x40000000) * 32 + 0x42000000) + 4 * 9);
    while (1) {
    // ????
    *GPIOF_ODR = 0x1; // ??bit9?1
    delay(1000000);
    // ????
    *GPIOF_ODR = 0x1; // ??bit9?1
    delay(10000000);
    // ????
    *GPIOF_ODR = 0x0; // ??bit9
    delay(10000000);
    // ????
    *GPIOF_ODR = 0x0; // ??bit9
    delay(10000000);
    }

    ???????*GPIOF_ODR = 0x10????????????????????????

    ?????

    ?RCC???????????????????????????

    /* stm32f4xx.h */
    #define PERIPH_BASE ((uint32_t)0x40000000)
    #define PERIPH_BB_BASE ((uint32_t)0x42000000)
    #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000)
    #define RCC_BASE (AHB1PERIPH_BASE + 0x3800)
    /* stm32f4xx_rcc.c */
    #define CR_OFFSET (RCC_BASE - PERIPH_BASE)
    #define CR_HSION_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (HSION_BitNumber * 4))

    ??????????????????????????????

    上一篇:Document_Style
    下一篇:C语言11_枚举

    发表评论

    最新留言

    关注你微信了!
    [***.104.42.241]2025年04月25日 11时58分38秒