Manually Drive SDA and SCL, I2C PSOC 4200

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

cross mob
Anonymous
Not applicable

Hi, so here goes.... I have a sensor that i  talk to over I2C everything seems to be setup correctly as I'm able to query the device and get valid data over I2C, what i try to do next is put my device to sleep and then wake it up over I2C by utilizing the 

   

moduleName_sda_Write(uint8 byte)

   

moduleName_scl_write(uint8 byte)

   

as the spec requires SDA be held LOW for a certain amount of time. 

   

The problem i run into is it doesn't seem that my sda_write() is ever happening as im not seeing them on my logic analyzer and the device never wakens, anyone have any hints as to where  to look next?

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

Can you post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

That's not going to be possible as what I'm working on is not a personal project, but rather a product.

   

I'm trying to do exactly what this person is doing except on the PSOC 4 platform. The code provided by another user seems to break under PsocCreator 3.2

   

http://www.cypress.com/forum/psoc-5-device-programming/manually-driving-pins-which-are-also-used-i2c

0 Likes
Anonymous
Not applicable

Is there really no one that can point me in the right direction without having to expose the code?

0 Likes
Anonymous
Not applicable

Hello Samuel,

   

 

   

You need to edit the HSIOM register to change the pin from SCB to GPIO.

   

I am attaching an example that I had done it for SCB SPI. The same should work for SCB I2C as well.

   

Kindly let me know if you have any issues.

   

 

   

Thanks,

   

Keerthi

0 Likes
Anonymous
Not applicable

Hi Keerthi,

   

I greatly appreciate your help. I took a look at the attached example and replicated the register writes that you do in your example with the HSIOM register. My I2C SCB block uses Port4 for my SCL and SDA pins, so i changed your CYREG_HSIOM_PORT_SEL0 to CYREG_HSIOM_PORT_SEL4 and then utilize the respective read and write methods from the I2C block. I still don't see the wake up sequence that I'm attempting to do, I only pickup the I2C communication attempts the PSOC makes to the sensor afterwards, of course i get no response as the sensor is still in sleep mode.

   

Is there anything else I'm missing? 

   

Am i supposed to use some other method for driving SDA and SCL?

   

Thank You,

   

Samuel

0 Likes
Anonymous
Not applicable

Hi Keerthi,

   

Looks like its a false alarm, With your sample code i was able to figure  it out and got it working as intended.

   

SCB_HSIOM_GPIO_SEL = 0x00u

   

SCB_HSIOM_I2C_SEL = 0x0Eu

   

SCB_HSIOM_SPI_SEL = 0x0Fu

   

You were using SPI so it was slightly different for me as you can see above so i simply do...

   

CY_SET_REG32(CYREG_HSIOM_PORT_SEL4,  0x00000000);

   

and 

   

CY_SET_REG32(CYREG_HSIOM_PORT_SEL4 , 0x000000EE);

   

and that allows me to work with the pins i need 

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Attaching the project

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Sleep Mode ref material -

   

 

   

http://www.cypress.com/documentation/application-notes/an86233-psoc-4-low-power-modes-and-power-redu...         AN86233 - PSoC® 4 Low-Power Modes and Power Reduction Techniques

   

http://www.cypress.com/documentation/application-notes/an90114-psoc-4000-family-low-power-system-des...                         AN90114 - PSoC® 4000 Family Low-Power System Design Techniques

   

http://www.cypress.com/documentation/application-notes/an92584-designing-low-power-and-estimating-ba...                          AN92584 - Designing for Low Power and Estimating Battery Life for BLE Applications

   

http://video.cypress.com/video-library/search/psoc+4+low+power/

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

What is the sensor part number ?

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Hi Dana,

   

The sensor I'm using is a Melexis IR sensor 90614, if you see my response to Keerthi, you will see the solution i have come up with. Btw: I'm using two pins off of port 4 

   

 

   

-Samuel

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I have used that part in a PSOC 1 design, great device.

   

 

   

Note it is an SMBUS device.

   

 

   

Did you observe this (from datssheet) -

   

 

   

8.4.8 Sleep Mode

   


The MLX90614 can enter in Sleep Mode via the command “Enter SLEEP mode” sent via the SMBu
interface. This mode is not available for the 5V supply version. There are two ways to put MLX90614 in
power-up default mode:
- POR
- By Wake up request   SCL pin high and then PWM/SDA pin low for at least tDDQ > 33ms

   

 

   

Regards, Dana.
 

0 Likes
Anonymous
Not applicable

Hi Dana,

   

I saw the note about the sensor being SMBUS, i had no issues putting the sensor to sleep, it was the waking up that caused quite a bit of head scratching... I'm still new to the PSOC platform so there is a bit of a learning curve.

   

-Samuel

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

To effect the wakeup you can  always use register writes to effect the I2C

   

pins wakeup requirements of the Melexis.

   

 

   

http://www.cypress.com/documentation/application-notes/an86439-psoc-4-using-gpio-pins                                                   AN86439 - PSoC® 4 - Using GPIO Pins

   

 

   

Regards, Dana.

0 Likes