RTC PCF2131 issue with Timestamp

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

RTC PCF2131 issue with Timestamp

898件の閲覧回数
simoberny
Contributor III

Hello,

I'm currently testing the PCF2131 RTC with I2C connection, on a Variscite devkit powered by i.MX8M Plus with Yocto Kirkstone (kernel 5.15.71). 

The RTC works fine, but I have some strange behavior with the timestamp functions. 

This is what I've done to make it work: 

  • Updated the driver in the kernel to support the PCF2131 (support added from kernel 6.6 >)
  • Add the RTC definition in the device tree
  • Boot up the board and checked the RTC was correctly recognized

By default, as the datasheet states, the battery switch over is not active and timestamps save only the first triggered event (and not overwrites itself when triggered again).

I'm interested in:

  1. Having the battery switch-over active
  2. Saving the event in TS4 when RTC switch over (control bit BTSE in register control 4)
  3. Timestamp (TS) overwriting themself when triggered

 

To do so I made the following changes: 

function pcf2127_enable_ts in rtc-pcf2127.c
Set TSM (Timestamp mode) to 0. 

 

/* Enable timestamp function. */
ret = regmap_update_bits(pcf2127->regmap,
		        pcf2127->cfg->ts[ts_id].reg_base,
			PCF2127_BIT_TS_CTRL_TSOFF,
			0);

ret = regmap_update_bits(pcf2127->regmap,
			pcf2127->cfg->ts[ts_id].reg_base,
			PCF2127_BIT_TS_CTRL_TSM,
			0);

 

simoberny_3-1701361333037.png

 

function pcf2127_probe in rtc-pcf2127.c 
Enabled switch-over and battery low detection and
set BTSE to 1 and BF to 0 to have the timestamp4 update when switch-over happen. 
Reference: page 17 and 43 of the datasheet to find bit map and default values. 

 

	// Set default behavour of RTC
	// Activate switchover and low battery
	ret = regmap_update_bits(pcf2127->regmap,
			PCF2127_REG_CTRL3,
			PCF2127_BIT_CTRL3_BTSE,
			1);			
	ret = regmap_update_bits(pcf2127->regmap,
			PCF2127_REG_CTRL3,
			PCF2127_BIT_CTRL3_BF |
			PCF2127_BIT_CTRL3_PWR0 | 
			PCF2127_BIT_CTRL3_PWR1 |
			PCF2127_BIT_CTRL3_PWR2,
			0);	  

 

simoberny_0-1701361203757.png

simoberny_2-1701361316264.png

Everything seems to work fine, the RTC time is correct and is maintained when going with the battery. Timestamps correctly overwrite itself when triggered. 

The problem are the following: 

  • When the system is rebooted (so when RTC does the switchover to battery), all the timestamp register reset and become empty. 
  • Some random other time they are not empty after reboot, but filled with the same value with recent date and time.
  • When doing the switch-over TS4 is not updated 

 

Thank you in advande for any help, 

Best regards

 

タグ(5)
0 件の賞賛
返信
2 返答(返信)

870件の閲覧回数
guoweisun
NXP TechSupport
NXP TechSupport

Reboot means power on reset for RTC, right ? if yes, all of the RTC registers will be set as default value.

0 件の賞賛
返信

867件の閲覧回数
simoberny
Contributor III
Yes, I mean turning the board off and on again. I expect the timestamps to remain saved just as the date and time remain saved by using the battery source power.
This is what an RTC is for, if it resets the timestamp registers every time what are they for?

Thanks
0 件の賞賛
返信