Frequency counter for UNO R4 wanted

$43 from Mouser - it has a Segger debug chip on it as well - which make the extra cost very worthwhile.

https://www.mouser.com/ProductDetail/Renesas-Electronics/RTK7EKA4M1S00001BU?qs=d0WKAl%252BL4KaDvzUWcFqJAA%3D%3D

1 Like

pretty reasonable. Is the IDE enough to use the kit? I found the FSP download, but I hope to avoid learning new tools.

I have found the easiest way to get the Arduino Minima dfu_minima.hex bootloader into the chip on the dev-board is using the Segger J-Flash Lite tool, which you can get here:

https://www.segger.com/downloads/jlink/

Note when doing this techniques, do NOT short the MD pin to ground (as it says to do in the Arduino notes) because we are using the Segger debug to load the code in sideways!

Once you have loaded the bootloader, just press the reset button and the EK-RA4M1 dev board should pop up on a COM port showing as a Minima.

In the Arduino IDE?

Yes.

1 Like

Thanks. I'll bite the bullet and buy an eval board ...

2 Likes

This is what it looks like - click on the button that has the three dots [ ... ] to get the file open menu.

2 Likes

My RA4M1 eval kit finally arrived ... (I'm in Australia, plus it was delayed by export review)

A couple of Q's if I may:

Should I skip the example project and the EX-RA4M1 QSG and go staight to J-Flash Lite and load dfu-minima.hex ?

I will need the J-link USB driver no doubt, but I'll be using the IDE so I assume I don't need FSP and e2 studio ?

TIA

1 Like

If you have the time, try out the e2studio. Just to get an idea as to what is involved.

By comparison, the Arduino IDE is simple.

But in the e2studio you get the full debugger and it is set up to show all the memory mapped peripheral states, as well as the processor stuff. If you use the debugger externally with the Segger Ozone tool it doesn't give you the memory-mapped peripherals.

I am looking at that to see if I can find the definitions to port these across for ozone, but don't hold your breath.

Once one has the bits together, one can hop between using e2studio and then quickly burning the Arduino bootloader and using the Arduino IDE.

Having just checked, the e2studio also works with an external Segger J-link unit, I have one (the base model, not the pro) which is connected to the debug header on the Minima and it works.

Lots of good progress: I worked through all the steps in the EK-RA4M1 Quick Start Guide with no issues. I was pleased to find e2studio is basically eclipse with a comprehensive Renesas overlay. I have played with eclipse in the past so e2studio is not completely unfamiliar. And I can see all the extra RA4M1 goodies in there ... for future fun.

I "side-loaded" dfu_minima.hex into my EK-RA4M1 using J-Flash Lite no problems, so now it thinks it's a Minima :slightly_smiling_face: It ran your HOCO sketch OK, and some of my other sketches too.

So all good, many thanks for your pointers & code ...

I threw together this mapping for the J1-J4 headers to UNO pins ... see attached

1 Like

Awesome, many thanks for the update; great to hear! :slight_smile:

I've stuffed up, unwittingly loading a sketch into the EK-RA4M1 with a bug that causes it to constantly output data to the serial port, every loop()

Annoyingly this interferes with the upload process, preventing replacement of the dud sketch, and the upload eventually times out.

Is there any easy way to stop, disable or remove an existing sketch (on an EK-RA4M1 set up to think its an R4 Minima) so a new skecth can be loaded? Maybe there's a reset to factory method?

FYI my upload issue has been resolved. A quick double reset push which puts the MCU in boot mode and a fresh upload was done.

@susan-parker I'm looking at your photo of 2 Minima's side by side (here). You've fitted one Minima with a 12MHz crystal piggybacked on the MCU.

I assume you're connecting the crystal to the 4 large solder pads for the uninstalled 16MHz crystal (Y1). Then you've thrown in a whole bunch of bypass caps (22pF ? ), but what are the two blue wire doing? It looks like one picks up +5V from the green Power LED (DL3) and the other picks up another 5V (VUSB) on the USB over-voltagae protection Schottky Diode (D3).

But what are you doing with the 5V? and how does the resistor get involved? tks

(Just realised there may be only one blue wire ? can't quite see)

As an aside, why was arduino considering 16MHz crystal? Why did they drop it? And why are you using 12MHz instead?

TIA

Yes, I have fitted a 12.2880 MHz crystal.

I underestimated the amount of capacitance needed with the physically larger crystal than what is inside the surface mount part, so I added extra capacitors to the existing ones rather than unsoldering fiddly connections.

The 1M0 resistor is across the crystal connections, which is standard for crystal oscillators, certainly for the larger ones.

I don't know why Arduino people put in 16MHz, the RA4M1 xtal circuit won't work (isn't specified to anyway) above 12.5 MHz when using the PLL circuit, so one divides by 2, then multiplies by 8 to get the main 48MHz clock.

The Renesas EK-RA4M1 dev-board has an external 12.000MHz crystal fitted, but I am also interested in audio-rate clocking, so I used a 12.2880 MHz crystal.

One can use a 12.000MHz one just as well, or experiment with other frequencies and PLL ratios.

It's not much for overclocking, but there are times when even 2 or 3 % more code exercution makes a difference.

Once one has the external crystal working, one can then start switching the main clock dividers whilst retaining the USB on the internal 48MHz HOCO so the USB serial continues to function.

The blue-wire takes the USB +5V input before the diodes so that the power-ON LED is only illuminated when the board is connected to a USB host. The ON LED with the 330 ohm series resistor otherwise takes 8mA or more when in use, which isn't exactly low-power!

On my Minima board with the crystal, I have also changed all the 330 ohm resistors to larger values - 2.3K for the ON led and 1.5K for the others.

:slight_smile:

As an aside, I ran a Minima doing some simple data-logging every minute using the basic compare millis count and after more than 2 months it was still in step with the computer PC time (to within a minute anyhow).

That a lot more accurate than my old school Timex ever was!

So unless one needs super-accurate timing, the lack of an external crystal shouldn't be an issue.

:slight_smile:

many thanks for your detailed response, lots of good info.

I'm not so concerned about in overall board power consumption so I probably won't replace the LED resistors. But I do want MCU precision timing on my minima to match the EK-RA4M1 so I'll fit the crystal (with fewer bypass caps and the resistor).

1 Like

I added Xtal with the intention of using the UNO R4 for measurement purposes. Then I was able to change and run the clock settings on the sketch.

Next I am trying to initialize the clock settings in the bootloader. But when it moves to the sketch the system clock source is HOCO instead of PLL.

And also the MOCO capability and USB clock source is not set as expected.

The changes to the bootloader settings are as follows

bsp_clock_cfg.h

/* generated configuration header file - do not edit */
#ifndef BSP_CLOCK_CFG_H_
#define BSP_CLOCK_CFG_H_
#define BSP_CFG_CLOCKS_SECURE (0)
#define BSP_CFG_CLOCKS_OVERRIDE (0)
#define BSP_CFG_XTAL_HZ (12000000) /* XTAL 12000000Hz */
#define BSP_CFG_PLL_SOURCE (BSP_CLOCKS_SOURCE_CLOCK_MAIN_OSC) /* PLL Src: XTAL */
#define BSP_CFG_HOCO_FREQUENCY (0) /* HOCO 24MHz */
#define BSP_CFG_PLL_DIV (BSP_CLOCKS_PLL_DIV_2) /* PLL Div /2 */
#define BSP_CFG_PLL_MUL (BSP_CLOCKS_PLL_MUL(8u,0u)) /* PLL Mul x8 */
#define BSP_CFG_CLOCK_SOURCE (BSP_CLOCKS_SOURCE_CLOCK_PLL) /* Clock Src: PLL */
#define BSP_CFG_ICLK_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_1) /* ICLK Div /1 */
#define BSP_CFG_PCLKA_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_1) /* PCLKA Div /1 */
#define BSP_CFG_PCLKB_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_2) /* PCLKB Div /2 */
#define BSP_CFG_PCLKC_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_1) /* PCLKC Div /1 */
#define BSP_CFG_PCLKD_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_1) /* PCLKD Div /1 */
#define BSP_CFG_FCLK_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_2) /* FCLK Div /2 */
#define BSP_CFG_CLKOUT_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* CLKOUT Disabled */
#define BSP_CFG_CLKOUT_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_1) /* CLKOUT Div /1 */
#define BSP_CFG_UCK_SOURCE (BSP_CLOCKS_SOURCE_CLOCK_PLL) /* UCLK Src: PLL */
#endif /* BSP_CLOCK_CFG_H_ */

This is exact copy from configuration file for RA4M1_EK setting.

In bsp_cfg.h

#define BSP_CLOCK_CFG_MAIN_OSC_POPULATED (1)

This line is the same setting as the configuration file for RA4M1_EK

If you know how to change the clock settings in the bootloader, please let me know.

Why? The bootloader works OK with whatever clock it is using, right?
AFAIK, there is nothing to stop you from reconfiguring the clock in the application code (your sketch.)

There are several reasons. The most significant reason is that I want to use HOCO at other frequency. However, the HOCOCR2 (HCFRQ1) register is not defined in the BSP and cannot be changed from the sketch.

As mentioned above, the EK-RA4M1 configuration file sets Xtal to be used as the system clock on the bootloader and also initializes HOCO to 24 MHz. In the same way, I want to initialize the frequency of HOCO in the configuration to use a frequency other than 48MHz. (In the above, I set the frequency to 24MHz because I tried it with the same settings as EK-RA4M1 as the first step, but I would like to use it at 64MHz).