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.

EK-TM4C1294XL: TIMER interrupt for every 500us

Part Number: EK-TM4C1294XL

Hi,

 i want to take adc samples for every 500us , so i thought of doing with a TIMER by setting an interrupt for 500us , so every time when it goes to ISR i can take ADC samples, but taking ADC sample in ISR is good idea??   or i need to do it in other way like setting a falg in ISR and in main inside while loop observing that flag and taking ADC samples when it is set , which one is better?, and if possible can anybody share the code for setting the timer interrupt for 500us.

thanks!

Regards,

Rupendra  

  • Setting a "flag" w/in the (smaller, quicker executing) ISR is the better of your two approaches.

    Your review of (both) MCU Manual and "Peripheral User Guide" will instruct as to, "How your Timer may "trigger" a repetitive ADC sampling" - exactly as you seek.

    Rather than "share" would not your effort - presented here - prove best for your learning - and serve to better compel, "Helper effort/guidance?"

  • cb1_mobile said:
    Your review of (both) MCU Manual and "Peripheral User Guide" will instruct as to, "How your Timer may "trigger" a repetitive ADC sampling" - exactly as you seek.

    Definitely the place to start.

    Interrupt on A/D completion, not on A/D start.

    Robert

  • Hello Rupendra,

    In addition to the advice of cb1/Robert to review available MCU manual's, as far as example code goes you may find some useful timer examples in the TivaWare peripheral folder: [Install Path]\TivaWare_C_Series-2.1.4.178\examples\peripherals\timer

    And a basic example of a 1s and 500ms timer for your LaunchPad at: [Install Path]\TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c1294xl\timers

    Setting a flag in an ISR is always a preferred solution. ISR's are best kept as lean as possible. Make sure if you do that method to have your flag variable declared as a volatile so it will be toggled properly with each interrupt.

    The code examples I noted along with reading of our provided manual's should provide you all the knowledge you need to achieve success with your application.
  • "Effort-lite" - (share the code) appears rejected in favor of (far more appropriate/beneficial) "focused, poster effort..."