This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHCC3220MODASF: TMP275 ALERT Configuration

Part Number: LAUNCHCC3220MODASF
Other Parts Discussed in Thread: TMP275, SYSCONFIG

Tool/software: Code Composer Studio

Hello,

I am interfacing TMP275 with LAUNCHCC3220MODASF.

Hardware  Config : Alert pin of TMP275   connect with LAUNCHCC3220MODASF (P61).

TMP Software Config :  12 bit resolution and Comparator Mode

 I got Temperature  data successfully .But I didn't get Alert when TMP exceed and equal Thigh and  Tlow .

Here I set interrupt like below.

GPIO_setConfig(CONFIG_GPIO_0, GPIO_CFG_INPUT | GPIO_CFG_IN_INT_FALLING);

/* Install Alert callback */
GPIO_setCallback(CONFIG_GPIO_0, AlertCallBack);
/* Enable interrupts */
GPIO_enableInt(CONFIG_GPIO_0);

Please suggest me where  I am wrong. I tried different polarity and mode but didn't get Alert.

Thanks and Regards,

Nikunj.

  • Hi Nikunj,

    1. Is CONFIG_GPIO_0 configured in SysConfig? What pin are you using?
    2. Have you called GPIO_init() and is AlertCallBack defined? There is an gpiointerrupt example in the drivers folder that may be helpful.
    3. Have you tried using GPIO_CFG_IN_PU?

    Best regards,

    Sarah

  • HI Sarah,

     I have used gpiointerrupt example and  I did the same change in my code.

       I configured SysConfig, and use P61 pin. yes  I  called GPIO_init() and defined AlertCallBack .

       I also tried GPIO_CFG_IN_PU. 

     

    Thanks

    Nikunj.

  • Hi Nikunj,

    Can you test the callback trigger by jumping P61 on the board to GND? Are you able to verify the TMP275 alert signal by measuring voltage or using a logic analyzer?

    Best regards,

    Sarah

  • Hi Sarah,

    I tested the callback working.

     Here is my TMP.c file 

    #include "TMP275.h"
    #include "i2c.h"
    
    static int measurementDelay;    //28ms, 55ms, 110ms, 220ms
    
    
    void set_ploarity()
    {
        uint8_t config = readConfigRegister();
           config &= 0xFB;
            config |= 0x04;
            writeConfigRegister(config);
    }
    
    
    uint8_t TMP_init() {
    
        measurementDelay=28;
        setResolution(12);
        setHighTempThreshold(20);
        setLowTempThreshold(15);
    return 0;
    }
    
    
    uint8_t readConfigRegister() {
    
    	uint8_t config=0;
    	HAL_I2C_Mem_Read(TMP275_ADDR, CONF_REG, &config,1);
    
    	return config;
    }
    
    void writeConfigRegister(uint8_t config) {
    
        HAL_I2C_Mem_Write(TMP275_ADDR, CONF_REG, &config,1);
    }
    
    float getTemperature() {
    	
    	delay_ms(measurementDelay);
    	uint8_t rxBuffer[2];
    	uint16_t result=0;
        HAL_I2C_Mem_Read(TMP275_ADDR, TEMP_REG,rxBuffer, 2);
        result = (rxBuffer[0] << 8 | rxBuffer[1]);
       // temprature=((float)result/256);        //256 try
        return ((float)(int)result / 32) / 8;
    }
    
    
    void setResolution(uint8_t res) {
        uint8_t config = readConfigRegister() & 0x9F;   //Mask out the res bits
        config |= (res-1) << 5;
    
        writeConfigRegister(config);
        //Change measurement delay
        if (res == 10)
            measurementDelay = 28;
        else if (res == 11)
            measurementDelay = 55;
        else if (res == 12)
            measurementDelay = 110;
        else
            measurementDelay = 220;
    }
    
    void enableShutdownMode(bool enable) {
    	uint8_t config = readConfigRegister();
    	config &= 0xFE;		//Mask out LSB
    	if (enable)
    		config |= 0x01;
    	writeConfigRegister(config);
    }
    
    void enableOS() {
    	enableShutdownMode(false);
    	delay_ms(measurementDelay);
    	enableShutdownMode(true);
    }
    
    void enableComparatorMode() {
    	uint8_t config =0;
    	config=readConfigRegister();
         config &= 0xFD;
    
    	writeConfigRegister(config);
    }
    
    void setHighTempThreshold(uint16_t threshold) {
    	
        uint8_t  buffer[2];
        uint16_t value= (uint16_t)((int)(threshold * 8) << 5);
       buffer[0]=(value & 0xFF00) >> 8 ;
       buffer[1]=value &0x00FF;
    	HAL_I2C_Mem_Write(TMP275_ADDR, THIGH_REG,buffer, 2);
    	
    }
    
    void setLowTempThreshold(uint16_t threshold) {
    
    	 uint8_t  buffer[2];
    	  uint16_t value= (uint16_t)((int)(threshold * 8) << 5);
    	   buffer[0]=(value & 0xFF00) >> 8 ;
    	   buffer[1]=value &0x00FF;
    	   HAL_I2C_Mem_Write(TMP275_ADDR, TLOW_REG,buffer, 2);
    
    }
    
    float getHighTempThreshold() {
    
    	uint8_t rxBuffer[2];
        uint16_t result=0;
        HAL_I2C_Mem_Read(TMP275_ADDR, THIGH_REG, rxBuffer, 2);
       
        result = (rxBuffer[0] << 8 | rxBuffer[1]);
           return ((float)(int)result / 32) / 8;
    }
    
    float getLowTempThreshold() {
    
        uint8_t rxBuffer[2];
            uint16_t result=0;
    
        HAL_I2C_Mem_Read(TMP275_ADDR, TLOW_REG, rxBuffer, 2);
        result = (rxBuffer[0] << 8 | rxBuffer[1]);
              return ((float)(int)result / 32) / 8;
    }
    
    int getFaults() {
    	uint8_t config = readConfigRegister();
    	config = (config >> 3) & 0x03;
    	return config;
    }
    
    void Thermostat_mode(){
    
        uint8_t config =0;
            config=readConfigRegister();
             config &= 0xFD; //0xFD;
            config |= 0x02;   //intruppt mode
            writeConfigRegister(config);
    }
    
    
    
    

    Please tell me if anything changes are needed in TMP file .

    I didn't get any voltage change on alert pin

    Nikunj.

  • Hi Nikunj,

    Thanks for confirming the callback is working. Unfortunately, I am not familiar with the requirements for that sensor. I will reassign this thread to another engineer that can help.

    Best regards,

    Sarah

  • Hi Nikunj,

    Could you show me on a logic analyzer what is being written to the TMP275 for configuration?

    Are you waiting long enough after configuration? The Alert will only be asserted at the end of temperature conversions, which could be 220ms apart.

    thanks,

    ren