TM4C1294NCPDT: TimerMatchSet() problem

Expert 4090 points
Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: ALP

Hi team, 

Attached you will find C code source and the log file.

TimerCounter.zip 

To drive the motor, we use:

  • A first timer (interrupt every 5 ms) to do a soft start
  • A second timer/counter to count the pulse sent by a tachymeter
  • An optical switch to determine the initial position

 

From the initial position, we try to have 8 rotations of 45°. Each rotation starts with a soft start (driven by the first timer) and continue until the second timer interrupts to do the soft stop.
The motor is started and after, all is driven from interrupts.

The application is waiting for a semaphore to be posted when 45° is done or when initial position is reached. We are having an issue with reading the value where it resets (goes to 0 instead of the actual reading). 

Best,

Luke

  • Hi Luke 

    >> We are having an issue with reading the value where it resets (goes to 0 instead of the actual reading). 

    May I know at what condition (motor position) user read the value (timer counter) is 0? 

    Could you please point out the code line # on the ddi_manifold_ALP_1.c

    Thanks!

  • Hello,

    The software is built with FreeRTOS.

    When timer/counter (counting UP)  is read from interrupt handler, and restarted with TimerMatchSet(), the value is incremented correctly.
    Then when we reach the sopt count, we just disable the timer interrupt.
    Then when the task read the value of the timer, it has been reseted, but continue to count from 0.

    Sample of trace:


    ALPTimerIntHandler Step 1 timer 94
    ALPTimerIntHandler Step 2 timer 98
    ALPTimerIntHandler Step 3 timer 102
    ALPTimerIntHandler Step 4 timer 106
    ALPTimerIntHandler Step 5 timer 110
    ALPTimerIntHandler Nb45deg 2 timer 113

    Then value read from task:

    58: MANI ALP End position 113 -> 1
    58: Line 1015 Count 66:1 Total 0

    The counter has been reseted, and just read one more pulse!

    I do not understand why the counter is reseted to zero. I need the value, cumulated from the start.

    Thank you for your help.

    Best regards.

                                              FWX.

  • Hello

    I checked the device data sheet 13.3.3.1 One-Shot/Periodic Timer Mode

    I think "counter is reseted to zero" on counter (counting UP)  mode should be normal behavior. 

    Could you please comment if my understanding is correct.

    Thanks!

  • Hi,

    My timer/counterA  is just configured with:

    TimerConfigure ( ALP_MOT_TACHY_TIMER_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP | TIMER_CFG_B_PWM );
    I do not indicate if timer A is periodic or one shot.

    But the behavior is not exactly what it is described in the doc: counter continues to count from the last value; it is not reseted to zero each time TimerMatchSet() is called from interrupt handler. As shown in my previous post, the counter if updated between interrupts: 94, 98, 102.. That is good for my usage. But I do not know why, the couter is reseted later.

    But perhaps I can't use the timer like that.

    Thank you for your comment.

    Best regards,

                         FWX.

  • Hello

    Please check SW-TM4C  TivaWare for C Series Software

    There is oneshot_16bit and periodic_16bit on C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\timer

    Could you please help to compare your code and this example code?

    Thanks!

  • Hi,
    I use timer A.
    The configuraion is:
    TimerConfigure ( ALP_MOT_TACHY_TIMER_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP | TIMER_CFG_B_PWM );
    Nowhere does it say that I have to specify TIMER_CFG_ONE_SHOT or TIMER_CFG_PERIODIC.
    In my case, I should like that interrupt handler is called when the counter value match the limit, then continue to count until the counter value match the new limit, and so on.
    The timer/counter seems to follow this behavior, except that sometimes the value is reset to zero. Is this related to disabling interrupts? Configuration problem?
    Thank you for your help.

  • Hello

    oneshot_16bit and periodic_16bit on C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\timer is based on TIMER0B

    timer A and timer B on TM4C1294 are the same.

    So, please try run this example code and refer to it.

    Thanks!