element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Blog Renesas RX65 Envision Kit - part 2b: Blinky with Timer and Interrupt
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 23 Nov 2019 9:51 PM Date Created
  • Views 1131 views
  • Likes 4 likes
  • Comments 0 comments
  • RoadTest
  • rx65n
  • rt
  • renesas
  • e2studio
Related
Recommended

Renesas RX65 Envision Kit - part 2b: Blinky with Timer and Interrupt

Jan Cumps
Jan Cumps
23 Nov 2019

I'm evaluating the Renesas RX65N MCU EV Kit.

In this post: Expand the Blinky example with a timer and interrupt.

image

This time it's a real blinky. The code to poll the user button is removed and the led is controlled by one of the onboard timers.

 

 

Modify the Project

 

In the configurator, navigate to the Components tab, select the Config_PORT module and uncheck PORT0.

We don't use the switch anymore. That's why we can remove our claim to that port and pin.

 

Then add the following Timer blocks:

  • Compare Match timer: this is a compare type timer that can throw an interrupt at expiration.
  • r_cmt_rc for the API functions

image

Click Finish.

 

image

Save the configurator and Generate code.

 

Write the C Code

 

Activate the C/C++ perspective again and open RX65_blinky.c.

The reference to SW_2 is removed.

I'm also going to use an alternative option to set gpio outputs - without a function call. This requires a different declaration.

 

#include "r_gpio_rx_if.h"     /* Contains prototypes for the GPIO driver */

#define  LED_2   PORT7.PODR.BIT.B0

void main(void);
void cmt_cb(void *pdata);

 

The main function no longer polls the switch. It prepares the timer (2 Hz, resulting in one blink per second), sets the interrupt handler then does nothing interesting.

 

void main(void) {
    bool        cmt_result;
    uint32_t    cmt_hdl;

    /* Create timer0 with callback at a rate of 2Hz. */
    cmt_result = R_CMT_CreatePeriodic(2, cmt_cb, &cmt_hdl);
    if (false == cmt_result)     {
        nop();  //Handle your error here.
    }

    /* nothing to do, spin here */
    while(1);
}

 

In the timer interrupt handler, the led is toggled. You can compare the different way toggling with the post 2a.

 

void cmt_cb(void *pdata) {
    uint32_t channel_num = *((uint32_t *)pdata);

    switch(channel_num)     {
    case 0:
    LED_2 = ~LED_2;  // Toggle LED2 with each callback
        break;
    default:
        break;
    }
}

 

Build and debug. The blue led blinks.

 

The e2 studio project is attached.

 

Related blog
part 1: Create an Empty Project
part 2a: Blinky with GCC Toolchain
part 2b: Blinky with Timer and Interrupt
part 3: Port an example from Renesas toolchain to GCC
part 4a: Low Power - Sleep
part 4b: Low Power - Software Standby
4c todo: power mode 3
4d todo: power mode 4
part 5: DAC
part 6: Software SHA
part 7: Blinky with FreeRTOS
part 8: DMA
part 9: UART
part 10: Reserve LCD Frame Buffer in Expansion RAM with GCC
part 11: port emWIN to GCC and run an LCD Widget
Renesas RX65N MCU EV Kit - Review
Andrew Johnson's blog series
Renesas Envision Kit RPBRX65N Roadtest
Attachments:
RX65_blinky_timer_interrupt.zip
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube