本帖最后由 gaolf_2000 于 2023-11-2 11:29 编辑
参照库里面的
void ertc_bpr_data_write(ertc_dt_type dt, uint32_t data)
{
__IO uint32_t reg = 0;
reg = ERTC_BASE + 0x50 + (dt * 4);
*(__IO uint32_t *)reg = data;
}
uint32_t ertc_bpr_data_read(ertc_dt_type dt)
{
__IO uint32_t reg = 0;
reg = ERTC_BASE + 0x50 + (dt * 4);
return (*(__IO uint32_t *)reg);
}
写的:
void ertc_bpr_16bitdata_write(uint16_t dt, uint16_t data)
{
__IO uint16_t reg = 0;
reg = ERTC_BASE + 0x50 + (dt * 2);
*(__IO uint16_t *)reg = data;
}
uint16_t ertc_bpr_16bitdata_read(uint16_t dt)
{
__IO uint16_t reg = 0;
reg = ERTC_BASE + 0x50 + (dt * 2);
return (*(__IO uint16_t *)reg);
}
时钟使能了,访问也使能了,但还是写不进去,读出来都是0xffff,不明白原因
crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
pwc_battery_powered_domain_access(TRUE); |
ARM指针都是占用32bit大小空间的,你定义一个仅16bit大小的变量存32位地址,装不下啊!