21ic问答首页 - AT32f323电池供电数据寄存器ERTC_BPRx半字操作不成功
AT32f323电池供电数据寄存器ERTC_BPRx半字操作不成功
gaolf_20002023-11-02
参照库里面的
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);
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);
您需要登录后才可以回复 登录 | 注册