打印
[AT32F415]

AT32f415CBT7 bit band位带功能不成功

[复制链接]
657|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
简单happy|  楼主 | 2022-2-28 23:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 简单happy 于 2022-2-28 23:05 编辑

使用以前stm32f103 的宏定义公式操作行不通
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
#define MEM_ADDR(addr)  *((volatile unsigned long  *)(addr))
#define BIT_ADDR(addr, bitnum)   MEM_ADDR(BITBAND(addr, bitnum))
我又移植库例程里的相关内容,也不成功
/* bit band for sram  */
#define RAM_BASE                         0x20000000
#define RAM_BITBAND_BASE                 0x22000000

#define VARIABLES_RESET_BIT(variables_addr, bit_number)    \
        (*(uint32_t *)(RAM_BITBAND_BASE + ((variables_addr - RAM_BASE) * 32) + ((bit_number) * 4)) = 0)
   
#define VARIABLES_SET_BIT(variables_addr, bit_number)       \
        (*(uint32_t *)(RAM_BITBAND_BASE + ((variables_addr - RAM_BASE) * 32) + ((bit_number) * 4)) = 1)

#define VARIABLES_GET_BIT(variables_addr, bit_number)       \
        (*(uint32_t *)(RAM_BITBAND_BASE + ((variables_addr - RAM_BASE) * 32) + ((bit_number) * 4)))

/* bit band for peripheral  */
#define PERIPHERAL_BASE                  0x40000000
#define PERIPHERAL_BITBAND_BASE          0x42000000

#define PERIPHERAL_RESET_BIT(peripheral_addr, bit_number)    \
        (*(uint32_t *)(PERIPHERAL_BITBAND_BASE + ((peripheral_addr - PERIPHERAL_BASE) * 32) + ((bit_number) * 4)) = 0)
   
#define PERIPHERAL_SET_BIT(peripheral_addr, bit_number)       \
        (*(uint32_t *)(PERIPHERAL_BITBAND_BASE + ((peripheral_addr - PERIPHERAL_BASE) * 32) + ((bit_number) * 4)) = 1)        
使用库例程,编译下载,是成功的。我看地址起始都是一样的.弄了一晚上也没有找出问题在哪.这个功能我一直是弄得云里雾里的,打算放弃这方法。

使用特权

评论回复
沙发
简单happy|  楼主 | 2022-2-28 23:24 | 只看该作者
本帖最后由 简单happy 于 2022-2-28 23:25 编辑

问题找到了,是因为我改了led灯的端口(测试另外一块打样回来的AT32f415RB板子),没有改回来。见笑了。使用103的宏定义和例程里的,均测试成功

使用特权

评论回复
板凳
zhazhengfeng| | 2022-3-1 14:52 | 只看该作者
高手啊

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

291

帖子

7

粉丝