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.

CCS/ADS8699: ADS8699 SPI DMA example c code

Part Number: ADS8699

Tool/software: Code Composer Studio

Hi,

I try to get sampled values from the ADS8699 but it is not really clear how to reach this in c code. I saw code like this https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/421491 .

I also read the datasheet and the SPI section from MSP432® Peripheral Driver Library USERS GUIDE. There are a lot of details to understand...

It would be grateful if there is an example how to read a raw value from the ADC. In the end I want to get 8192 samples via DMA.

I hope there are some examples or you can give me some help.

my setup: ADS8699, msp432P401R, CCS Version: 8.2.0.00007

  • Hi there,

    Unfortunately, we don't have any example code for the ADS8699 with the MSP430P401R to share with you. However, I see that you've been asking similar questions on the MSP430 forum and it seemed like you had some working code at one point (e2e.ti.com/.../753655). Can you perhaps post a screen shot of your existing SPI control lines (SCLK, SDI, SDO and CONVST/CS)? Maybe we can see what the issue is that way. The code you pointed to above had an active high chip select, the ADS8699 would require an active low chip select as shown in Figure 3 of the datasheet.
  • Hi,

    thank you for writing. CS is low I recognised. I wired it as you can see in the code. At first i want to test directly with SPI, later with SPI with DMA because its more complicated.

    From the example I changed the clock and EUSCI_B0_MODUL to EUSCI_B0_BASE because ...MODUL i isn't declared a msp432 i would say.

    It looks like this:

    /* MSP432 = SPI master,                                          external device = SPI slave
     *
     *            MSP432P401                                                    ADS8699
     *          -----------------                                           -----------------
     *         |                 |                                         |                 |
     *         |            5V   |->                                     ->| DVDD            |
     *         |                 |                                         |                 |
     *         |            GND  |->                                     ->| DGND            |
     *         |                 |                                         |                 |
               |            P4.3 |-> _CS                                 ->| CST/CS          |
     *         |                 |                                         |                 |
     *         |            P1.6 |-> Data Out (UCB0SIMO)                 ->| SDI             |
     *         |                 |                                         |                 |
     *         |            P1.7 |<- Data In (UCB0SOMI)                  <-| SDO0            |
     *         |                 |                                         |                 |
     *         |            P1.5 |-> Serial Clock Out (UCB0CLK)          ->| SCLK            |
     **********************************************************************************************/
    
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    #include <ti/devices/msp432p4xx/driverlib/spi.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    static volatile uint8_t RXData[10];
    static volatile uint8_t i = 0;
    static uint8_t TXData = 0;
    static uint8_t ii = 0;
    
    
    /* SPI Master Configuration Parameter */
    const eUSCI_SPI_MasterConfig spiMasterConfig =
    {
            EUSCI_B_SPI_CLOCKSOURCE_SMCLK,              // SMCLK Clock Source
            3000000,                                    // SMCLK = DCO = 3MHz
            500000,                                     // SPICLK = 500kHz
            EUSCI_B_SPI_MSB_FIRST,                      // MSB First
            EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,    // Phase
            EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW,   // low polarity
            EUSCI_B_SPI_3PIN                            // 3Wire SPI Mode
    };
    
    
    int main(void)
    {
        volatile uint32_t ii;
    
        /* Halting WDT  */
        WDT_A_holdTimer();
    
        /* Starting and enabling LFXT (3MHz) */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);
        CS_setExternalClockSourceFrequency(3000000, 0);
        CS_initClockSignal(CS_SMCLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
        CS_startLFXT(CS_LFXT_DRIVE0);
    
    
        /* Selecting P1.0 as LED */
        GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    
    
        /* SPI --> P4.3 = _CS, P1.5 = CLK, P1.6 = MOSI & P1.7 = MISO */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
        GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
    
    
        /* Configuring SPI in 3-wire master mode & enabling it & interrupts */
        SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig);
        SPI_enableModule(EUSCI_B0_BASE);
        SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);
        Interrupt_enableInterrupt(INT_EUSCIB0);
        //Interrupt_enableSleepOnIsrExit();
        /* Delaying waiting for the module to initialize */
        for(ii=0;ii<100;ii++);
    
    
        /* SPI, put _CS low P4.3 and polling to see if the TX buffer is ready or busy */
        GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
    
    
    //    TXData = 0x40;
    //    while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
    //    SPI_transmitData(EUSCI_B0_BASE, TXData);
    //    TXData = 0x00;
    //    while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
    //    SPI_transmitData(EUSCI_B0_BASE, TXData);
    
    
        while(1) {}
        /*PCM_gotoLPM0();
        __no_operation();*/
    }
    
    
    void euscib0_isr(void)
    {
        int i = 0;
        uint32_t status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE);
        SPI_clearInterruptFlag(EUSCI_B0_BASE, status);
    
        if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT)
        {
            RXData[i++] = SPI_receiveData(EUSCI_B0_BASE);
            if ((i % 2) == 1) {
                 for( ii=0;ii<10;ii++);
                 GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
            }
            GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
            for(i=0;i<48000000;i++); // delay 1s
            GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
        }
    }
    

    The Software is always at while(1), the function euscib0_isr() isn't entered. I think that with _CS low the ADC starts working and send an interrupt.

    But how does this work "send an interrupt" to the msp432?

  • Hi,

    I was hoping you had screen shots to share with us. The ADS8699 uses its CONVST/CS pin as the mechanism to begin the conversion process. You would need to toggle that pin high, which starts the conversion and drives the RVS pin low. Once the RVS pin toggles back to a high state, you would need to send CONVST/CS low again start driving the SCLK pin to retrieve the conversion results from the ADC. Take a look at Figure 1 and Figure 3 on page 11, it's the RVS pin that basically acts as an interrupt to your processor.

  • Hi,

    in the c code you can see the new pin configuration. I extended it with the RVS signal.

    1. I want to use the max. SPI speed of 16MHz. I'm not really sure about the constant:

    /* SPI Master Configuration Parameter */
    const eUSCI_SPI_MasterConfig spiMasterConfig =
    {
            EUSCI_B_SPI_CLOCKSOURCE_SMCLK,              // SMCLK Clock Source
            3000000,                                    // clockSourceFrequency: SMCLK = DCO = 3MHz
            16000000,                                   // desiredSpiClock: SPICLK = 16MHz
            EUSCI_B_SPI_MSB_FIRST,
    
          // MSB First
            EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,    // Phase
            EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW,   // low polarity
            EUSCI_B_SPI_3PIN                            // 3Wire SPI Mode
    };

    Which/what clock ist the clockSourceFrequency? I only can choose SMCLK and ACLK.

    Furthermore, I can't recognise a clock at pin 1.5 with a oscilloscope while the  while loop (se below) is running. Because of this, I think there is something wrong with the clock setting.

    2. In reference to p.11 fig. 1 and 3 I made a simple test sequence:

        while(1) {
            // conversion start with rising edge on CONV:
            GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
            GPIO_setOutputHighOnPin(GPIO_PORT_P4, GPIO_PIN3);
            // Wait until conversion is done (RVS -> high):
            while (GPIO_getInputPinValue(GPIO_PORT_P4, GPIO_PIN6) == 0);
            // set CONV to low for reading buffer:
            GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
            int k;
            for (k = 0; k < 4; ++k) {
                RXData[k] = SPI_receiveData(EUSCI_B0_BASE);
            }
        }
    

    But everytime I read with SPI_receiveData 0x0000311C. The value never changes. What's wrong?

    Regards

  • ... sorry I forgot the pin configuration:

    /*
     * whole circuit like figure 67 and 98 in the datasheet
     * 
     * MSP432 = SPI master,                                          external device = SPI slave
     *
     *            MSP432P4111                                                   ADS8699
     *          -----------------                                           -----------------
     *         |                 |                                         |                 |
     *         |            5V   |->                                     ->| DVDD            |
     *         |                 |                                         |                 |
     *         |            GND  |->                                     ->| DGND            |
     *         |                 |                                         |                 |
               |            P4.3 |-> _CS                                 ->| CST/CS          |
     *         |                 |                                         |                 |
     *         |            P4.6 |<- Conv. ready                         <-| RVS             |
     *         |                 |                                         |                 |
     *         |            P1.6 |-> Data Out (UCB0SIMO)                 ->| SDI             |
     *         |                 |                                         |                 |
     *         |            P1.7 |<- Data In (UCB0SOMI)                  <-| SDO0            |
     *         |                 |                                         |                 |
     *         |            P1.5 |-> Serial Clock Out (UCB0CLK)          ->| SCLK            |
     */

  • Hi,

    Can you send the scope screen capture? Normally, the SPI master sends the clock, which means you have to initiate a transmit to get the SDO from the device.
  • Hi,

    the problem is, that I have no clock!

    /* SPI Master Configuration Parameter */
    const eUSCI_SPI_MasterConfig spiMasterConfig =
    {
            EUSCI_B_SPI_CLOCKSOURCE_SMCLK,              // SMCLK Clock Source
            48000000,                                    // SMCLK = DCO = 3MHz
            16000000,                                     // SPICLK = 500kHz
            EUSCI_B_SPI_MSB_FIRST,
          // MSB First
            EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,    // Phase
            EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW,   // low polarity
            EUSCI_B_SPI_3PIN                            // 3Wire SPI Mode
    };
    
    int main(void)
    {
        /* Halting WDT  */
        WDT_A_holdTimer();
    
        /* Starting and enabling HFXT */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    
        CS_setExternalClockSourceFrequency(32000, 48000000);
    
        /* Starting HFXT in non-bypass mode without a timeout. Before we start
         * we have to change VCORE to 1 to support the 48MHz frequency */
        MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
        MAP_FlashCtl_A_setWaitState(FLASH_A_BANK0, 3);
        MAP_FlashCtl_A_setWaitState(FLASH_A_BANK1, 3);
        CS_startHFXT(false);
    
        /* Starting HFXT in non-bypass mode without a timeout. Before we start
         * we have to change VCORE to 1 to support the 48MHz frequency */
        MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
        MAP_FlashCtl_A_setWaitState(FLASH_A_BANK0, 3);
        MAP_FlashCtl_A_setWaitState(FLASH_A_BANK1, 3);
        CS_startHFXT(false);
    
        //![Simple SPI Example]
        /* Selecting P1.5 P1.6 and P1.7 in SPI mode */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);

    I need a SPI clock of 16MHz. I tried to create it from the 48MHz HFXT and SMCLK. Can you see the problem?

  • You have to initiate a data transfer by 'writing' to the SPI port - what that means is that the master device (your MSP432P4111) has to move data (usually just zeros) to the transmit buffer. Otherwise, you won't get a clock.
  • Hi,
    if I send "SPI_transmitData(EUSCI_B0_BASE, 0x00);" then the clock is started?
    I thought when I create a rising edge on CONV P4.3 the conversion starts. After the RVS reaches high level the conversion is finished.
  • When using the internal clock for conversion, yes - pulsing CONV takes care of the actual conversion process. You still need to generate the SCLK from your host controller to read the conversion results.
  • after sending "SPI_transmitData(EUSCI_B0_BASE, 0x00);"
    the following gpio read or write commands always end in the Default Handler...?
  • Not sure what you mean, but you have to send over enough bytes to read the full conversion results from the device, you should get conversion data into the receive buffer which you would then concatenate for the full conversion results.
  • I mean that after I sent 0x00 to ADS8699 I have to set CONV to high becaus ADS8699 needs this high level to start conversion. And at this moment when I set the GPIO PIN P4.3 from low to high, the debugger from CCS arrived in the Default Handler.

    Regards

  • So, you are getting SCLKS to the ADS8699? Once you've read out all the data, you can reset the CONV high again to start the next conversion.
  • At P1.5 I can't recognise a clock.

    I would be glad if I had an code example for the ADS8699 and the MSP432P4111 to read the digital value.

    Regards

  • I'm sorry, but we don't have an example for you to go by. Do you have any means to show scope traces to the ADC?
  • Unfortunately, at this moment I have no means to show scope traces. If I understand it rigth, I need the clock from msp432 to ADC only for the read and write, the ADC runs by internal clock. If I send high at CONV the conversion starts, with the next high at RVS I can read the SPI buffer.
  • Yes - that's right. If you have no way to monitor the signals between the ADC and your microcontroller, it's going to be difficult to progress forward. Even if I had known working code to send you, that would be hardware dependent and you would still need an O'Scope or logic analyzer to verify that everything is working properly. Let us know when you have the ability to monitor the SPI bus and we'll pick it back up from there. In the meantime, I wish you a very happy holiday season!
  • Hi, hope you all have a beautiful christmas time.

    Now I have a O'Scope to monitor the signals. Furthermore I have written new example code with different clock sources to find a working one:

    1. external clock 48MHz: maybe my target SPI clock of 16MHz is not possible because of the fixed dividers -> 12MHz with divider 4

    2. internal clock: set to 32MHz that I reach the 16MHz with divider 2

    3. intenal clock slow: as I have seen in the USERS GUIDE example

    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    #include <ti/devices/msp432p4xx/driverlib/spi.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/gpio/GPIOMSP432.h>
    
    static volatile uint8_t RXData[10];
    static volatile uint8_t i = 0;
    static uint8_t TXData = 0;
    static uint8_t ii = 0;
    
    /* SPI Master Configuration Parameter */
    const eUSCI_SPI_MasterConfig spiMasterConfig =
    {
        // ========== external clock ==================
    //        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,              // SMCLK Clock Source
    //        24000000,                                   // SMCLK
    //        12000000,                                   // SPICLK
    //        EUSCI_B_SPI_MSB_FIRST,
        // ========== internal clock ===================
    //        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,              // SMCLK Clock Source
    //        32000000,                                   // SMCLK
    //        16000000,                                   // SPICLK
    //        EUSCI_B_SPI_MSB_FIRST,
        // ========== internal clock example slow ======
           EUSCI_B_SPI_CLOCKSOURCE_SMCLK,              // SMCLK Clock Source
           3000000,                                    // SMCLK
           500000,                                     // SPICLK
           EUSCI_B_SPI_MSB_FIRST,
        // =============================================
    
          // MSB First
            EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,    // Phase
            EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW,   // low polarity
            EUSCI_B_SPI_3PIN                            // 3Wire SPI Mode
    };
    
    
    int main(void)
    {
        volatile uint32_t ii;
    
        /* Halting WDT  */
        WDT_A_holdTimer();
    
        MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);    // Achtung zwingend vor clock set, sonst factory reset nötig
        MAP_FlashCtl_A_setWaitState(FLASH_A_BANK0, 3);
        MAP_FlashCtl_A_setWaitState(FLASH_A_BANK1, 3);
    
    /* ========== external clock ==================================================================== */
    
        /* Starting and enabling HFXT */
    //    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    
    //    CS_setExternalClockSourceFrequency(32000, 48000000);
    //
    //    /* -------------------------------------------     Pos.1 for initClockSignal     ---------- */
    //    MAP_CS_initClockSignal(CS_MCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); //48MHz
    //    MAP_CS_initClockSignal(CS_SMCLK,CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_4); //12MHz
    //    /* ---------------------------------------------------------------------------------------- */
    //
    //    /* Starting HFXT in non-bypass mode without a timeout. Before we start
    //     * we have to change VCORE to 1 to support the 48MHz frequency */
    
    //    CS_startHFXT(false);
    
    //    /* -------------------------------------------     Pos.2 for initClockSignal     ----------- */
    //	  /* ----------------------------------------------------------------------------------------- */
    
    /* ========== internal clock ===================================================================== */
    //    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_3); //48MHz
    //    CS_setDCOFrequency(32000000);
    //    CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2);
    
    /* ========== internal clock example slow ======================================================== */
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_3); //48MHz
        CS_setDCOFrequency(3000000);
        CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    //  ==============================================================================================
    
        //![Simple SPI Example]
        /* Selecting P1.5 P1.6 and P1.7 in SPI mode */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
    
        GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);   // P1.0 LED
        GPIO_setAsInputPin(GPIO_PORT_P4, GPIO_PIN6);    // P4.6 RVS
        GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN3);   // P4.3 CONV
    
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);// P1.0 LED
        GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3); // P4.3 CONV
    
        /* Configuring SPI in 3-wire master mode & enabling it & interrupts */
        bool statusFlag = false;
        statusFlag = SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig);
        SPI_enableModule(EUSCI_B0_BASE);
        SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);
        Interrupt_enableInterrupt(INT_EUSCIB0);
        //Interrupt_enableSleepOnIsrExit();
        /* Delaying waiting for the module to initialize */
        for(ii=0;ii<100;ii++);
    
        /* SPI, put _CS low P4.3 and polling to see if the TX buffer is ready or busy */
        GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
    
        SPI_transmitData(EUSCI_B0_BASE, 0xFF);
    
        while(1) {
    		
    		/* -------------------------------------------  SMCLK auslesen und mit printf ausgeben? ---------------------------------------- */
    //		int clock = CS_getSMCLK();
    		/* ----------------------------------------------------------------------------------------------------------------------------- */
    		
            GPIO_getInputPinValue(GPIO_PORT_P4, GPIO_PIN6); // RVS should be high
            // conversion starts with rising edge on CONV:
            GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
            GPIO_setOutputHighOnPin(GPIO_PORT_P4, GPIO_PIN3);
    
            //printf("Wait until conversion is done (RVS -> high)");
            while (GPIO_getInputPinValue(GPIO_PORT_P4, GPIO_PIN6) == 0); // RVS
            // set CONV to low for reading buffer:
            GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
            int k;
            for (k = 0; k < 4; ++k) {
                RXData[k] = SPI_receiveData(EUSCI_B0_BASE);
            }
            __no_operation();
        }
        /*PCM_gotoLPM0();
        __no_operation();*/
    }
    
    
    //void euscib0_isr(void)
    //{
    //    int i = 0;
    //    uint32_t status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE);
    //    SPI_clearInterruptFlag(EUSCI_B0_BASE, status);
    //
    //    if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT)
    //    {
    //        RXData[i++] = SPI_receiveData(EUSCI_B0_BASE);
    //        if ((i % 2) == 1) {
    //             for( ii=0;ii<10;ii++);
    //             GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);
    //        }
    //        GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //        for(i=0;i<48000000;i++); // delay 1s
    //        GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //    }
    //}
    

    My first issue when i debug is, that I always end in the default handler when I enter the line "GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);" after the for loop.

    /* This is the code that gets called when the processor receives an unexpected  */
    /* interrupt.  This simply enters an infinite loop, preserving the system state */
    /* for examination by a debugger.                                               */
    void Default_Handler(void)
    {
        /* Fault trap exempt from ULP advisor */
        #pragma diag_push
        #pragma CHECK_ULP("-2.1")
    
    	/* Enter an infinite loop. */
    	while(1)
    	{
    	}
    
    	#pragma diag_pop
    }

    If I do "step into F5" steps I don't end in the handler, but with "step over F6" steps I'm ending in the default handler.

    I cannot find the explanation for this.

  •  If I run the evalution board with the "internal clock slow (500kHz)" variante and without the debugger, then I can trigger the clock after pushing the reset button once.

    1ch=clk

    2.ch=CONV

    3.ch=RVS

    4.ch=SOMI

    Maybe the clock is from the "SPI_transmitData(EUSCI_B0_BASE, 0xFF);" transfer. But no CONV or RVS high level.

    With SIMO and SOMI:

  • Hi, and Happy New Year to you!

    I see that you write SPI_transmitData(EUSCI_B0_BASE, 0xFF); just ahead of your 'while(1)' loop. That SPI_transmitData caused the SCLK to run and send the 0xFF seen in the green trace from SIMO, the ADS8699 responded with the 0x1D from SOMI and most likely cause the RX interrupt to fire off before entering the while(1) loop.

    In your euscib0_isr loop, you seem to be waiting for data to be received, but there is no means of clock generation that I see there. If you expect to read 4 bytes, you have to generate 32 SCLKs be putting data (0x00 for example) into the transmit buffer.
  • Hi, Happy New Year to you!

    The void euscib0_isr(void) is currently disabled, but I have enabled the interrupt, maybe I should disabled the interrupt too.

    Do you mean that I have to send

    SPI_transmitData(EUSCI_B0_BASE, 0xFFFFFFFF); or SPI_transmitData(EUSCI_B0_BASE, 0x00000000);

    to read 4bytes before RXData[k] = SPI_receiveData(EUSCI_B0_BASE); ?

  • Hi,

    now I think I can read adc values.
    The problem with the default handler was, that I had enabled the interrupt but the ISR function was disabled.

    To verify the digital adc values, I should know what the setup of the "ADC input range" is.
    If I read the 32bit at output register, the bit 0 to 13 are always 0.This is maybe because the "RANGE_INCL" flag isn't set to 1.
    How can I set this flag to 1 to read out the "ADC input range"?
  • Hello user5841294,

    After power up the ADC, all bits in DATAOUT_CTL_REG register are zero, the 32-bit output data on SDO-x will only include 18-bit conversion result and the rest bits will be all zeros, so you got right information on SDO-x. The default range is 0000b which means +/-3VREF input range(+/-12.288V), please refer to the information about DATAOUT_CTL_REG register in Table 15 of datasheet.

    To set "Range_INCL" bit in DATAOUT_CTL_REG register, you can use one of below commands:

    WRITE command:

    11010_01_<0_0001_0000><00000001_00000000>  or

    11010_00_<0_0001_0000><00000001_00000000> 

    or SET_HWORD command:

    11011_00_<0_0001_0000><00000001_00000000> 

    Remark for format:    Command_<Reg address><Data> 

    Please refer to the command detail in Table 5 and the register detail in Table 15 of ADS8699 datasheet.

    Please let us know if you have any further question.

    Thanks&Regards

    Dale

  • Hello Dale,

    that's great. For a start, I could set the DATAOUT_CTL_REG value same as Table 6. in datasheets with:

    #define WRITE                  0xD000
    #define DATAOUT_CTL_REG  0x10

        ADC_Command = WRITE + DATAOUT_CTL_REG;
        SPI1_ADC_TxBuffer[0] = (uint8_t)(ADC_Command >> 8);
        SPI1_ADC_TxBuffer[1] = (uint8_t)ADC_Command;
        SPI1_ADC_TxBuffer[2] = 0x55;
        SPI1_ADC_TxBuffer[3] = 0x08;
    
        SPI_transmitData(EUSCI_B0_BASE, SPI1_ADC_TxBuffer[0]);
        SPI_transmitData(EUSCI_B0_BASE, SPI1_ADC_TxBuffer[1]);
        SPI_transmitData(EUSCI_B0_BASE, SPI1_ADC_TxBuffer[2]);
        SPI_transmitData(EUSCI_B0_BASE, SPI1_ADC_TxBuffer[3]);
    
        __delay_cycles(4800000);

    And it looks good.

    But:
    1. the 18bit value that I read out doesn't match with the range (0011=1.25*vref):

    Some printf from my 32bit read out (second number is the current 18bit adc value):

    Mean=158096 158096 10011010011001000000000000001100
    Mean=158100 158105 10011010011001100100000000001100
    Mean=158100 158100 10011010011001010000000000000000
    Mean=158101 158103 10011010011001011100000000000000
    Mean=158101 158102 10011010011001011000000000001100
    Mean=158104 158108 10011010011001110000000000001100
    Mean=158106 158109 10011010011001110100000000000000
    Mean=158106 158106 10011010011001101000000000001100
    Mean=158108 158110 10011010011001111000000000000000
    Mean=158106 158105 10011010011001100100000000001100
    Mean=158104 158102 10011010011001011000000000001100
    Mean=158104 158104 10011010011001100000000000000000
    Mean=158104 158104 10011010011001100000000000000000
    Mean=158102 158101 10011010011001010100000000001100
    Mean=158106 158111 10011010011001111100000000001100
    Mean=158108 158111 10011010011001111100000000001100
    Mean=158105 158103 10011010011001011100000000000000
    Mean=158105 158105 10011010011001100100000000001100
    Mean=158104 158104 10011010011001100000000000000000
    Mean=158104 158105 10011010011001100100000000001100
    Mean=158103 158103 10011010011001011100000000000000
    Mean=158105 158108 10011010011001110000000000001100
    Mean=158106 158108 10011010011001110000000000001100
    Mean=158103 158101 10011010011001010100000000001100
    Mean=158103 158103 10011010011001011100000000000000
    Mean=158104 158106 10011010011001101000000000001100
    Mean=158103 158102 10011010011001011000000000001100
    Mean=158105 158107 10011010011001101100000000000000
    Mean=158105 158105 10011010011001100100000000001100
    Mean=158106 158107 10011010011001101100000000000000
    Mean=158107 158108 10011010011001110000000000001100
    Mean=158100 158094 10011010011000111000000000001100

    My measurements and calculation:

    AVDD 5,063 V
    Ain 2,555 V
    ADC value 158105 digit
    ADC value 60,3 % of range
    Voltage_calc 4,236 V

    But with the setup 1.25*vref=5.12V I should have Voltage_calc=3.088V at 185105 digits !?


    2. sometimes I read range = 0000b ?