Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 3 months ago.
Setting interrupt threshold
I have been working with very similar sensor from AMS (formally know as TAOSinc). I have found your code really helpful. However, it doesn't fit my need so I am writing my own library. I am using TSL276711FN. /media/uploads/jspatel/tsl2671_datasheet_en_v1.pdf
Here are the list of registers.
const char ENABLE_REG = 0x00; /// Enables states and interrupts const char PTIME_REG = 0x02; /// Proximity ADC time const char WTIME_REG = 0x03; /// Wait Time const char PILTL_REG = 0x08; /// Proximity interrupt low threshold low byte const char PITLH_REG = 0x09; /// Proximity interrupt low threshold high byte const char PIHTL_REG = 0x0A; /// Proximity interrupt high threshold low byte const char PIHTH_REG = 0x0B; /// Proximity interrupt high threshold high byte const char PERS_REG = 0x0C; /// Interrupt persistence filter const char CONFIG_REG = 0x0D; /// Configuration const char PPCOUNT_REG = 0x0E; /// Proximity pulse count const char CONTROL_REG = 0x0F; /// Control register const char ID_REG = 0x12; /// Device ID const char STATUS_REG = 0x13; /// Device status const char PDATAL_REG = 0x18; /// Proximity ADC low data register const char PDATAH_REG = 0x19; /// Proximity ADC high data register
I am able to read and write all registers. I can read Proximity ADC registers and get value from [0, 1023]. Higher number indicates closer proximity to sensor. When I set low threshold to 0 and high threshold to 600, I never get any interrupt. I flipped the values and still not getting any interrupts. So I set both values to 600. Now I do get interrupt because proximity ADC value is not going to 600, hence trigger an interrupt. I am not sure what value to set for interrupt threshold. I am wondering if you have any insight on this. I have also attached datasheet.
Values I am setting for registers, ENABLE =0x2f PTIME = 0xff WTIME = 0xff PILTx = 0x00 00 PIHTx = 0x02 58 = 600
Any help is appreciated.
Question relating to:
7 years, 3 months ago.
I can't see a problem with the approach you have taken. It seems like it should work. This is all I can think of:
1) If you're using the interrupt pin, note that it is active-low and requires a pull-up resistor because it is open-drain. ( For reference: http://en.wikipedia.org/wiki/Open_collector ) As a check, you could try using the PINT field of the STATUS register to detect interrupts.
2) Make sure you have PIHTL and PIHTH in the right order.
3) Check the value of the persistence register, although this shouldn't be an issue.
Here is a code example using interrupts with my driver which might help: