CHANGE I2C pins to GPIO Pins

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

cross mob
Anonymous
Not applicable

Hi everybody,

   

for a project, I have to change pins from I2C to GPIO, in order to drive them thorugh FW, because of test procedures in software.

   

So I set up Pins 4.0 and 4.1 for I2C SCK, and SDA, but, during SW, IF a condition occurs, I have to change 4.0 and 4.1 to GPIOs pins.

   

 

   

So i made this changes...

   

 

   

if (testing)

   

{

   

   regVal=CY_GET_REG32(CYREG_HSIOM_PORT_SEL4);
             regVal&= ~ 0x00000F00u;
              
             // setta il PIN COME GPIO OUTPUT , configurazione del registro
             regVal=CY_SET_REG32(CYREG_HSIOM_PORT_SEL4,regVal|(HSIOM_SW_GPIO<<0u));
                  
              
             I2C_scl_SetDriveMode(I2C_scl_DM_STRONG); // output digitale SCL
            
             regVal=CY_GET_REG32(CYREG_HSIOM_PORT_SEL4);
             regVal&= ~ 0x00000F00u;
              
             // setta il PIN COME GPIO OUTPUT , configurazione del registro
             regVal=CY_SET_REG32(CYREG_HSIOM_PORT_SEL4,regVal|(HSIOM_SW_GPIO<<0u));
                  
              
             I2C_sda_SetDriveMode(I2C_sda_DM_STRONG); // output digitale SDA 

   

 

   

 

   

}

   

 

   

 

   

Then I try to drive these pins by software but is not possible. Have you any ideas or I am not doing something?

   

 

   

Thanks,

   

David.

0 Likes
7 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Port 4 pins are reserved to the Uart  and I2C PSOC Creator will flag them if you try to use them as GPIO.

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

This is not quite correct, Bob 😉

   

You may disable the hardware connection and use the port4 pin with pin_Write() and pin_Read(). This is probably what David wants to do.

   

 

   

Bob

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Bob I have tried this and Psoc Creator complains. But I'll check it again and see what happens.

0 Likes
Anonymous
Not applicable

Hi everybody,

   

I solved,

   

The code I wrote is correct except one line...

   

regVal&= ~ 0x00000F00u;

   

 

   

FOR I2C pin SCL, 4.0

   

I have to write

   

 

   

regVal&= ~ 0x0000000Fu;

   

 Because I have to write bits concerting to port 4.0 of HSIOM, now it works 🙂

0 Likes

Hi davide.rossi​ , thank you for this information.

Do you know if it is possible to do the same with PSoC  5LP ?

I have searched the datasheets and application notes and seems that HSIOM to PSoC 4 is the same as the digital system interconnect (DSI) to PSoC 5. But I have no idea about how to use this.

0 Likes

There is a "Register Technical Reference Manual" which lists *ALL* registers used for setting the design. There ou may find the information for setting the DSI.

Bob

0 Likes
Anonymous
Not applicable

I have a question which may or may nor fit in with this issue?
Bootloader will not work when P4[0] and P4[1] Connected to I2C bus

0 Likes