Announcements
Community Announcement : Welcome to the NEW Cypress Developer Community.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

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*/

0 Likes
1 Solution
GeonaP_26
Moderator
Moderator

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

View solution in original post

0 Likes
1 Reply
GeonaP_26
Moderator
Moderator

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

View solution in original post

0 Likes