I want to get another simple program working that requires more effort on my part in utilising the tools available. In this brief note, it is to create a Blinky app (similar to the tutorial that failed in part 3) whilst utilising the Smart Configurator. I know Blinky is boring, but the idea is that the LED will blink under a timer interrupt OR under a user switch press. I’m not so much interested in that per-se, but very interested in how the Smart Configurator works within the e2Studio IDE as it promises a gui-based tool for setting pins and writing code. These are all building blocks to developing applications for the MCU.
Summary of steps:
- Create a project ensuring it is associated with the Smart Configurator
- Open the Smart Configurator file (.scfg) or the Smart Configurator Perspective, which does the same
- I want the Compare Match Timer and selecting it will allow me to configure it and have the relevant code created: specifically, to have the timer count to 5000 and use an interrupt. The CMT is typically used to measure incoming digital waveforms allowing characteristics such as frequency to be determined. In my case, I will be using it as a simple counter but timing is possible.
- Repeat for Ports which will allow me to configure port usage (reading/writing/direction/pins and so on) on the MCU. I need Port0 and Port7 because from the board schematic I see:
- LED: Port P70, Pin 104
- Configure the Pins - essentially, make sure the ports are enabled and the correct pin assigned to it
From here, the Smart Configurator can generate the necessary code for the selections made.
Source code can then be modified - like all good generators, delimiters are used to tell you where you can enter your own code
To give an example of what this means, the code I have to add to blink the LED (without the switch operation as yet, I’m building up to that) on the Compare and Match Timer interrupt is (extracted from the 3 source files I had to change):
/* define the LED . Bit 0 because the LED is assigned to PORT70 */ #define LED2 (PORT7.PODR.BIT.B0) … /* Toggle LED */ LED2 ^= 1U; … /* Start Compare & Match Timer operation and loop forever */ R_Config_CMTW0_Start(); while (1U) { nop(); }
And indeed, LED2 blinks. Having got this far, I realise that Jan Cumps Jan Cumps has done essentially the same thing in a slightly different way in two of his review posts and it’s worth reading through those as well: here and here.
Adding the switch will require some additional Smart Configuration changes and a small bit of additional code. I’m actually basing the app on the sample program that I couldn’t get working in Part three because it was for a different board as I now understand enough to work out how it is doing it. So as well as the LED configuration in Smart Configurator, I’m adding the Interrupt_Controller with configuration for IRQ13. Although the SW2 can use Port5, that’s not needed as it will generate input signal on IRQ13 and I can hook off that.
Right, so after about 9 hours of trying to figure this out with the switch not working, I managed to sort it out. Whilst SW2 should interrupt on IRQ13, it is necessary to hook it up to do so which I hadn't figured out! I couldn't work out why it wouldn't fire off interrupt 13 when pressing the button but it is all there in Smart Configuration and now I know, I know.
I’m a bit frustrated with it but also myself because it's obvious once you know. Like a lot of things I suppose.
So if anyone is interested, I’ve attached the project. When it is run, don’t press the user switch and the LED should blink rapidly unaffected by the user switch which you can press away as much as you like once it has started; press the Restart button on the debugger whilst pressing the user switch and the LED should light; it will alternate on and off with every subsequent user switch. This is all happening on interrupts, configured through Smart Configuration, rather than with realms of hand-written code. in order to do that, this is the handwritten code necessary:
main function
/* Start Compare & Match Timer operation */ LED2 = LED_OFF; if (SW2_PUSH == SW2) /* SW2_PUSH = Manual Mode, Other = Auto Mode*/ { R_Config_ICU_IRQ13_Start(); } else { R_Config_CMTW0_Start(); } while (1U) { nop(); }
Interrupt Handler code for the switch (the interrupt handler for the Compare Match Timer above on line 05 hasn't changed, but I should change it to the same as below for consistency.):
LED2 = ~LED2;
And a definition for SW2:
#define SW2 (PORT0.PIDR.BIT.B5)
Everything else is generated.
Summary Thoughts
As I go through the features of the development toolset, I remain impressed with the support Renesas has provided to help. So far I’ve tried out a Quick and Effective tool (in part 3) for on-the-fly changes to managing the display and here, the Smart Configurator to get access to the Ports, Pins and built-in timers that the MCU has. Incidentally, using the QE tool really is effective: as you make adjustments on-the-fly to the display, in my case, when you have it set up correctly, the tool can be used to create a Header file with the set parameters to include in your application.
I'm still struggling a bit with the structure of information from their website but it is becoming easier.
Further Entries
I will update this entry to provide links to further instalments as I create them:
Part Three: Development Software
Part Four A: Smart Configuration (this post)
Part Four C: Segger emWin Introduction
Part Four D: Removal of the LCD
Part Four E: Analog to Digital Conversion
Part Five: Static Setup of the GUI
Part Six: Getting the Display Working
Part Seven: USB/Serial Interface
Also, worth reading Jan Cumps' road test as he's taking a more technical approach.
Top Comments