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.

LDC1612: Autoscan and hardware interrupts not working unless a delay is used

Part Number: LDC1612

Hi there!

I have a problem with the LDC1612 that I would greatly appreciate some help understanding.

I am using an LDC1612 in continuous mode with hardware interrupts to inform my microcontroller of new conversions. I have two inductive coils and am using channel0 and channel1.  

The issue I am facing is that I cannot get "data ready" interrupts to trigger consistently unless I use a delay of 8 milliseconds. That is, for each interrupt I delay once, for 8 milliseconds, immediately after the interrupt, but just before data is read.  

My code flows like this:

1. Register ISR to trigger on falling edge of INTB on microcontroller

2. Set LDC registers (see code attachment)

3. Clear LDC by reading data channels and status register

4. Wait for interrupt

5. On interrupt, read from data channels 0&1 and status register

Steps 4 & 5 should repeat forever... but they don't. Instead, the ISR gets triggered once and INTB remains asserted.

Does anyone know why I cannot seem to get consistent interrupt behaviour without an arbitrary delay? What am I doing wrong here?

Thanks!

const uint16_t DRIVE_CURRENT = 0xFFC0;
const uint16_t REF_COUNT = 0x2500;
const uint16_t SETTLING_TIME = 0x0030;
const uint16_t CLOCK_DIVISION = 0x1001;
const uint16_t ERROR_CONFIG = 0x0001;
const uint16_t CONFIG = 0x1E01;
const uint16_t MUX_CONFIG = 0x820C;

  • Hello Kurt,

    Thank you for posting to the sensing forum! Thanks for the information, based on your code flow your implementation sounds like it should operate fine.

    Just a couple of questions:

    What is the clock frequency that you are providing to the CLKIN pin?

    Have you tried other delay values besides 8ms, or is 8ms the perfect number that allows the system to work?

    What frequency are the coils being used?

    What is the I2C frequency?

    When the ISR remains asserted have you tried reading the UNREADCONVx registers to see if they indicate you have any unread conversions?

    Best,

    Isaac

  • Hi Isaac, thanks for your reply!

    What is the clock frequency that you are providing to the CLKIN pin?

    The clock for the LDC is 40 MHz.

    Have you tried other delay values besides 8ms, or is 8ms the perfect number that allows the system to work?

    Yes, 8ms is the shortest delay I can use. Anything shorter than 8ms and my code will only get 1 interrupt. 

    What frequency are the coils being used?

    The coil sampling frequency is 146 Hz. 

    What is the I2C frequency?

    The LDC is connected to an I2C bus that runs at 400 KHz. 

    When the ISR remains asserted have you tried reading the UNREADCONVx registers to see if they indicate you have any unread conversions?

    Good suggestion. After a 1 minute period where INTB remained asserted (and my ISR didn't fire), the contents of the STATUS register were `0x000c`.  Since UNREADCONV0 and UNREADCONV1 are both set to 1 in this case, there is data for that should be read. Also, I notice that reading from STATUS de-asserts INTB, making one subsequent ISR-driven read of the LDC possible, before the loop times out again. (I attached a sample of my FreeRTOS code for better context).

    I wonder if I am not clearing the STATUS and MSBx registers correctly? Or if it is a timing issue of some kind...

    void captureLDCTask()
    {
    	for (;;)
    	{
    		ulNotificationValue = ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000));
    		WDT_Clear(); 
    
    		if (ulNotificationValue == 1)
    		{
    			//vTaskDelay(8); 
    			readFromDataChannels();
    		}
    		else
    		{
    			uint16_t s = getValueOfStatusRegister();
    
    		}
    	}
    }

  • Update: I resolved my issue. 

    As it turns out, the Microchip tool that I use to generate code was not generating "fall edge" GPIO code properly. I fixed this so that my interrupt triggers on falling edges properly now. 

    Moral of the story: be skeptical of your tools and double check exactly how your interrupts are configured/handled.  

  • Hey Kurt,

    Thanks for the update! Glad to hear you were able to track down the issue.

    Best,

    Isaac

  • No problem. Thanks for your time, Isaac!