Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

LM3S9B96 timers

$
0
0

It seems like my timer is running at a slower frequency then what I would expect. I stripped down my program to the following to test it out.

void TimerZero()
{
    HWREG(TIMER0_BASE + TIMER_O_TAV) = 0;
}

int
main(void)
{
   
    // Set the clocking to run at 80 MHz from the PLL.
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
       
    // Initialize the device pinout appropriately for this board.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    
    // Set up TIMER 0 for loop timing
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER_UP);
    TimerEnable(TIMER0_BASE, TIMER_A);
    TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet());
    TimerControlStall(TIMER0_BASE, TIMER_A, true);
    while(1)
    {
        // Grab the loop time
        delta_t = (double)TimerValueGet(TIMER0_BASE, TIMER_A) / (double)SysCtlClockGet();
        // Add up the deltas
        sum_delta_t += delta_t;
        // Reset the timer
        //TimerLoadSet(TIMER0_BASE, TIMER_A, 0);
        TimerZero();
            
        if(sum_delta_t < 1.00) continue;
    
        UART0Send("Hello World!\n", 13);
        
        sum_delta_t = 0.0;
    
    }

This prints every 10 seconds rather than every 1 like I would expect. What am I missing here?


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>