How do you determine brown out detection event?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaPi_1514011
Level 3
Level 3
First like received

Hi

CYBLE-022001-00.

From PRoC BLE Registers TRM, Document No. 001-93112 Rev. *B, it says:

    // To detect brown-outs firmware should do this on boot:

    // 1. Set key= KEY16

    // 2. Set KEY16= 0x3A71

    // 3. If key==0x3A71 this was a brown-out event.

    // Default Value: X

I implemented this as follows, but it appears to raise an exception on the processor when running.

Is there an unlock or something that has to occur before this register can be written to?

int BootTestAndEnableBodOnRestart(void)

{

    // from PRoC BLE Registers TRM, Document No. 001-93112 Rev. *B

    // To detect brown-outs firmware should do this on boot:

    // 1. Set key= KEY16

    // 2. Set KEY16= 0x3A71

    // 3. If key==0x3A71 this was a brown-out event.

    // Default Value: X

   

    unsigned short key = CY_GET_REG16(CYREG_PWR_BOD_KEY);

   

    CY_SET_REG16(CYREG_PWR_BOD_KEY,0x3A71);

   

    return (key == 0x3A71);

}

0 Likes
1 Solution
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

DaPi_1514011

The error is occurring because you are trying to access a 32 bit register using CY_SET_REG16. Please use macro CY_SET_REG32 instead.

Thanks and regards

Harigovind

View solution in original post

0 Likes
6 Replies