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
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello DaPi_1514011

Can you post the exception that you are observing?

Thanks and regards

Harigovind

0 Likes

Apparently IntDefaultHandler is being called with errno as ENOMEM

#define ENOMEM 12 /* Not enough space */

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

Hi

Please increase the heap size by selecting System in Design wide resources and choosing heap size.

pastedImage_1.png

Please share your project so that we can check this at our end as well.

Thanks and regards

Harigovind

0 Likes

We're tight on memory space.

Why would a register write use heap space?  It's an address macro... what does that then trigger?

0 Likes
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

0 Likes

That worked (or at least now runs ).  I'll only access registers completely in future.

Thank you.

0 Likes