PCA2131: AF (Alarm Flag) in Control Register 2 will not be able to clear

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

PCA2131: AF (Alarm Flag) in Control Register 2 will not be able to clear

Jump to solution
486 Views
vikasgupta
Contributor II

Hi everyone,

I am currently integrating the PCA2131 Automotive RTC into a Battery Management System (BMS).

I am encountering a persistent issue where the Alarm Flag (AF, bit 4 of Control_2 register 01h) is stuck high. Basic SPI communication is functioning perfectly-I can successfully set and read the time registers without issue. However, I cannot clear the AF flag during initialization.

Important Context:

  • I have already ensured that all Alarm Enable (AE_X) bits in the alarm registers (0Ah through 0Eh) are set to 1 (disabled) prior to attempting to clear the AF flag.

The sequence I am executing:

  1. Read Control_2 (Register 01h). The AF bit reads as 1.

  2. Clear the flag by setting AF = 0 and AIE = 0 in my local struct.

  3. Write the modified byte back to Control_2.

  4. Read Control_2 again. The AF bit is still 1.

I have attached screenshots from my debug session showing the register states before clearing, during the clear operation, and after reading it back.

My Questions:

  1. Given that all AE_X bits are disabled, what other internal conditions could force the AF flag to immediately re-assert (or prevent it from clearing)?

Any insights or recommendations would be greatly appreciated!

Tags (2)
0 Kudos
Reply
1 Solution
446 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hi Vikas,

thank you for confirmation. Given the PCA2131 behavior described in the datasheet, and assuming AE_S/AE_M/AE_H/AE_D/AE_W are all 1. it does not look the RTC is legitimately re-triggering AF. Most likely cause is bitfield ordering mismatch. Could you please catch and share the scopes of the three reading, writing SPI messages? To confirm the timing and registers/bits written and read. 

JozefKozon_2-1783678052638.png

 

With Best Regards,

Jozef

View solution in original post

0 Kudos
Reply
4 Replies
465 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hi Vikas,

please double check the Alarm registers. These registers have address 0Eh to 12h. 

JozefKozon_0-1783672873300.pngJozefKozon_1-1783672931555.png

Please try to set all the AE_x bits to 1 again. 

With Best Regards,

Jozef

0 Kudos
Reply
456 Views
vikasgupta
Contributor II
Oops, sorry for the typo! The correct address is 0Eh to 12h. I just double-checked, and I did have it correct in my code, so it was just a mistake in my message.
0 Kudos
Reply
447 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hi Vikas,

thank you for confirmation. Given the PCA2131 behavior described in the datasheet, and assuming AE_S/AE_M/AE_H/AE_D/AE_W are all 1. it does not look the RTC is legitimately re-triggering AF. Most likely cause is bitfield ordering mismatch. Could you please catch and share the scopes of the three reading, writing SPI messages? To confirm the timing and registers/bits written and read. 

JozefKozon_2-1783678052638.png

 

With Best Regards,

Jozef

0 Kudos
Reply
439 Views
vikasgupta
Contributor II
Hi Jozef,

Thank you for your support and for pointing me in the right direction.

I checked the SPI messages using the picoscope and verified that the hardware values were correct. Following your suggestion, I debugged my code further and confirmed that the root cause was indeed a bitfield ordering mismatch.

I have fixed the mismatch, and the issue is now fully resolved. Thanks again for your help!

