Post Go back to editing

How can we Differentiate between Dout/RDY pin. ? (Part number : ad7124-4) How can we handle interrupt. on Dout/RDY pin?

Category: Hardware
Product Number: ad7124-4

Part number : AD7124-4

I'm testing a code using Nucleo-L476RG and an analog-to-digital converter. This ADC uses SPI communication and shares its RDY (end of conversion) and DOUT functions on the same pin, that is, after reading the converted data on the pin, it becomes an RDY pin and can drive an external interrupt on the microcontroller.

My question is: how can I enable the External Interrupt event on a pin already configurated as MISO of SPI 

Since both the functionality relays on 1 common pin,  

If you have an, example code on Interrupt it will be useful for us to move further 



moved,updated form and tagged
[edited by: GenevaCooper at 2:51 PM (GMT -4) on 28 Aug 2023]
Parents
  • Here is the code I use on nucleo-G474re to read AD7124-4 (arduino IDE):

    uint32_t get_data(void)
    {
      static  uint8_t   rx[8]   = { 0};
      static  uint8_t   tx[8]   = { 0};
              uint32_t  resultat  =  0;
    
              uint8_t   head = 0;
              uint8_t   size_reg;
          
        // head |= address_spi;    
        head |= 0x02;   // data reg. = 2
        head |= 0x40;   // read
    
        if(debug_osm == 2) {
          Serial.print(F("\n\thead: "));
          Serial.print(head, BIN);
          }
    
        tx[0] = head;
    
        detachInterrupt( 29);
        
          SPI.transfer(CS_PIN1, tx, rx, 5, SPI_LAST); 
     
        HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
        delayMicroseconds(10);
        attachInterrupt( 29, data_contread, FALLING); // PD2
    
          resultat  |= rx[4];
          resultat  <<= 8;
          resultat  |= rx[1];
          resultat  <<= 8;
          resultat  |= rx[2];
          resultat  <<= 8;
          resultat  |= rx[3];
        
      return resultat;
    }
    

    There is no issue to switch interrupt of before SPI transaction takes place, you can use HAL driver for this.

Reply
  • Here is the code I use on nucleo-G474re to read AD7124-4 (arduino IDE):

    uint32_t get_data(void)
    {
      static  uint8_t   rx[8]   = { 0};
      static  uint8_t   tx[8]   = { 0};
              uint32_t  resultat  =  0;
    
              uint8_t   head = 0;
              uint8_t   size_reg;
          
        // head |= address_spi;    
        head |= 0x02;   // data reg. = 2
        head |= 0x40;   // read
    
        if(debug_osm == 2) {
          Serial.print(F("\n\thead: "));
          Serial.print(head, BIN);
          }
    
        tx[0] = head;
    
        detachInterrupt( 29);
        
          SPI.transfer(CS_PIN1, tx, rx, 5, SPI_LAST); 
     
        HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
        delayMicroseconds(10);
        attachInterrupt( 29, data_contread, FALLING); // PD2
    
          resultat  |= rx[4];
          resultat  <<= 8;
          resultat  |= rx[1];
          resultat  <<= 8;
          resultat  |= rx[2];
          resultat  <<= 8;
          resultat  |= rx[3];
        
      return resultat;
    }
    

    There is no issue to switch interrupt of before SPI transaction takes place, you can use HAL driver for this.

Children
No Data