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.

ADS7138-Q1: How to Use ADS7138 Autonomous Mode

Part Number: ADS7138-Q1
Other Parts Discussed in Thread: ADS7138

Tool/software:

Hi everyone!

How to Use ADS7138 Autonomous Mode

After following the flowchart on page 25 of the datasheet, I noticed that when I set the threshold value lower than the current input voltage, the ALERT signal does not change. I also checked the EVENT_FLAG register, but no flags were triggered.
Could you please help me check if there is any issue with the following initialization steps? Thank you.

GR,

HC

static void ADS7138_Alert_Test_Init(void)
{
	ads7138RegWrite.pinConfig.u8 		= 0x00;
	ads7138RegWrite.autoSeqChSel.u8		= 0xFF;
	ads7138RegWrite.sequenceConfig.bits.SEQ_MODE = SET_AUTO;
	ads7138RegWrite.eventRgn.u8 = 0xFF;
	ads7138RegWrite.hysteresisCh[0].bits.HYSTERESIS = 0xF;
	ads7138RegWrite.hysteresisCh[0].bits.H_TH_LSB = 0xF;
	ads7138RegWrite.highThCh[0].H_TH_MSB = 0xFF;
	ads7138RegWrite.eventCountCh[0].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[0].bits.L_TH_LSB = 0xD;
	ads7138RegWrite.lowThCh[0].L_TH_MSB = 0xFA;

	ads7138RegWrite.hysteresisCh[1].bits.HYSTERESIS = 0xF;
	ads7138RegWrite.hysteresisCh[1].bits.H_TH_LSB = 0x1;
	ads7138RegWrite.highThCh[1].H_TH_MSB = 0xAE;
	ads7138RegWrite.eventCountCh[1].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[1].bits.L_TH_LSB = 0xE;
	ads7138RegWrite.lowThCh[1].L_TH_MSB =0xA3;

	ads7138RegWrite.hysteresisCh[2].bits.HYSTERESIS = 0x8;
	ads7138RegWrite.hysteresisCh[2].bits.H_TH_LSB = 0xF;
	ads7138RegWrite.highThCh[2].H_TH_MSB = 0x27;
	ads7138RegWrite.eventCountCh[2].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[2].bits.L_TH_LSB = 0xE;
	ads7138RegWrite.lowThCh[2].L_TH_MSB = 0x24;

	ads7138RegWrite.hysteresisCh[3].bits.HYSTERESIS = 0x8;
	ads7138RegWrite.hysteresisCh[3].bits.H_TH_LSB = 0x8;
	ads7138RegWrite.highThCh[3].H_TH_MSB = 0x2B;
	ads7138RegWrite.eventCountCh[3].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[3].bits.L_TH_LSB = 0x0;
	ads7138RegWrite.lowThCh[3].L_TH_MSB = 0x29;

	ads7138RegWrite.hysteresisCh[4].bits.HYSTERESIS = 0xA;
	ads7138RegWrite.hysteresisCh[4].bits.H_TH_LSB = 0xE;
	ads7138RegWrite.highThCh[4].H_TH_MSB = 0x3A;
	ads7138RegWrite.eventCountCh[4].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[4].bits.L_TH_LSB = 0xC;
	ads7138RegWrite.lowThCh[4].L_TH_MSB = 0x35;

	ads7138RegWrite.hysteresisCh[5].bits.HYSTERESIS = 0xA;
	ads7138RegWrite.hysteresisCh[5].bits.H_TH_LSB = 0xB;
	ads7138RegWrite.highThCh[5].H_TH_MSB = 0x5E;
	ads7138RegWrite.eventCountCh[5].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[5].bits.L_TH_LSB = 0x9;
	ads7138RegWrite.lowThCh[5].L_TH_MSB = 0x59;

	ads7138RegWrite.hysteresisCh[6].bits.HYSTERESIS = 0xA;
	ads7138RegWrite.hysteresisCh[6].bits.H_TH_LSB = 0xE;
	ads7138RegWrite.highThCh[6].H_TH_MSB = 0x3A;
	ads7138RegWrite.eventCountCh[6].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[6].bits.L_TH_LSB = 0xC;
	ads7138RegWrite.lowThCh[6].L_TH_MSB = 0x35;


	ads7138RegWrite.hysteresisCh[7].bits.HYSTERESIS = 0xF;
	ads7138RegWrite.hysteresisCh[7].bits.H_TH_LSB = 0xF;
	ads7138RegWrite.highThCh[7].H_TH_MSB = 0xFF;
	ads7138RegWrite.eventCountCh[7].bits.EVENT_COUNT = 0x00;
	ads7138RegWrite.eventCountCh[7].bits.L_TH_LSB = 0xD;
	ads7138RegWrite.lowThCh[7].L_TH_MSB = 0xFA;

	ads7138RegWrite.alertChSel.u8 = 0xFF;
	ads7138RegWrite.alertPinConfig.bits.ALERT_DRIVE = PUSH_PULL;
	ads7138RegWrite.alertPinConfig.bits.ALERT_LOGIC = ACTIVE_LOW;

	ads7138RegWrite.opmodeConfig.bits.OSC_SEL = SET_HIGH_SPEED;
	ads7138RegWrite.opmodeConfig.bits.CLK_DIV = 0x00;

	ads7138RegWrite.generalConfig.bits.DWC_EN = SET_ENABLE ;
	ads7138RegWrite.sequenceConfig.bits.SEQ_START = SET_START;

	ads7138RegWrite.sequenceConfig.bits.SEQ_START = SET_START;
	ads7138RegWrite.opmodeConfig.bits.CONV_MODE = SET_AUTONOMOUS_MODE;
	ads7138RegWrite.generalConfig.bits.STATS_EN = SET_ENABLE;
	ads7138RegWrite.generalConfig.bits.CNVST = 1;

	TS_ADS7138_HANDLE ads7138TestWrite[ADS7138HANDLESIZE] = {
		{ true, 	 true, 		ADS7138_SERVICE_WRITE_PIN_CFG			},
		{ true, 	 true, 		ADS7138_SERVICE_WRITE_AUTO_SEQ_CH_SEL	},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_SEQUENCE_CFG		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_RGN			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_ALERT_CH_SEL		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_ALERT_PIN_CFG		},

		{ true,		 true, 		ADS7138_SERVICE_WRITE_OPMODE_CFG		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_SEQUENCE_CFG		},
		{ true,		 true, 		ADS7138_SERVICE_WRITE_GENERAL_CFG		},
		{false,		false, 		ADS7138_BlankFunc						},
		{false,		false, 		ADS7138_BlankFunc						},
		{false,		false, 		ADS7138_BlankFunc						},
		{false,		false, 		ADS7138_BlankFunc						},
		{false,		false, 		ADS7138_BlankFunc						}
	};

  • Hi Hsuan Chia,

    Rather than sending the code, are you able to send logic captures of your configuration sequence probing the I2C lines? This helps to verify that the code is executing the expected values at a low level.

    Regards,
    Joel

  • Hi Joel

    The following are the settings and operation methods. Each time an I2C is written, an I2C is read. And attach LA log.

    static void ADS7138_Alert_Test_Init(void)
    {
    	ads7138RegWrite.pinConfig.u8 		= 0x00;		
    	ads7138RegWrite.autoSeqChSel.u8		= 0xFF;		
    	ads7138RegWrite.sequenceConfig.bits.SEQ_MODE = SET_AUTO;		
    
    	ads7138RegWrite.eventRgn.u8 = 0xFF;
    	ads7138RegWrite.hysteresisCh[0].bits.HYSTERESIS = 0xF;
    	ads7138RegWrite.hysteresisCh[0].bits.H_TH_LSB = 0xF;
    	ads7138RegWrite.highThCh[0].H_TH_MSB = 0xFF;
    	ads7138RegWrite.eventCountCh[0].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[0].bits.L_TH_LSB = 0xD;
    	ads7138RegWrite.lowThCh[0].L_TH_MSB = 0xFA;
    
    	ads7138RegWrite.hysteresisCh[1].bits.HYSTERESIS = 0xF;
    	ads7138RegWrite.hysteresisCh[1].bits.H_TH_LSB = 0x1;
    	ads7138RegWrite.highThCh[1].H_TH_MSB = 0xAE;
    	ads7138RegWrite.eventCountCh[1].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[1].bits.L_TH_LSB = 0xE;
    	ads7138RegWrite.lowThCh[1].L_TH_MSB =0xA3;
    
    	ads7138RegWrite.hysteresisCh[2].bits.HYSTERESIS = 0x8;
    	ads7138RegWrite.hysteresisCh[2].bits.H_TH_LSB = 0xF;
    	ads7138RegWrite.highThCh[2].H_TH_MSB = 0x27;
    	ads7138RegWrite.eventCountCh[2].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[2].bits.L_TH_LSB = 0xE;
    	ads7138RegWrite.lowThCh[2].L_TH_MSB = 0x24;
    
    	ads7138RegWrite.hysteresisCh[3].bits.HYSTERESIS = 0x8;
    	ads7138RegWrite.hysteresisCh[3].bits.H_TH_LSB = 0x8;
    	ads7138RegWrite.highThCh[3].H_TH_MSB = 0x2B;
    	ads7138RegWrite.eventCountCh[3].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[3].bits.L_TH_LSB = 0x0;
    	ads7138RegWrite.lowThCh[3].L_TH_MSB = 0x29;
    
    	ads7138RegWrite.hysteresisCh[4].bits.HYSTERESIS = 0xA;
    	ads7138RegWrite.hysteresisCh[4].bits.H_TH_LSB = 0xE;
    	ads7138RegWrite.highThCh[4].H_TH_MSB = 0x3A;
    	ads7138RegWrite.eventCountCh[4].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[4].bits.L_TH_LSB = 0xC;
    	ads7138RegWrite.lowThCh[4].L_TH_MSB = 0x35;
    
    	ads7138RegWrite.hysteresisCh[5].bits.HYSTERESIS = 0xA;
    	ads7138RegWrite.hysteresisCh[5].bits.H_TH_LSB = 0xB;
    	ads7138RegWrite.highThCh[5].H_TH_MSB = 0x5E;
    	ads7138RegWrite.eventCountCh[5].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[5].bits.L_TH_LSB = 0x9;
    	ads7138RegWrite.lowThCh[5].L_TH_MSB = 0x59;
    
    	ads7138RegWrite.hysteresisCh[6].bits.HYSTERESIS = 0xA;
    	ads7138RegWrite.hysteresisCh[6].bits.H_TH_LSB = 0xE;
    	ads7138RegWrite.highThCh[6].H_TH_MSB = 0x3A;
    	ads7138RegWrite.eventCountCh[6].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[6].bits.L_TH_LSB = 0xC;
    	ads7138RegWrite.lowThCh[6].L_TH_MSB = 0x35;
    
    
    	ads7138RegWrite.hysteresisCh[7].bits.HYSTERESIS = 0xF;
    	ads7138RegWrite.hysteresisCh[7].bits.H_TH_LSB = 0xF;
    	ads7138RegWrite.highThCh[7].H_TH_MSB = 0xFF;
    	ads7138RegWrite.eventCountCh[7].bits.EVENT_COUNT = 0x00;
    	ads7138RegWrite.eventCountCh[7].bits.L_TH_LSB = 0xD;
    	ads7138RegWrite.lowThCh[7].L_TH_MSB = 0xFA;
    
    	ads7138RegWrite.alertChSel.u8 = 0xFF;
    	ads7138RegWrite.alertPinConfig.bits.ALERT_DRIVE = PUSH_PULL;
    	ads7138RegWrite.alertPinConfig.bits.ALERT_LOGIC = ACTIVE_LOW;
    
    	ads7138RegWrite.opmodeConfig.bits.OSC_SEL = SET_HIGH_SPEED;
    	ads7138RegWrite.opmodeConfig.bits.CLK_DIV = 0x00;
    
    	ads7138RegWrite.generalConfig.bits.DWC_EN = SET_ENABLE ;
    	ads7138RegWrite.sequenceConfig.bits.SEQ_START = SET_START;
    
    	ads7138RegWrite.sequenceConfig.bits.SEQ_START = SET_START;		
    	ads7138RegWrite.opmodeConfig.bits.CONV_MODE = SET_AUTONOMOUS_MODE;	
    	ads7138RegWrite.generalConfig.bits.STATS_EN = SET_ENABLE;		
    	ads7138RegWrite.generalConfig.bits.CNVST = 1;				
    
    	TS_ADS7138_HANDLE ads7138TestWrite[ADS7138HANDLESIZE] = {
    	    // enable, event, handle
    		{ true, 	 true, 		ADS7138_SERVICE_WRITE_PIN_CFG			},
    		{ true, 	 true, 		ADS7138_SERVICE_WRITE_AUTO_SEQ_CH_SEL	},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_SEQUENCE_CFG		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_RGN			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HYSTERESIS		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_HIGH_TH			},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_EVENT_COUNT		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_LOW_TH			},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_ALERT_CH_SEL		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_ALERT_PIN_CFG		},
    
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_OPMODE_CFG		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_SEQUENCE_CFG		},
    		{ true,		 true, 		ADS7138_SERVICE_WRITE_GENERAL_CFG		},
    		{false,		false, 		ADS7138_BlankFunc						},
    		{false,		false, 		ADS7138_BlankFunc						},
    		{false,		false, 		ADS7138_BlankFunc						},
    		{false,		false, 		ADS7138_BlankFunc						},
    		{false,		false, 		ADS7138_BlankFunc						}
    	};
    
    	TS_ADS7138_HANDLE ads7138TestRead[ADS7138HANDLESIZE] = {
    			{ true, 	false, 		ADS7138_SERVICE_READ_SYSTEM_STATUS		},
    			{ true, 	false, 		ADS7138_SERVICE_READ_PIN_CFG			},
    			{ true,		false, 		ADS7138_SERVICE_READ_AUTO_SEQ_CH_SEL	},
    			{ true,		false, 		ADS7138_SERVICE_READ_SEQUENCE_CFG		},
    			{ true,		false, 		ADS7138_SERVICE_READ_RECENT 			},
    
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_RGN			},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		true, 		ADS7138_SERVICE_READ_HYSTERESIS			},
    			{true,		true, 		ADS7138_SERVICE_READ_HIGH_TH			},
    			{true,		true, 		ADS7138_SERVICE_READ_EVENT_COUNT		},
    			{true,		true, 		ADS7138_SERVICE_READ_LOW_TH				},
    
    			{true,		false, 		ADS7138_SERVICE_READ_EVENT_FLAG			},
    			{true,		false, 		ADS7138_SERVICE_READ_ALERT_CH_SEL		},
    			{true,		false, 		ADS7138_SERVICE_READ_GENERAL_CFG		},
    			{true,		false, 		ADS7138_SERVICE_READ_OPMODE_CFG			},
    			{false,		false, 		ADS7138_BlankFunc						},
    			{false,		false, 		ADS7138_BlankFunc						},
    			{false,		false, 		ADS7138_BlankFunc						},
    			{false,		false, 		ADS7138_BlankFunc						}
    	};
    	memcpy(ads7138WriteHandle, ads7138TestWrite, sizeof(ads7138TestWrite));
    	memcpy(ads7138ReadHandle, ads7138TestRead, sizeof(ads7138TestRead));
    }

    void I2C_Schedule(void)
    {
    	switch(i2cSched) {
    		case i2c_isIdle:
    			i2cSched = i2c_isWrite;
    			break;
    			
    		case i2c_isWrite:
    			I2C_TX_Schedule();
    			i2cSched = i2c_isRead;
    			break;
    			
    		case i2c_isRead:
    			I2C_RX_Schedule();
    			i2cSched = user_functions;
    			break;
    			
    		case user_functions:
    			i2cSched = i2c_isWrite;
    			break;
    
    		default:
    			i2cSched = i2c_isIdle; 
    			break;
    	}
    }

    ADS7138.csv

    GR,

    HC

  • Hi Hsuan Chia,

    Apologies for the delay in the response here. I've been trying to go through the log thoroughly and understand the configurations being done.

    I see you are configuring the EVENT_RGN register to set the event flags when the conversion result is between the low and high thresholds. This is similar to the "signal in band" condition shown in figure 8-9 of the datasheet.

    Is this what you would be expecting? To trigger the alarm when the EVENT_RGN = 1, the input signal must be higher than the low threshold, and lower than the high threshold. 

    If we focus on one channel specifically, say CH0, the high threshold looks to be set to 0xFFF. The low threshold is set to 0xFAD. Hysteresis is set to 0xF, which is left shifted by three bits, and applied to the 7 least significant bits of the conversion. The event count is set to 0, which means 1 reading will cause the ALERT pin to be active.

    What input are you giving to the device? What do the MIN_VALUE_CH0 and MAX_VALUE_CH0 registers show as the values? Any value greater than 0xFAD && less than 0xFFF will cause the alert to become active.I believe all other registers have been configured correctly.

    Regards,
    Joel

  • Hi Joel

    I expect that when my input voltage drops below the low threshold or rises above the high threshold, an alarm will be triggered.

    Here are my settings :

    AVDD 5V
    V MAX MIN MAX(12-bit) MIN(12-bit)
    AIN0 5 5 4.9 0xFFF 0xFAD
    AIN1 3.3 3.4 3.2 0xAE1 0xA3E
    AIN2 0.75 0.78 0.72 0x27F 0x24E
    AIN3 0.825 0.85 0.8 0x2B8 0x290
    AIN4 1.1 1.15 1.05 0x3AE 0x35C
    AIN5 1.8 1.85 1.75 0x5EB 0x599
    AIN6 3.3 3.4 3.2 0xAE1 0xA3E
    AIN7 5 5 4.9 0xFFF 0xFAD

    After that, the input voltage prepared with the same reference voltage will be changed to use voltage division

    Is there a way I can perform the alarm test without changing the design (and without adjusting the input voltage)?
    For example, set the upper and lower thresholds of AIN4 to AIN1, so once I set the parameters and start the conversion, the alarm will be triggered immediately? (AIN4 input voltage 1.1V <3.2V)

    GR,

    HC

  • Hi Hsuan Chia, 

    If you would like to trigger the ALERT when the analog input goes higher than the high threshold, or lower than the low threshold, I believe you can keep the EVENT_RGN field to the default values. See the case from figure 8-9. The alert is triggered (dotted line region) when the signal exceeds the high threshold, or is lower than the low threshold.

    Yes, you should be able to trigger the alert by changing the high and low limits, without changing the input voltage. The alarm will be set once the input voltage falls out of range.

    Regards,
    Joel

  • Hi Joel

    I wrote the following settings, but the alarm did not trigger or the alarm was incorrect

    ain0/ch0 5V ~ 0xFFB
    EVENT_RGN  0x01 0x01 0x00
    High Th 0x222 0xFFF 0x222
    Low Th 0x111
    Hysteresis 0x00
    Event_count 0x00
    Event Flag ch0 Not_det Not_det Det

    Are there any errors or adjustments in the settings?

    GR,

    HC

  • Hi Joel

    I try to read the High/Low Flag. When I set the following, the Event High Flag is triggered. Why ?

    EVENT_RGN  0x00
    High Th 0xffe
    Low Th 0x001
    Hysteresis 0x00
    Event_count 0x00
    Event Flag 0xFF
    Event High Flag 0xFF
    Event Low Flag 0x00
    Recent CH 0 0xffc0
    Recent CH 1 0xa7c0
    Recent CH 2 0x2780
    Recent CH 3 0x2a10
    Recent CH 4 0x38b0
    Recent CH 5 0x5c60
    Recent CH 6 0xa900
    Recent CH 7 0xfe70

    GR,

    HC

  • Hi HC,

    Apologies for the delay again. I was out of office for a majority of the last week. 

    So it seems like you have set the high and low thresholds close to the extremes of the input. Can you clarify if the high and low thresholds are applied to each channel, or just channel 0?

    Since all of the channels are showing the high flag, can you check the MAX_CHx register values?

    What was the sequence that the high and low thresholds were set, when the event flags were read, and when the recent channel registers were read back?

    Provided the MAX conversion values exceed the high threshold, this seems to be working correctly. My biggest concern is that the sequence that the registers were set might have set the high thresholds inadvertently.

    Regards,
    Joel

  • Hi Joel

    I temporarily set all channels to the same threshold to test the alarm function.

    The values ​​are as follows:

    1. Set high and low thresholds
    2. Read the recent register
    3. Read event flags

    GR,

    HC