# Embedded C Programming

I am currently a project intern, working on Light Fidelity (Li-Fi). Most part of the project deals with development of software for Renesas Micro controller.

I have a simple doubt regarding timer and interrupt programming.

As a part of my project, I have to generate an interrupt as soon as the timer overflows. I am trying hard and finding it difficult to achieve it . Also. I need to know about how to calculate the timer overflow value, so that an interrupt is generated.

It would be great help,if these questions are solved and explained in detail.

Thank you!

• Respected sir, thank you for showing your your interest and help me solve this problem. The details are as follows : 1) Renesas RL78/F13 microcontrollers. 2) We are using IAR IDE, along with APPLILET3 for code generation. Hope this will be beneficial to solve my doubt. Thank you! Dec 4 '19 at 4:02
• My experience is limited to e2Studio, smart configurator and RX130 processor platform. Using above tools and microcontroller it took me less than 15 minute achieve the above task. I think this can be achieved with RL78/F13. If you are open to experimenting with e2Studio, smart configurator and RL78 I will post a step. Hopefully this will help you guidance to solve the problem for RL78/F13 and IAR IDE. Let me know your thoughts. Dec 5 '19 at 1:53
• Dear Sir, it will be of great help, if you could guide me. Thank you! Dec 5 '19 at 10:04
• I have posted a brief response to your question. If need assistance with setting up a GPIO port connected to LED, post a separate question with a link this question. There are step that I left out, which I believe are intuitive, Dec 6 '19 at 15:25
• Also I suggest that you update the question with comments about micro controller and IDE and delete the comment. Their is an edit option to help update the question, below the tags Dec 6 '19 at 15:27

This response is based on RX130 Capacitive touch development board as shown below

• IDE: e2Stuido v7.5 and above
• Toolchain: Renesas RXC toolchain
• Board: RX130 Capacitive touch development board
• Debugger: E1

The steps below are to help setup the RX130

1. Set up clocks HOCO Clock and VCC to 5.0

make sure other clocks a deselected

1. Select the Compare Match Timer and add software module

1. Configure the Compare Match Timer (CMT)

The above are all the step you need to configure the Compare Match Timer. There are steps that have been left out to be concise.

To test the CMT setup a GPIO port connected to a LED and toggle the LED when CMT has rolled over and interrupt is generated

mcu-programming-peripherals-04-interrupts.html

It has information about how to use interrupts (very similar to Arduino). However, for the timer I only see references to functions like milli.

As you mention, the best way is to set up a timer which automatically sets the value of the time, after the interrupt is generated.

For this, you need to set the relevant registers, which can be found in the datasheet of your MCU.

In general, it works something like this:

• Chose a timer peripheral (if there are more, high likely)
• Set the timer value (this can involve multiple registers, like a value, multiplier, something to repeat interrupts or a one-shot, or a comparator).
• Start the interrupt
• Thank you so much! I will try it! Dec 4 '19 at 4:07