Control Register Write

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

cross mob
Anonymous
Not applicable

I am a novice at electronics as well as psoc so forgive me here... I have an application that uses a control register with 7 outputs... From what I can understand, when I call I_Control_Reg_Write(0) I turn it off, and if I call I_Control_Reg_Read() first and use the value I read from that and call I_Control_Reg_Write(value) that it will turn this Control Register back on?

0 Likes
1 Solution
Anonymous
Not applicable

I just had to call ADC_Stop, ADC_Start... thanks!

View solution in original post

0 Likes
3 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Not exactly. When you set ControlReg_Write(0), all 7 lines go Low. When you set ControlReg_Write(value), the output of each of 7 lines correspond to bits 6 to 0 of that value. Reading ControlReg_Read() has no effect on the lines state. For example, setting ControlReg_Write(129) produce line states:  6-0, 5-0, 4-0, 3-0, 2-0, 1-0, 0-1.

Sometimes it is necessary to modify existing ControlReg state just for some lines. In such case you have to read/modify like that:

value=ControlReg_Read();

ControlReg_Write(value | 0x02);  // set bit_1 to Hi, leave other as-is.

Anonymous
Not applicable

To give you more insight on what I am doing.... when program first boots up, it is doing this...

TX_ena_Write(0);

I_Control_Reg_Write(0x02);

uint8_t mytemp = I_Control_Reg_Read();   

I_Control_Reg_Write (mytemp & 0x0f);

Then when turning the registers off I am doing this...

g_RegValue = I_Control_Reg_Read();

I_Control_Reg_Write(0);

To turn it on,

I_Control_Reg_Write(g_RegValue);

Which the code chunks above work if I turn off the register for 3 seconds, and turn in on for 1 second... But once I leave it off for more than 3 seconds, I can't seem to turn it back on....

0 Likes
Anonymous
Not applicable

I just had to call ADC_Stop, ADC_Start... thanks!

0 Likes