Jump to content
43oh

nesslersreagent

Members
  • Content Count

    9
  • Joined

  • Last visited

Reputation Activity

  1. Like
    nesslersreagent reacted to Lyon in TivaC sample ADC code problem   
    Hi,
    Two problems with your code:
    1) First, you should have a GPIO peripheral enabled and a specific pin configured as analog input pin. 
    2) In this function call
        ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
    the pin selected for conversion is still the internal temperature sensor (ADC_CTL_TS) - replace it with your analog pin declared above. Also, you don't need to declare ADC_CTL_IE if you do not use ADC interrupts.
     
    L
  2. Like
    nesslersreagent reacted to Bernard in LM4F120 PWM   
    Hi,
     
    I have found an excellent tutorial about PWM on Stellarpad that help me to understand .
     
    Here is the Energia version :
    /* PWM * TIMER0 B * PF_1 RED_LED */ #include "inc/hw_memmap.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" #include "driverlib/timer.h" unsigned long ulPeriod, dutyCycle; void setup() { ulPeriod = 2000; dutyCycle = 500; // PF_1 on T0CCP1 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinConfigure(GPIO_PF1_T0CCP1); GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_1); // Timer configuration SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE,TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_PWM); TimerLoadSet(TIMER0_BASE, TIMER_B, ulPeriod -1); TimerMatchSet(TIMER0_BASE, TIMER_B, dutyCycle); TimerEnable(TIMER0_BASE, TIMER_; } void loop() { TimerMatchSet(TIMER0_BASE, TIMER_B, dutyCycle++); if(dutyCycle >= ulPeriod - 1) dutyCycle = 0; delay(1); } // End of .ino file I wanted to share .. it could be usefull for beginers like me.
     
    Salutations
     
    Bernard
     
     
     
×
×
  • Create New...