Forums - I2C operation

2 posts / 0 new
Last post
I2C operation
Loris
Join Date: 27 Jul 16
Posts: 35
Posted: Fri, 2016-08-19 01:03

I used two PIOs as sda and scl for I2c communicates with a lumen sensor. I used PIO9 as SDA and PIO10 as  SCL. they are pulled-up to 3.3v with a 10k resister.I have init the I2c as follow, but i get none response when i tried to send command to sensor to config. I tried to check I2C status and I2cready() always returns false;

I2c Init code:

  PioSetModes(    ((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)), 
                                            pio_mode_user);
    
    /* Configure the PIOs as Input */
    PioSetDirs(     ((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)), 
                                            FALSE);
    PioSetPullModes(((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)), 
                                            pio_mode_strong_pull_down); 
    PioSetEventMask(((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)), 
                                            pio_event_mode_disable);
    
    /* Configure the I2C controller */
    I2cInit(CSR_LUMEN_PIO_SDA,
            CSR_LUMEN_PIO_SCL,
            I2C_POWER_PIO_UNDEFINED,
            pio_i2c_pull_mode_strong_pull_up);
    
    /* Configure pull mode of the I2C pins */
    PioSetI2CPullMode(pio_i2c_pull_mode_strong_pull_up);
    
    /* Configure the I2C clock */
    I2cConfigClock(I2C_SCL_100KBPS_HIGH_PERIOD, I2C_SCL_100KBPS_LOW_PERIOD);
    
    /* Enable the I2C controller */
    I2cEnable(TRUE);
 
 
after init , I tried to config the sensor
I2CWriteRegister(AL3010_ADDR,REG_SYS_CONFIG,TRUE);
and operation failed.
 
does anybody can help me ?

 

 

  • Up0
  • Down0
Dr. Nissim Zur
Profile picture
Join Date: 6 Jun 16
Location: Skype: nissim.test CSR1010 External design house
Posts: 235
Posted: Sat, 2016-08-27 10:39

This is an error "PioSetModes(    ((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)),                                         pio_mode_user);"

The PIO has to be defined as I2C no user mode. see pio.h

See I2C.h for demo. 

    
  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.