5 years, 8 months ago.

MAX30001 with Nordic NRF52DK

Hi,

I used MAX30001 library from EV kit Hello world. I used EV kit and connected it to Nordic nrf52dk I used the code below

max30001

#include "mbed.h"
#include "MAX30001.h"



#define EN_ECG     0b1
#define OPENP      0b1
#define OPENN      0b1
#define POL        0b0
#define CALP_SEL   0b10
#define CALN_SEL   0b11
#define E_FIT      31
#define RATE       0b00
#define GAIN       0b00
#define DHPF       0b0
#define DLPF       0b01
 
/// Initialization values for CAL_InitStart() 
#define EN_VCAL  0b1
#define VMODE    0b1
#define VMAG     0b1
#define FCAL     0b011
#define THIGH    0x7FF
#define FIFTY    0b0

/// Initializaton values for Rbias_FMSTR_Init()
#define EN_RBIAS 0b01 
#define RBIASV   0b10
#define RBIASP   0b1
#define RBIASN   0b1
#define FMSTR    0b00
#define BUFFER_LENGTH 50
  
  // @brief SPI Master 0 with SPI0_SS for use with MAX30001
 /// DigitalOut for CS
DigitalOut cs(D10);
/// SPI Master 2 with SPI0_SS for use with MAX30001
SPI spi(SPI_PSELMOSI0, SPI_PSELMISO0, SPI_PSELSCK0); // used by MAX30001
  
    
  //@brief ECG device
 MAX30001 max30001(&spi, &cs);
InterruptIn max30001_InterruptB(D8);
InterruptIn max30001_Interrupt2B(D9);
  
  Serial pc(USBTX, USBRX); // tx, rx
    
  //@brief Creating a buffer to hold the data
  uint32_t ecgBuffer[BUFFER_LENGTH];
  int ecgIndex = 0;
  char data_trigger = 0;
 
  
  //
  // @brief Creates a packet that will be streamed via USB Serial
  //       the packet created will be inserted into a fifo to be streamed at a later time
  // @param id Streaming ID
  // @param buffer Pointer to a uint32 array that contains the data to include in the packet
  // @param number Number of elements in the buffer
  //
  void StreamPacketUint32_ecg(uint32_t id, uint32_t *buffer, uint32_t number) {
    int i;
    if (id == MAX30001_DATA_ECG) {
      for (i = 0; i < number; i++) {
        ecgBuffer[ecgIndex] = buffer[i];
        ecgIndex++;
        if (ecgIndex > BUFFER_LENGTH)
          {
          data_trigger = 1;
          ecgIndex = 0;
          }
      }
    }
    if (id == MAX30001_DATA_BIOZ) {
          /// Add code for reading BIOZ data
    }
    if (id == MAX30001_DATA_PACE) {
          ///  Add code for reading Pace data
    }
    if (id == MAX30001_DATA_RTOR) {
          /// Add code for reading RtoR data
    }
  }
 
  
  int main() {
  
    uint32_t all;
  printf("Init MAX30001 callbacks, interrupts...\n");
  fflush(stdout);
  max30001_InterruptB.disable_irq();
  max30001_Interrupt2B.disable_irq();
  max30001_InterruptB.mode(PullUp);
  max30001_InterruptB.fall(&MAX30001Mid_IntB_Handler);
  max30001_Interrupt2B.mode(PullUp);
  max30001_Interrupt2B.fall(&MAX30001Mid_Int2B_Handler);
  max30001_InterruptB.enable_irq();
  max30001_Interrupt2B.enable_irq();
  MAX30001_AllowInterrupts(1);
  max30001.max30001_sw_rst(); // Do a software reset of the MAX30001
  max30001.max30001_INT_assignment(MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_enint_loc,      en_eovf_loc,   en_fstint_loc,
                                     MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_dcloffint_loc,  en_bint_loc,   en_bovf_loc,
                                     MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_bover_loc,      en_bundr_loc,  en_bcgmon_loc,
                                     MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_pint_loc,       en_povf_loc,   en_pedge_loc,
                                     MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,  //  en_lonint_loc,     en_rrint_loc,  en_samp_loc,
                                     MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR);       
  
  
    
                             
  
    max30001.onDataAvailable(&StreamPacketUint32_ecg);
  
    /// Set and Start the VCAL input
    /// @brief NOTE VCAL must be set first if VCAL is to be used 
      max30001.max30001_CAL_InitStart(EN_VCAL , VMODE, VMAG, FCAL, THIGH, FIFTY);
            
    /// ECG Initialization
     max30001.max30001_ECG_InitStart(EN_ECG, OPENP, OPENN, POL, CALP_SEL, CALN_SEL, E_FIT, RATE, GAIN, DHPF, DLPF);
  
    /// @details The user can call any of the InitStart functions for Pace, BIOZ, and RtoR
  
  
    /// @brief Set Rbias & FMSTR over here
       max30001.max30001_Rbias_FMSTR_Init(EN_RBIAS, RBIASV, RBIASP, RBIASN,FMSTR);
  
       max30001.max30001_synch();
  
    /// clear the status register for a clean start
    max30001.max30001_reg_read(MAX30001::STATUS, &all);  
    
    printf("Please wait for data to start streaming\n");
    fflush(stdout);
      
    while (1) {
      if(data_trigger == 1){
      printf("%ld ", ecgBuffer[ecgIndex]);  // Print the ECG data on a serial port terminal software
      fflush(stdout);
      }
    }

When I open serial monitor ,I see only "Please wait for data to start streaming."

What is the problem?

Question relating to:

For all future developments from Maxim Integrated, please refer to the following group: https://os.mbed.com/teams/MaximIntegrated/
Be the first to answer this question.