3 Replies Latest reply on Sep 20, 2017 11:04 AM by t.go_2259821

    Control Register Write

    t.go_2259821

      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?

        • 1. Re: Control Register Write
          user_342122993

          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.

          • 2. Re: Control Register Write
            t.go_2259821

            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....

            • 3. Re: Control Register Write
              t.go_2259821

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