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.

LM3S8962: Check the Time-Out Raw Interrupt Status (Blink a led)

Part Number: LM3S8962
Other Parts Discussed in Thread: LM3S811

I am doing a blinky led using Timer Time-Out. Although I follow the instructions in the datasheet, I don't know why this program doesn't work. I guess that this 

condition " (TIMER0_RIS_R & 0x01)  == 1 " is fault so that the LED doesn't blink. Can anyone help me pls!!!

int main()
{
//Set the system clock to 8MHZ
SysCtlClockSet (SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

//Enable Timer0
SYSCTL_RCGC1_R = SYSCTL_RCGC1_TIMER0;

//Disable Timer0 for config
TIMER0_CTL_R &= ~0x01;

//Choose 32bit Timer 
TIMER0_CFG_R |= 0x00;


//Choose periodic mode
TIMER0_TAMR_R |= 0x02;


//Load the value of 4,000,000
TIMER0_TAILR_R |= 0x3D0900;


//Star the Timer0
TIMER0_CTL_R |= 0x01;


//=============================================================//
// Enable GPIO //
//=============================================================//


// Enable the GPIO port F for the on-board LED and SW2:
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;

//Enable the GPIO pin for the LED(bit 0)
//Set the direction LED(bit 0)- OUTPUT
GPIO_PORTF_DIR_R = 0x01;

//Enable the GPIO pins:
GPIO_PORTF_DEN_R = 0x01;

while(1) {

    if ( (TIMER0_RIS_R & 0x01)  == 1) {

          TIMER0_ICR_R |= 0X01;
          // TIMER0_CTL_R &= ~0x01;
          GPIO_PORTF_DATA_R ^= 0X01;
          // TIMER0_CTL_R |= 0x01;
    }
  }
}

  • Hello Tuan,

    1) The LM3S is NRND, you should work with the TM4C123G moving forward. We won't offer support for new designs/projects on an NRND device. Here is the TM4C123G LaunchPad: http://www.ti.com/tool/EK-TM4C123GXL

    2) When you migrate to TM4C123G, you should be using TivaWare and not DRM, our TivaWare APIs have been developed to remove the burden of DRM for all our customers, and we have a blinky example already done in TivaWare. If you truly wish to use DRM, then reference the TivaWare project to understand all the required DRM calls (the API's themselves use DRM if you investigate each API), but understand doing so will likely block you from receiving detailed TI support as we are not going to invest time re-inventing the TivaWare API's that were carefully crafted specifically to avoid issues with DRM like what you are facing.

    TivaWare download: http://www.ti.com/tool/SW-TM4C

  • Hi, from a long time LM3S user here.

    Your code looks right, though I didn't check against the datasheet. I would suggest the following.

    1. Make sure you can blink the led.
    2. If you have a debugger, make sure that the timer is running.
    3. The if statement happens to be right but I generally don't explicitly test for a non zero condition. I only test for a zero condition explicitly. So in your code, I would use instead.

    If (register & mask) do-something().

    Or to test a zero condition explicitly.

    If ((register & mask)== 0) do-something().

    If you want, I have a set of code for the LM3S family that hopefully will get you going.
  • As one (also) very much against the use of "DRM" (why DID you USE THAT - by the way?) as a "fellow" LM3S  Device User - I feel compelled to (attempt to) assist.     (and - on occasion - succeeding...)

    You MUST be aware of   "KISS"  (google if you are not) much of your difficulty (likely) flows from your choice of:

    • "hard over easy"   (i.e. 32 bit over (simpler) 16 bit Timer)
    • the "Holding Hostage" of your result/objective -  to "indirect" factors   (i.e.  Timer's Raw Interrupt Status (attempt) ... may block your Led operation)
    • failure to "Test & Verify" that your "Led Code" performs to expectation    (you critically rely upon that "Timer Interrupt" - but (other) events may prevent the Led from responding!)

    "KISS" directs that you write your code (ideally via the API - just as vendor's Ralph suggested) - so that it develops "Systematically" and "Incrementally" ... ONE TESTED/VERIFIED - STEP AT A TIME!

    Should you have not - at minimum - "Tested your Led code (i.e. ON/OFF) independently of its insertion w/in the "RIS Interrupt test?"    Creating such "dependencies" - makes little sense - and is (sure) to devour time & effort.

    As a "hint" - should you not  (earlier) have "Enabled Timer Interrupts" - and then insured that  "ALL"  were clear/cleared - prior to launching your  "RIS Test?"

  • Tuan Kiet Dang said:
    // Enable the GPIO port F  for the on-board LED and SW2:
    SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;

    The above caught my attention - poster claims that (both) the LED & Switch (the interrupt's generator) reside upon Port F.

    And then - poster code reveals:

    Tuan Kiet Dang said:
    //Enable the GPIO pins:
    GPIO_PORTF_DEN_R = 0x01;

    Thus - Port F - pin "0" - is the only pin enabled!    (results due to poster's "assignment")    The switch - assuming that it does reside upon Port F - must then be,  "Undetectable!"

    Beyond this - as my earlier post noted - poster's code does not reveal ANY Set-Up nor Config. of Port F's interrupt - placing (yet another) roadblock to the detection of his board's switch!

    Should it be noted that   vendor's  "Thinks Resolved" -  falls far short of the  more detailed/insightful post  -  which "actually Resolves?"

  • here is your code, with minimum modification, running in a simulator on LM3S811, flipping PC5.

    if you wonder, it also ran on a real LM3S811, flawlessly.

    Your code is mostly sound. Just some minor tweaks.