How to set or clear a register bit in software?

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

cross mob
Anonymous
Not applicable

Hi!

i use a CY8C4024LQI-S412 and i want to use the internal 1,2v reference on Pin 4.0.

The idea is to set the register bit 24 (SW_SGRE) in the register CSD_SW_REFGEN_SEL.

My problem is, how can i set or clear this bit?

i tried:

         CSD_SW_REFGEN_SEL |= (1 << SW_SGRE);

but it doesnt work.

0 Likes
1 Solution
Anonymous
Not applicable

Hi Bob,

now i used

refgen = CY_GET_REG32(0x400B02A8);

refgen |= 0x1000000;    // Mask Bit 24

CY_SET_REG32(0x400B02A8, refgen);    // Set register CSD_SW_REFGEN_SEL (Bit 24)

and it works!

View solution in original post

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Try a

        CSD_SW_REFGEN_SEL |= ((uint32)1 << SW_SGRE);

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

sorry, i doesnt work.

I get the message    "use of undeclared identifier CSD_SW_REFGEN_SEL"

0 Likes

The original question was "How to set or clear a register bit in software?"

Can you please post your complete project so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

now i used

refgen = CY_GET_REG32(0x400B02A8);

refgen |= 0x1000000;    // Mask Bit 24

CY_SET_REG32(0x400B02A8, refgen);    // Set register CSD_SW_REFGEN_SEL (Bit 24)

and it works!

0 Likes