1 Reply Latest reply on Jan 31, 2017 5:56 AM by geon

    I2C_Stop and set scl pin to output while running

    michael.linner_2245411

      Hello , I would like to stop i2c communication during runtime and use the scl pin to toggle several times to reset a slaves State Machine. It seems that calling the SCL_Stop() function is not enough to get the scl pin back to normal output function. Here is my code: I2C_Stop(); /* Stop I2C */ I2C_scl_SetDriveMode(I2C_scl_DM_STRONG); /*set DriveMode*/ I2C_scl_Write( 1u ); /*set pin output manually*/

        • 1. Re: I2C_Stop and set scl pin to output while running
          geon

          Hello Jens,

             


          High-Speed I/O Matrix  (HSIOM)  multiplexes the pin and connects to a particular peripheral selected in HSIOM_PORT_SELx register. Please make use of below code to control SCL pin using firmware.

             

              regVal = CY_GET_REG32(I2C_scl__0__HSIOM);
              regVal &= ~I2C_scl__0__HSIOM_MASK;

             

              /* Set Pin as GPIO controlled by firmware */
              regVal = CY_SET_REG32(I2C_scl__0__HSIOM, regVal |(I2C_scl__0__HSIOM_GPIO <<I2C_scl__0__HSIOM_SHIFT)); 

             

              /* Set Pin drive mode */    
              I2C_scl_SetDriveMode(I2C_scl_DM_STRONG); 

             

              for(i= 0u; i < 5u; i++)
              {
                  /* Toggle Pin with 100-ms delay */
                  I2C_scl_Write(0u);
                  CyDelay(100u);
                  I2C_scl_Write(1u);
                  CyDelay(100u);
              }

             

          Thanks and Regards,

             

          Geona Mary