PCA2131 RTC: Intermittent periodic interrupts (Missed or running 4x faster)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PCA2131 RTC: Intermittent periodic interrupts (Missed or running 4x faster)

63 Views
vikasgupta
Contributor II

Hi everyone,

I am currently integrating the PCA2131 Automotive RTC into a Battery Management System (BMS) and experiencing an inconsistent issue with the periodic interrupt generation.

Issue Description: We are trying to generate an interrupt at a defined interval (e.g., every X minutes). The core problem is that the behavior is highly erratic:

  • Sometimes, the interrupt triggers exactly as expected.

  • Sometimes, the counter appears to run approximately 4x faster than it should.

  • Sometimes, the interrupt is missed entirely.

Because this issue occurs randomly, we are struggling to isolate the root cause.

Testing & Observations:

  • Hardware: We have tested 3–4 different RTC samples, and this abnormal behavior has been observed across multiple units.

  • Clock Configurations: We evaluated the default 32.768 kHz clock, as well as the 16 kHz and 8 kHz configurations.

  • Interrupt Intervals: Tested with 1-minute, 2-minute, and 5-minute intervals.

  • Result: The timing instability persists across these variations.

Request: For reference, I have attached our schematic and the captured waveforms.

Could you please review the attachments and help us understand what could be causing this? We would appreciate any insight into specific register configurations, known errata, or noise/hardware conditions that could lead to this intermittent timing instability.

Thanks in advance for your support.

Labels (1)
Tags (2)
0 Kudos
Reply
3 Replies

41 Views
ErikaC
NXP TechSupport
NXP TechSupport

Hello!

Could you please check the following points?

  • The MSF flag (bit 7 of Control_2, address 01h) must be explicitly cleared after every interrupt. 
    • Always write 0 to MSF (bit 7 of Control_2) in your ISR. Use the AND-write method described in Section 7.11.5 of the datasheet (write 0 to clear, 1 to leave unchanged)

  • If both MI (bit 1) and SI (bit 0) of Control_1 are set, the result is an interrupt once per second not once per minute.
    • Set only MI = 1, SI = 0 in Control_1 for a periodic minute interrupt. Read back the register to confirm.

Please let me know the result.

 

0 Kudos
Reply

23 Views
vikasgupta
Contributor II

I Checked as you suggested me. For that I take screenshot of CTRL_REG_1 and CTRL_REG_2 when alarm trigger and after alarm clear.

 

0 Kudos
Reply

16 Views
ErikaC
NXP TechSupport
NXP TechSupport

Hello,

The writes that disable the alarm comparators by setting AEN_x = 1 are commented out, please uncomment all five lines. These writes must execute before re-arming the next alarm.

In the alarm trigger screenshot, the raw register value ctrl2.w = 18 (0x12 = 0001 0010 binary) correctly shows:

  • Bit 4 = 1 → AF (Alarm Flag) is SET
  • Bit 1 = 1 → AIE (Alarm Interrupt Enable) is SET

However, the struct field ctrl2.b.af is displayed as 0 in the debugger. This means your C bitfield struct definition for Control_2 does not correctly map the af field to bit 4. If any part of the firmware branches on ctrl2.b.af instead of the hardware interrupt line or RTC_ALarm_Flag software variable, it will fail to detect the alarm and miss interrupts entirely  explaining the missed interrupt symptom.

