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.

TM4C1231H6PGE: Internal ADC stopped responding after the Wide Timer configured to generate a PWM

Part Number: TM4C1231H6PGE
Other Parts Discussed in Thread: TM4C123GH6PGE

HI ,

Internal ADC had stopped working ,upon configuring the Wide Timer in order to generate a PWM signal.

WT1CCP1 pin 109 is used for PWM generation.

Does Wide Timer configuration leads to disruption in the functioning of the Internal ADC.

Best Regards,

Rohith .

  • Hi,

      Do you mean TM4C123GH6PGE instead of TM4C1231H6PGE? As a matter of fact, there is no TM4C1231H6PGE part number. 

      With that said, there is no reason for the timer configuration to interfere with the ADC. What do you mean by disruption to the ADC? Is the ADC not running at all or the ADC is not producing the same result as if the Timer is not used?  I will suggest you check your software again and see if you might have done something to disable the ADC by mistake if the ADC is just simply stopped. 

  • Hi Charles,

    Thanks for the response .

    Tiva™TM4C1231H6PGE Microcontroller is the one that is being used.

    ADC is not running at all.

    Below is the code snipet of both the ADC initialization as well as the pwm generation , to give more info ADC is first initialized in the code sequence and them comes the PWM generation which is a one time process.

    Hope this would help in giving me some direction.

    //************************************************************************************
    
    void halogen_init_adc(void)
    {
    	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    	ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);
    	ROM_SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);
    	ROM_ADCHardwareOversampleConfigure(ADC0_BASE, HW_OVERSAMPLE_FACTOR);
    	ROM_ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);
    
    	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
    	ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_ADC1);
    	ROM_SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);
    	ROM_ADCHardwareOversampleConfigure(ADC1_BASE, HW_OVERSAMPLE_FACTOR);
    	ROM_ADCReferenceSet(ADC1_BASE, ADC_REF_EXT_3V);
    
    	ROM_ADCSequenceDisable(ADC0_BASE, ADC_0_SEQUENCER);
    	ROM_ADCSequenceConfigure(ADC0_BASE, ADC_0_SEQUENCER, ADC_TRIGGER_PROCESSOR, 0);
    
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 0, (get_voltage(HALOGEN_USB1_PD_CUR_SENSE)));
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 1, (get_voltage(HALOGEN_MCU_VMON_0_6_DDR4_VTT)));
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 2, (get_voltage(HALOGEN_USB2_PD_CUR_SENSE)));
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 3, (get_voltage(HALOGEN_MCU_VMON_2_5V)));
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 4, (get_voltage(HALOGEN_MCU_VMON_1_05V)));
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 5, (get_voltage(HALOGEN_MCU_VMON_1_08V)));
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 6, (get_voltage(HALOGEN_MCU_VMON_1_2V)));
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, ADC_0_SEQUENCER, 7, (get_voltage(HALOGEN_MCU_VMON_1_5V) | ADC_CTL_IE | ADC_CTL_END));
    	ROM_ADCSequenceEnable(ADC0_BASE, ADC_0_SEQUENCER);
    	/* Clear the ADC interrupt flag. */
    	ROM_ADCIntClear(ADC0_BASE, ADC_0_SEQUENCER);
    	ROM_ADCIntEnable(ADC0_BASE, ADC_0_SEQUENCER);
    
    	/*ADC1*/
    	ROM_ADCSequenceDisable(ADC1_BASE, ADC_1_SEQUENCER);
    	ROM_ADCSequenceConfigure(ADC1_BASE, ADC_1_SEQUENCER, ADC_TRIGGER_PROCESSOR, 0);
    
    	ROM_ADCSequenceStepConfigure(ADC1_BASE, ADC_1_SEQUENCER, 0, (get_voltage(HALOGEN_MCU_VMON_1_8V)));
    	ROM_ADCSequenceStepConfigure(ADC1_BASE, ADC_1_SEQUENCER, 1, (get_voltage(HALOGEN_MCU_VMON_P3_3V_MCU)));
    	ROM_ADCSequenceStepConfigure(ADC1_BASE, ADC_1_SEQUENCER, 2, (ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END));
    	ROM_ADCSequenceEnable(ADC1_BASE, ADC_1_SEQUENCER);
    	/* Clear the ADC interrupt flag. */
    	ROM_ADCIntClear(ADC1_BASE, ADC_1_SEQUENCER);
    	ROM_ADCIntEnable(ADC1_BASE, ADC_1_SEQUENCER);
    
    	return;
    }
    
    
    
    
    
    
    //**********************************************************************
    
    #include <stdbool.h>
    #include <stdint.h>
    #include "stellaris/inc/hw_gpio.h"
    #include "stellaris/inc/hw_ints.h"
    #include "stellaris/inc/hw_memmap.h"
    #include "stellaris/inc/hw_timer.h"
    #include "stellaris/inc/hw_types.h"
    #include "stellaris/driverlib/gpio.h"
    #include "stellaris/driverlib/interrupt.h"
    #include "stellaris/driverlib/pin_map.h"
    #include "stellaris/driverlib/sysctl.h"
    #include "stellaris/driverlib/timer.h"
    #include "stellaris/driverlib/uart.h"
    #include "stellaris/utils/uartstdio.h"
    #include "stellaris/driverlib/rom_map.h"
    
    //*****************************************************************************
    //*************************************************************************
    
    //*****************************************************************************
    //
    // The g_ui32SysClock contains the system clock frequency
    //
    //*****************************************************************************
    #if defined(TARGET_IS_TM4C129_RA0) ||                                         \
        defined(TARGET_IS_TM4C129_RA1) ||                                         \
        defined(TARGET_IS_TM4C129_RA2)
        uint32_t g_ui32SysClock;
    #endif
    
    
    
    int pwm_pin_109(void)
    {
      
        SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_25MHZ);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER1);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
       
        MAP_GPIOPadConfigSet(GPIO_PORTK_BASE, GPIO_PIN_7, GPIO_STRENGTH_8MA,GPIO_PIN_TYPE_STD);
    
        GPIOPinConfigure(GPIO_PK7_WT1CCP1);
    
        GPIOPinTypeTimer(GPIO_PORTK_BASE, GPIO_PIN_7);
       
        TimerConfigure(WTIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PWM);
    
        TimerLoadSet(WTIMER1_BASE, TIMER_B, 2500000);
       
        TimerMatchSet(WTIMER1_BASE, TIMER_B,
                     TimerLoadGet(WTIMER1_BASE, TIMER_B) /100);
    
        TimerEnable(WTIMER1_BASE, TIMER_B);
    
    }
    
    

  • Hi,

      That is weird to me. Glancing through the code I don't really spot an issue with your code. Let me ask some questions here.

      - If you only call  halogen_init_adc() without calling pwm_pin_109() then the ADC is working. Is this correct?

       - What happens if you only call pwm_pin_109() without calling halogen_init_adc()? Does the PWM work on pin 109?

       - When you call both the pwm_pin_109() and halogen_init_adc(), you said the ADC stops working. What about the PWM on pin 109? Does it continue to work?

       - Is this only a problem when you use PWM on pin 109? For experimental purpose, can you try other PWM pins? Will it make a difference?

  • Hi Charles,

    Please find my response online.

    - If you only call  halogen_init_adc() without calling pwm_pin_109() then the ADC is working. Is this correct?

    --> Yes without calling pwm_pin_109() , and calling only halogen_init_adc() then the ADC is working .

      - What happens if you only call pwm_pin_109() without calling halogen_init_adc()? Does the PWM work on pin 109?

    --> This i haven't tried..this part of the code for PWM is for the latest hardware design requirement so has been added in the latest revision of software.Trying this on the hardware might hinder something on the board if it doesn't work out .

      - When you call both the pwm_pin_109() and halogen_init_adc(), you said the ADC stops working. What about the PWM on pin 109? Does it continue to work?

    --> Yes , the PWM still continues to work .

      - Is this only a problem when you use PWM on pin 109? For experimental purpose, can you try other PWM pins? Will it make a difference?

    --> As I mentioned this is based on the hardware requirement that driving the pulse is the critical addition which is mandatory on the pin 109 .There are No GPIOs available that I could validate it on the other pin and would become difficult to recover the unit since MCU is the one that would be driving the critical power and CPU rails.

    Thanks and Regards,

    Rohith.

  • Hi Rohith,

      Thanks for the answers to my questions. I still can't make sense why the Timer will interfere with the ADC. I will need you to do some debugging. This is what I will suggest you do. 

      - Without calling the pwm_pin_109(), examine the ADC registers in the register browser window.

      - In a separate run, call the pwm_pin_109() ad re-examine the ADC registers. Do you see any differences compared to the ADC without calling the pwm_pin_109()? What I particularly wanted to know why the ADC is suddenly stopped as you reported. The ADC registers settings should provide some clue. 

      - You configure the ADC for ADC_TRIGGER_PROCESSOR. This mean you need to provide a trigger to start the conversion in your application using ADCProcessorTrigger(). I don't have your code so I don't know how you are creating the trigger. Please make sure you provide trigger to the ADC. 

      - You enable ADC interrupt. So you want to look at the ADCRIS (ADC Raw Interrupt Status) register to see if flags are set or not.