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.

TM4C Timer Output to Pin

Other Parts Discussed in Thread: TM4C1231E6PM

Is there a way to have a GP timer create an output to a CCP pin in a uC without a PWM module?

I'm using the TM4C1231E6PM

The literature seems to imply that it should be able to with a match value set, and the driver library has TIMER_CFG_A_ACT_TOGGLE bit defined but I am unable to get it to work. I'm trying to use  the T2CCP0 on PF4 with Timer A

  • Hello Frank,

    Yes it is possible to do so without using the PWM module. Can you please share your existing code so that we can check why the CCP pin is not toggling?

    Regards
    Amit
  • // Set Buzzer Frequecies & timer counter values
    #define BUZZER_TIMER_FREQ_HZ 2400
    #define BUZZER_TIMER_TIMEOUT ((UINT32)(ROM_SysCtlClockGet() / (BUZZER_TIMER_FREQ_HZ * 2)))

    #define BUZZER_SYS_PERIPH_TIMER SYSCTL_PERIPH_TIMER2
    #define BUZZER_TIMER TIMER2_BASE
    #define BUZZER_PIN_BASE GPIO_PORTF_AHB_BASE

    ROM_SysCtlPeripheralEnable( BUZZER_SYS_PERIPH_TIMER );
    ROM_TimerDisable( BUZZER_TIMER, TIMER_A );
    ROM_TimerConfigure( BUZZER_TIMER, TIMER_CFG_A_PERIODIC | TIMER_CFG_A_ACT_TOGGLE );
    ROM_TimerLoadSet( BUZZER_TIMER, TIMER_A, BUZZER_TIMER_TIMEOUT );
    ROM_TimerMatchSet( BUZZER_TIMER, TIMER_A, BUZZER_TIMER_TIMEOUT / 2 );
    ROM_TimerControlStall( BUZZER_TIMER, TIMER_A, TRUE );
    ROM_TimerEnable( BUZZER_TIMER, TIMER_A );
  • I also added the following: (And yes the Port F peripheral and AHB is enabled prior)

    #define BUZZER_PIN_BASE GPIO_PORTF_AHB_BASE
    #define BUZZER_PIN GPIO_PIN_4

    ROM_GPIOPinConfigure( GPIO_PF4_T2CCP0 );
    ROM_GPIOPinTypeTimer( BUZZER_PIN_BASE, BUZZER_PIN );
  • Does the code (below) properly link to PF4?   

    #define BUZZER_PIN_BASE    GPIO_PORTF_AHB_BASE

    And - brief code shown appears to "miss" the "SysCtlPeripheralEnable()" of Port F.

    Must say that I'm, "in the camp" of those believing that (Timer in PWM mode) "serves best" to expose timer results to an output pin.

  • I got it to work with the following code changes:
    (Added TIMER_CFG_A_PWM to TimerConfigure() call, anbd found that I had to manually set the 0x04 bit in the TIMER_O_CFG register)
    The driver lib does not seem to handle this correctly on it's own.

    ROM_SysCtlPeripheralEnable( BUZZER_SYS_PERIPH_TIMER );
    ROM_TimerDisable( BUZZER_TIMER, TIMER_A );
    ROM_TimerConfigure( BUZZER_TIMER, TIMER_CFG_A_PWM | TIMER_CFG_A_PERIODIC | TIMER_CFG_A_ACT_TOGGLE );
    ROM_TimerLoadSet( BUZZER_TIMER, TIMER_A, BUZZER_TIMER_TIMEOUT );
    ROM_TimerMatchSet( BUZZER_TIMER, TIMER_A, BUZZER_TIMER_TIMEOUT / 2 );
    ROM_TimerControlStall( BUZZER_TIMER, TIMER_A, TRUE );

    ROM_GPIOPinConfigure( GPIO_PF4_T2CCP0 );
    ROM_GPIOPinTypeTimer( BUZZER_PIN_BASE, BUZZER_PIN );
    HWREG( BUZZER_TIMER + TIMER_O_CFG ) = 0x04;

    ROM_TimerEnable( BUZZER_TIMER, TIMER_A );
  • Hello Frank

    Are you using the timer in 32 or 16 bit mode?

    Regards
    Amit

  • I don't know how to specifically specify 16bit mode since TIMER_A would be used to for 32 and 16bit mode when calling TimerConfigure, but since I used TIMER_CFG_A_PERIODIC | TIMER_CFG_A_ACT_TOGGLE, but I'm thinking I'm using 16bit mode and apparently the hardware thinks the same since I have to force it using the 0x04 bit in the config register.
    I also found it odd that I had to use the TIMER_CFG_A_PWM when the uC does not have a PWM module.
  • Hello Frank,

    If it is 16 bit mode then you have to specify the Timer configuration as

    TimerConfigure(BUZZER_TIMER, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);

    Regards
    Amit
  • OK, that's what I was missing, but it still doesn't answer the question of why you have to specify TIMER_CFG_A_PWM when there is no PWM module and it is not a PWM function.
  • Hello Frank,

    That is what I saw in your application code, so my assumption was that you are using the PWM mode. If not then TIMER_CFG_A_PERIODIC is to replace TIMER_CFG_A_PWM

    ROM_TimerConfigure( BUZZER_TIMER, TIMER_CFG_A_PWM | TIMER_CFG_A_PERIODIC | TIMER_CFG_A_ACT_TOGGLE );

    would be

    ROM_TimerConfigure( BUZZER_TIMER, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_A_ACT_TOGGLE );

    Regards
    Amit
  • Sorry but it will not work unless you include TIMER_CFG_A_PWM
    ROM_TimerConfigure( BUZZER_TIMER, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM | TIMER_CFG_A_PERIODIC | TIMER_CFG_A_ACT_TOGGLE );
  • Hello Frank,

    In the Regular Periodic mode the Timer can generate outputs. This is clearly documented in the data sheet.

    Regards
    Amit
  • I wouldn't say it's clearly documented at all, and if I don't include TIMER_CFG_A_PWM in the call then it simply does not work.
    Why don't you try it and see for yourself OK?
    Thanks
  • Hi Amit,

    Earlier the statement was made that a timer signal/event could be output to the appropriate timer pin - without the timer being forced into PWM Mode.

    My group has NOT found that to be true! Are you in agreement? Thanks...
  • Hello Frank, cb1,

    Yes you are right. It does not exist on the TM4C123 (for some reason I had it confused with the TCACT on TM4C129).

    The PWM Mode is the only mode on TM4C123 for output on CCPn pin.

    Regards
    Amit
  • Hi Amit,

    Feel not bad - that would have been a "break-thru" for LX4F or '123!    As parts are added to your mix - it is (indeed) hard to track "everything!"

    I did not believe "Timer Output" was possible (from either of the above) unless PWM was linked.   (and such holds for "others" ARM MCUs - too (except in more deluxe models & cases)

    To Frank - perhaps if you think of "PWM" as a "free bonus" it will be more palatable!    You can easily create (nearly) any duty cycle - although 50% works very well for most applications.   You confirmed this reporter's beliefs (and teachings...)

  • Yes, it had occurred to me that indeed I could use it as a PWM timer with varying duty cycles. In a lot of cases there does not seem to be a need for the PWM module. The data sheet for the TM4C1231E6PM talks about the PWM module being in there and describes its capabilities. That threw me for a while trying to get the PWM module to work. Only after more digging did I find out that the part does not have a PWM module, so yes I'm considering the timer output mode a free-bee.
    Cheers!
  • Just one more thing I noticed is that I can't seem to make it work in 32bit timer mode, only 16 bit mode seems to work.
  • You've made a nice, "attitude adjustment" Frank - and solved your issue - good that.

    Believe if you dig bit deeper in the Timer Chapter (particularly the, "Timer Group Chart") you'll observe that "Timer PWM mode" is accommodated (only) via 16 bit timer. (that from memory...) Bon chance mon ami...
  • What book are you referring to?
    I'd love to have something more to refer to than the data sheet and the driver lib document.
  • The MCU Data Manual - Timer Chapter - includes this chart.

    You'll note that the "normal" timer only allows 16 bit operation when in PWM Mode.   That said - the "wide" timer (appears) to double that.  (we've never used in that manner - finding the wide timers (better) for longer time measures...)

    Beyond the MCU manual, Driver Lib, the many code examples (your MCU & others) provide great learning...

  • I must be dense or something because I can't find any reference to an MCU Data Manual anywhere on the TI website.
    Where can I get a copy of it?
    Thanks for all your help!
  • We may be impaled by language and/or interpretation.  

    As past tech writer - anything exceeding 50 pages - is (usually) classed as a manual.   My small firm dislikes calling the MCU manual (1K+ pages) a "data-sheet!"  

    Know that other ARM MCU vendors (often) provide 2 such MCU tech write-ups - one outlining key features (say 70-150 pgs) and a, "Reference Manual" (never data sheet) in the 1K+ neighborhood.   (that one w/the real "nitty-gritty."    (our group finds that dual write-up approach best - as the fine-detail is separated from the more "user-basic" descriptions...

  • So how can I get a copy of the thing you are talking about with the chapters in it?
  • My bet is that you (already) have one! From this vendor's site - entering your MCU part number will produce a page-full of detail - and the "largest" document w/in that page(s) most always will be the MCU manual. (sometimes described as data sheet) (misuse of language is a plague - mais non?)

    Here's a scan from top page of our MCU manual (1400+ pages) "improperly labeled" (here) as data-sheet!   (some "sheet!")

    My firm uses ARM MCUs from 4 different vendors (no one - at all times - can be considered "best/brightest") yet "few" label 1400+ pgs. as a "sheet..."