Best regards,
Vikas
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2393538%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPCA2131%3A%20AF%20(Alarm%20Flag)%20in%20Control%20Register%202%20will%20not%20be%20able%20to%20clear%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2393538%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%3C%2FSTRONG%3E%20Automotive%20RTC%20into%20a%20Battery%20Management%20System%20(BMS).%3C%2FP%3E%3CP%3EI%20am%20encountering%20a%20persistent%20issue%20where%20the%20Alarm%20Flag%20(AF%2C%20bit%204%20of%20Control_2%20register%2001h)%20is%20stuck%20high.%20Basic%20SPI%20communication%20is%20functioning%20perfectly-I%20can%20successfully%20set%20and%20read%20the%20time%20registers%20without%20issue.%20However%2C%20I%20cannot%20clear%20the%20AF%20flag%20during%20initialization.%3C%2FP%3E%3CP%3E%3CSTRONG%3EImportant%20Context%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3EI%20have%20already%20ensured%20that%20all%20Alarm%20Enable%20(AE_X)%20bits%20in%20the%20alarm%20registers%20(0Ah%20through%200Eh)%20are%20set%20to%201%20(disabled)%20prior%20to%20attempting%20to%20clear%20the%20AF%20flag.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EThe%20sequence%20I%20am%20executing%3A%3C%2FSTRONG%3E%3C%2FP%3E%3COL%3E%3CLI%3E%3CP%3ERead%20Control_2%20(Register%2001h).%20The%20AF%20bit%20reads%20as%201.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EClear%20the%20flag%20by%20setting%20AF%20%3D%200%20and%20AIE%20%3D%200%20in%20my%20local%20struct.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EWrite%20the%20modified%20byte%20back%20to%20Control_2.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3ERead%20Control_2%20again.%20The%20AF%20bit%20is%20still%201.%3C%2FP%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3EI%20have%20attached%20screenshots%20from%20my%20debug%20session%20showing%20the%20register%20states%20before%20clearing%2C%20during%20the%20clear%20operation%2C%20and%20after%20reading%20it%20back.%3C%2FP%3E%3CP%3E%3CSTRONG%3EMy%20Questions%3A%3C%2FSTRONG%3E%3C%2FP%3E%3COL%3E%3CLI%3E%3CP%3EGiven%20that%20all%20AE_X%20bits%20are%20disabled%2C%20what%20other%20internal%20conditions%20could%20force%20the%20AF%20flag%20to%20immediately%20re-assert%20(or%20prevent%20it%20from%20clearing)%3F%3C%2FP%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3EAny%20insights%20or%20recommendations%20would%20be%20greatly%20appreciated!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2393761%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PCA2131%3A%20AF%20(Alarm%20Flag)%20in%20Control%20Register%202%20will%20not%20be%20able%20to%20clear%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2393761%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHi%20Jozef%2C%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20you%20for%20your%20support%20and%20for%20pointing%20me%20in%20the%20right%20direction.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20checked%20the%20SPI%20messages%20using%20the%20picoscope%20and%20verified%20that%20the%20hardware%20values%20were%20correct.%20Following%20your%20suggestion%2C%20I%20debugged%20my%20code%20further%20and%20confirmed%20that%20the%20root%20cause%20was%20indeed%20a%20bitfield%20ordering%20mismatch.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20fixed%20the%20mismatch%2C%20and%20the%20issue%20is%20now%20fully%20resolved.%20Thanks%20again%20for%20your%20help!%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20regards%2C%3CBR%20%2F%3EVikas%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2393678%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PCA2131%3A%20AF%20(Alarm%20Flag)%20in%20Control%20Register%202%20will%20not%20be%20able%20to%20clear%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2393678%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Vikas%2C%3C%2FP%3E%0A%3CP%3Ethank%20you%20for%20confirmation.%26nbsp%3BGiven%20the%20PCA2131%20behavior%20described%20in%20the%20datasheet%2C%20and%20assuming%20AE_S%2FAE_M%2FAE_H%2FAE_D%2FAE_W%20are%20all%201.%20it%20does%20not%20look%26nbsp%3Bthe%20RTC%20is%20legitimately%20re-triggering%20AF.%20Most%20likely%20cause%20is%20bitfield%20ordering%20mismatch.%20Could%20you%20please%20catch%20and%20share%20the%20scopes%20of%20the%20three%20reading%2C%20writing%20SPI%20messages%3F%20To%20confirm%20the%20timing%20and%20registers%2Fbits%20written%20and%20read.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JozefKozon_2-1783678052638.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22JozefKozon_2-1783678052638.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F391996i653BF2E7FE9DBBB6%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JozefKozon_2-1783678052638.png%22%20alt%3D%22JozefKozon_2-1783678052638.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EWith%20Best%20Regards%2C%3C%2FP%3E%0A%3CP%3EJozef%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2393596%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PCA2131%3A%20AF%20(Alarm%20Flag)%20in%20Control%20Register%202%20will%20not%20be%20able%20to%20clear%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2393596%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EOops%2C%20sorry%20for%20the%20typo!%20The%20correct%20address%20is%200Eh%20to%2012h.%20I%20just%20double-checked%2C%20and%20I%20did%20have%20it%20correct%20in%20my%20code%2C%20so%20it%20was%20just%20a%20mistake%20in%20my%20message.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2393577%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PCA2131%3A%20AF%20(Alarm%20Flag)%20in%20Control%20Register%202%20will%20not%20be%20able%20to%20clear%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2393577%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Vikas%2C%3C%2FP%3E%0A%3CP%3Eplease%20double%20check%20the%20Alarm%20registers.%20These%20registers%20have%20address%200Eh%20to%2012h.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JozefKozon_0-1783672873300.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22JozefKozon_0-1783672873300.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F391982i2A11ADC577311096%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JozefKozon_0-1783672873300.png%22%20alt%3D%22JozefKozon_0-1783672873300.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JozefKozon_1-1783672931555.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22JozefKozon_1-1783672931555.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F391984i2A1B8614ABBB452B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JozefKozon_1-1783672931555.png%22%20alt%3D%22JozefKozon_1-1783672931555.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EPlease%20try%20to%20set%20all%20the%20AE_x%20bits%20to%201%20again.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20Best%20Regards%2C%3C%2FP%3E%0A%3CP%3EJozef%3C%2FP%3E%3C%2FLINGO-BODY%3E