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.

create timer with 2-3 seconds of delay tm4c1294xl

Hi

i would like to create a 32 bit timer(or maybe i need less?) in my tm4c1294xl card

i would like to create timer that in case no data arrived(i have bool that save the current state) it wil call a function

my system uses 2 uarts.

2 questions:

1.which value i should provide to the "timerLoadSet" in order to give the timer a tick every 2-3 seconds?

2. in case im in the interupt (timer) and i get uart interupt will it bypass the timer or it will wait for it as nested interupt( i would like to avoid uart data lost and also in case of sending data its important me to finish sending the usb data)

i am using 120mhz clock!

Thanks

Idan

  • Hi idan,

    "i would like to create a 32 bit timer(or maybe i need less?) "
    "1.which value i should provide to the "timerLoadSet" in order to give the timer a tick every 2-3 seconds?"
    Now do you need less? Or maybe more than a 32 bit timer? Well lets see.
    The timers are just counters. Each time their clock does a cycle it decrements (or increments) 1. In the Tiva the timers clock is the system clock. So you need to first check the system clock! Assuming it's the 120Mhz - 1 value every 8,3333 ns. So if you want it to timeout you need to use a Load Value of about (if each 1 = 8,3333ns)?



    for question number 2, it depends on the priority set which I don't know the default by head.
    But you should not have any of the 2 interrupts too long! They should be as short as possible, actually, the uart interrupt should just set a flag like "NewData" so the main code can receive it. Having a timer interrupt while you are sending data in the main will not cause any problems and the timer interrupt will still fire every 2-3 seconds without problems (could be a nano second delay in getting to the interrupt when 2 interrupts fire at the same time).
  • so for 3 seconds i should provide the function :3/(8.333*10^-9) meaning =3.6*10^8

    if so i think 32 bit timer is more than enough
  • Hello Idan,

    The UART has a FIFO which an be enabled. When you do so the data being written to the FIFO has time before the FIFO can be overrun. Now the FIFO is 16 locations deep. So if the two interrupts occur together and Timer has a priority then the time available before an overrun occurs would be

    (16-RX THRESHOLD)*(8 Data bits+1 Start bit+1Stop Bit)/Baud rate assuming that the data byte is no parity and 1 stop bit.

    Where RX Threshold is a configured value in the UARTIFLS as 1/8,1/4,1/2,3/4 or 7/8 of 16

    Typically you must ensure that the Timer interrupt should not spend too much time processing either via blocking functions or doing operations like matrix multiplications.

    Regards
    Amit