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.

TM4C129XNCZAD: ADC raw interrupt does not triggered if using PIOSC for both system clock and ADC clock

Part Number: TM4C129XNCZAD


Hi,

I am having this issue of ADC raw interrupt does not trigger if using PIOSC for both system and ADC clock. below is the code I use to do the testing. If the SysCtlClockFreqSet() is commented, the ADC does not interrupt does not triggered. Just wondering what could be the work around?

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "sysctl.h"
#include "gpio.h"
#include "adc.h"

int main(void)
{

uint32_t pui32ADC0Value;

//SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MOSC| SYSCTL_USE_PLL |
// SYSCTL_CFG_VCO_480), 120000000);

SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

GPIODirModeSet(GPIO_PORTD_AHB_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(GPIO_PORTD_AHB_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_ANALOG);

ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH7 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);

ADCProcessorTrigger(ADC0_BASE, 3);
while(!ADCIntStatus(ADC0_BASE, 3, false));
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, &pui32ADC0Value);

while(1);

}

  • Hi,
    If you want to use PIOSC as the clock source for the system then did you try

    SysCtlClockFreqSet( SYSCTL_OSC_INT | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000 );
  • Hi Charlse,

    Thanks for the reply. What I meant is to feed in PIOSC directly to without passing through the PLL. If you look at my code, if the SysCtlClockFreqSet() is commented, the default configuration setup will be used after POR. In this case, PIOSC will be supplying clock to both ADC digital and analog block directly at 16 MHz. Somehow, under this settings, the interrupt for the ADC does not trigger.

    Regards
    Chee Chein
  • Hi,

    Can you try to wait for the peripheral ready after enabling the peripheral and see if it makes a difference? See below.

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0))
    {
    }

    Also for the ADC pin configuration please use below


    GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_4);
  • Chee Chein Wong said:
    this issue of ADC raw interrupt does not trigger if using PIOSC for both system and ADC clock.

    Would it not prove useful to (temporarily) apply the (hopefully present)  "External System Clock/Oscillator" - reconfigure for that - and then (once your raw ADC interrupt arrives) confirm that the issue  "CONCLUSIVELY OCCURS" - exactly as you state?

    As presented - that confirmation is absent - thus an entire "constellation of  issues" may  (alternatively) present.    (yielding far more time/effort demand - upon your helper crüe...)

  • Hi Charles,

    I does not work after trying the proposed method.

  • Hi, cb1_mobile,

    Base on my question, I am suspecting that the ADC digital block has to get the clock from the PLL in order for it to work properly. if PIOSC clock is used without the PLL, ADC seems to be not working as no interrupt is triggered. Could someone from TI confirm my doubt?
  • Chee Chein Wong said:
    Base on my question, I am suspecting that the ADC digital block has to get the clock from the PLL in order for it to work properly.

    Section 18.3.2.7 Module Clocking in the datasheet description of the ADC says:

    ■ 16 MHz PIOSC. Using the PIOSC provides a conversion rate near 1 Msps. To use the PIOSC to clock the ADC, first power up the PLL and then enable the PIOSC in the CS bit field in the ADCCC register, then disable the PLL.

    I.e. the PLL is necessary to initialise the ADC, but then should be able to be disabled.

  • Hi Chester,
    You are correct. Thanks for quoting the datasheet statement about using PIOSC.

    ADC clock needs to be configured like below.

    ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC |ADC_CLOCK_RATE_FULL, 1);
  • Hi Chester,

    Thanks for pointing out this statement in the datasheet that I have missed. I have tested with the the method and It work nicely. I have actually modified further to include the code to wait for the PLL to completely powered before setting the clock source and disable it. Below is the codes I have included.

    //Set PLLPWR to turn on the power to the PLL
    *((uint32_t *)(SYSCTL_PLLFREQ0)) |= (0x1 << 23);

    //To Wait until the PLL has powered and locked
    while(!(*(uint32_t *)(SYSCTL_PLLSTAT)));

    //Configure the clock source to use PIOSC
    *((uint32_t *)(ADC0 + ADC_O_CC)) = 0x1;

    //Clear PLLPWR to turn off the power to the PLL
    *((uint32_t *)(SYSCTL_PLLFREQ0)) &= ~(0x1 << 23);

    Anyway, thank you very much!

  • As it was poster Chester who, "Successfully RESOLVED" your issue - it is preferred that you AWARD HIM the, "This Resolved my Issue" GREEN Check-box.

    Your code indeed extends the functionality - yet (both) posts should be marked as, "This Resolved!"
  • Done as requested.