Please verify and correct the bitfield definition of your Control_2 register struct. The af field must be declared at bit position 4.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2407022%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPCA2131%20RTC%3A%20Intermittent%20periodic%20interrupts%20(Missed%20or%20running%204x%20faster)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2407022%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20everyone%2C%3C%2FP%3E%3CP%3EI%20am%20currently%20integrating%20the%20%3CSTRONG%3EPCA2131%20Automotive%20RTC%3C%2FSTRONG%3E%20into%20a%20Battery%20Management%20System%20(BMS)%20and%20experiencing%20an%20inconsistent%20issue%20with%20the%20periodic%20interrupt%20generation.%3C%2FP%3E%3CP%3E%3CSTRONG%3EIssue%20Description%3A%3C%2FSTRONG%3E%20We%20are%20trying%20to%20generate%20an%20interrupt%20at%20a%20defined%20interval%20(e.g.%2C%20every%20X%20minutes).%20The%20core%20problem%20is%20that%20the%20behavior%20is%20highly%20erratic%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CP%3E%3CSTRONG%3ESometimes%3C%2FSTRONG%3E%2C%20the%20interrupt%20triggers%20exactly%20as%20expected.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3ESometimes%3C%2FSTRONG%3E%2C%20the%20counter%20appears%20to%20run%20approximately%204x%20faster%20than%20it%20should.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3ESometimes%3C%2FSTRONG%3E%2C%20the%20interrupt%20is%20missed%20entirely.%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EBecause%20this%20issue%20occurs%20randomly%2C%20we%20are%20struggling%20to%20isolate%20the%20root%20cause.%3C%2FP%3E%3CP%3E%3CSTRONG%3ETesting%20%26amp%3B%20Observations%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CP%3E%3CSTRONG%3EHardware%3A%3C%2FSTRONG%3E%20We%20have%20tested%203%E2%80%934%20different%20RTC%20samples%2C%20and%20this%20abnormal%20behavior%20has%20been%20observed%20across%20multiple%20units.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3EClock%20Configurations%3A%3C%2FSTRONG%3E%20We%20evaluated%20the%20default%2032.768%20kHz%20clock%2C%20as%20well%20as%20the%2016%20kHz%20and%208%20kHz%20configurations.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3EInterrupt%20Intervals%3A%3C%2FSTRONG%3E%20Tested%20with%201-minute%2C%202-minute%2C%20and%205-minute%20intervals.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3EResult%3A%3C%2FSTRONG%3E%20The%20timing%20instability%20persists%20across%20these%20variations.%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3ERequest%3A%3C%2FSTRONG%3E%20For%20reference%2C%20I%20have%20attached%20our%20schematic%20and%20the%20captured%20waveforms.%3C%2FP%3E%3CP%3ECould%20you%20please%20review%20the%20attachments%20and%20help%20us%20understand%20what%20could%20be%20causing%20this%3F%20We%20would%20appreciate%20any%20insight%20into%20specific%20register%20configurations%2C%20known%20errata%2C%20or%20noise%2Fhardware%20conditions%20that%20could%20lead%20to%20this%20intermittent%20timing%20instability.%3C%2FP%3E%3CP%3EThanks%20in%20advance%20for%20your%20support.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2407022%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ertc%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2407097%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PCA2131%20RTC%3A%20Intermittent%20periodic%20interrupts%20(Missed%20or%20running%204x%20faster)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2407097%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello!%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20check%20the%20following%20points%3F%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20MSF%20flag%20(bit%207%20of%20Control_2%2C%20address%2001h)%20must%20be%20explicitly%20cleared%20after%20every%20interrupt.%26nbsp%3B%0A%3CUL%3E%0A%3CLI%3E%0A%3CP%20class%3D%22wnfdntu%20_1ibi0s3f5%20_1ibi0s3ce%20_1ibi0s3ea%22%20data-pm-slice%3D%221%201%20%5B%5D%22%3EAlways%20write%200%20to%20MSF%20(bit%207%20of%20Control_2)%20in%20your%20ISR.%20Use%20the%20AND-write%20method%20described%20in%20Section%207.11.5%20of%20the%20datasheet%20(write%200%20to%20clear%2C%201%20to%20leave%20unchanged)%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EIf%20both%20MI%20(bit%201)%20and%20SI%20(bit%200)%20of%20Control_1%20are%20set%2C%20the%20result%20is%20an%20interrupt%20once%20per%20second%20not%20once%20per%20minute.%0A%3CUL%3E%0A%3CLI%3ESet%20only%20MI%20%3D%201%2C%20SI%20%3D%200%20in%20Control_1%20for%20a%20periodic%20minute%20interrupt.%20Read%20back%20the%20register%20to%20confirm.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EPlease%20let%20me%20know%20the%20result.%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2407485%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PCA2131%20RTC%3A%20Intermittent%20periodic%20interrupts%20(Missed%20or%20running%204x%20faster)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2407485%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EThe%20writes%20that%20disable%20the%20alarm%20comparators%20by%20setting%20AEN_x%20%3D%201%20are%20commented%20out%2C%20please%20uncomment%20all%20five%20lines.%20These%20writes%20must%20execute%20before%20re-arming%20the%20next%20alarm.%3C%2FP%3E%0A%3CP%3EIn%20the%20alarm%20trigger%20screenshot%2C%20the%20raw%20register%20value%20ctrl2.w%20%3D%2018%20(0x12%20%3D%200001%200010%20binary)%20correctly%20shows%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EBit%204%20%3D%201%20%E2%86%92%20AF%20(Alarm%20Flag)%20is%20SET%3C%2FLI%3E%0A%3CLI%3EBit%201%20%3D%201%20%E2%86%92%20AIE%20(Alarm%20Interrupt%20Enable)%20is%20SET%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EHowever%2C%20the%20struct%20field%20ctrl2.b.af%20is%20displayed%20as%200%20in%20the%20debugger.%20This%20means%20your%20C%20bitfield%20struct%20definition%20for%20Control_2%20does%20not%20correctly%20map%20the%20af%20field%20to%20bit%204.%20If%20any%20part%20of%20the%20firmware%20branches%20on%20ctrl2.b.af%20instead%20of%20the%20hardware%20interrupt%20line%20or%20RTC_ALarm_Flag%20software%20variable%2C%20it%20will%20fail%20to%20detect%20the%20alarm%20and%20miss%20interrupts%20entirely%26nbsp%3B%20explaining%20the%20missed%20interrupt%20symptom.%3C%2FP%3E%0A%3CP%3EPlease%20verify%20and%20correct%20the%20bitfield%20definition%20of%20your%20Control_2%20register%20struct.%20The%20af%20field%20must%20be%20declared%20at%20bit%20position%204.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2407460%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PCA2131%20RTC%3A%20Intermittent%20periodic%20interrupts%20(Missed%20or%20running%204x%20faster)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2407460%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20Checked%20as%20you%20suggested%20me.%20For%20that%20I%20take%20screenshot%20of%20CTRL_REG_1%20and%20CTRL_REG_2%20when%20alarm%20trigger%20and%20after%20alarm%20clear.%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E