How to get silabs Si1141 out of suspended mode

Discussion in 'Programmer's Corner' started by jokkeedk, Mar 20, 2015.

  1. jokkeedk

    Thread Starter New Member

    Mar 20, 2015
    1
    0
    Trying to read the PS1 values. But as im running the following code it keeps saying on "chip_stat" that its suspended.

    Code (Text):
    1.  
    2. main (void){
    3.  
    4. init();// Configuration initialization
    5. si1141_init();// Si1141 sensor initialization
    6.  
    7. __delay_ms(30);// Delay to ensure Si1141 is completely booted, must be atleast 25ms
    8.  
    9. si1141_WriteToRegister(REG_IRQ_STATUS,0xFF);// Clear interrupt source
    10.  
    11. signed int status;
    12.  
    13. while(1){
    14.  
    15. WriteToI2C(0x5A<<1);// Slave addressPutByteI2C(0x30);// chip_stat
    16. ReadFromI2C(0x5A<<1);// Slave address
    17. if((status =GetByteI2C(0x30))==Sw_I2C_ERROR)// part_id{
    18. returnSw_I2C_ERROR;
    19. }
    20. Stop_I2C();
    21. status++;
    22. }
    23. }
    24.  
    The code im using to read the PS1 values is the following. Im reading the value 16705. Which keeps being the same on all measurements.

    The value should go up and down from 0 - 32767, as it measures more or less movement.

    Code (Text):
    1.  
    2. signedint si1141_ReadFromRegister(unsignedchar reg){signedint data;
    3.  
    4. WriteToI2C(0x5A<<1);// Slave address
    5. ReadFromI2C(0x5A<<1);// Slave address
    6. if((data =GetByteI2C(Sw_I2C_LAST))==Sw_I2C_ERROR){
    7. return Sw_I2C_ERROR;
    8. }
    9. Stop_I2C();
    10. return data;
    11. }
    12.  
    13. main (void){
    14.  
    15. init();// Configuration initialization
    16. si1141_init();// Si1141 sensor initialization
    17.  
    18. __delay_ms(30);// Delay to ensure Si1141 is completely booted, must be atleast 25ms
    19.  
    20. si1141_WriteToRegister(REG_IRQ_STATUS,0xFF);// Clear interrupt source
    21.  
    22. signedint PS1;
    23.  
    24. while(1){
    25.  
    26. PS1 = si1141_ReadFromRegister(REG_PS1_DATA0)+(256* si1141_ReadFromRegister(REG_PS1_DATA1));// Proximity CH1
    27.  
    28. }
    29. }
    30.  
    I linked the files for the i2c communication.

    https://www.dropbox.com/s/q41vw444gjvj0qa/swi2c.c?dl=0
    https://www.dropbox.com/s/1mshyz88o15hz8c/swi2c.h?dl=0

    Moderators note : Please use code tags for pieces of code
     
Loading...