I just got my R4 WiFi and really wanted to dive into the guts of it. I love the eclipse IDE so looks like e2 Studio was the way to go. I found an example online about creating a "Bare Metal Blinky Project" and seems like my code should work but of course it doesn't.
I figured out how to upload my code using the arduino-cli.exe tool(unfortunately you must install the complete Arduino IDE and R4 board package to do this)
This simple Blinky code works when compiled and loaded through the Arduino IDE
while(1)
{
R_BSP_PinWrite (LED_PIN, BSP_IO_LEVEL_HIGH);
R_BSP_SoftwareDelay (500, BSP_DELAY_UNITS_MILLISECONDS);
R_BSP_PinWrite (LED_PIN, BSP_IO_LEVEL_LOW);
}
However no luck with e2 Studio .. Here's some details
Board= Custom User Board, Device = R7FA4M1AB3CFM
I have defined as BSP_IO_PORT_01_PIN_02 which is built in LED on the Arduino R4 board.
My clock configuration is set to HOCO 48MHz
It would be great if there was a way to select the Arduino R4 board in e2 Studio.
Has anybody else tried this?
Thanks
Hi emklaus,
Sorry about that we cannot select R4 board in FSP, but I think you select the right mcu type of R4 board.
Could you show more detail about your project? Like the pins stack, to make sure that you set the P01_02 as output mode.
Hi; After a great deal of experimentation I have finally got something working.I found some of the FSP related files that the Arduino IDE installs to support the R4 board.Tried using the linker scripts fsp.ld and memory_regions.ld that Arduino IDE uses (which generated tons of error & warning messages) like a missing library libfsp.a and other incorrect values.Eventually with LOTs of tweaks and modifications I'm now able to compile and execute code on the R4 using e2 studio.I'm sorry to admit that my knowledge of linker scripts is minimal but I'm guessing the Arduino people have loaded a bootloader on the microcontroller so the executable code needs to be loaded to a different address.There's also some properties in the configuration.xml file that needed to be adjusted manually as I couldn't find a way in the e2 Studio configuration IDE that set them (config.bsp.common.heap, config.bsp.common.main_osc_populated and config.bsp.common.subclock_populated).The good news in now I can simply copy my "Blinky" project with all the adjustments, and use the copy as a starting point for further development.
I'm happy to share the details of the necessary adjustment with this group but don't seea way to upload a document or any files. Thanks AgainEric
Hi Eric, just so you know, you set those values in the configuration.xml file by using the configuration editor/BSP tab in e2studios. You should never need to manually edit configuration.xml ;)
Thanks Dale;Since I'm new to e2 Studio I somehow managed to entirely miss the "Properties" tab beneath the FSP configuration window. This explained a lot of what I was missing.
After a couple more days of messing around I reduced the project modifications to adding a singleline to memory_regions.ld "FLASH_IMAGE_START = 0x4000;"Of course that file gets re-built with each build so a couple more mods were necessary.
So I now have my LED blinking and have a very basic UART running. (no interrupts will fire)On to trying to figure out why interrupts will not work.Tried a simple 1 second GPT example and I can see the counter running but never get an invocation of the overflow interrupt. Same for the UART. I can send & receive character but none of the interrupts are working.
Thanks AgainEric
UPDATE 1/11.2024As mentioned in a reply below, After a couple more days of messing around I reduced the project modifications to adding a singleline to memory_regions.ld "FLASH_IMAGE_START = 0x4000;"Of course that file gets re-built with each build so a couple more tweaks were necessary.
So I now have my LED blinking and have a very basic UART running. (no interrupts will fire)On to trying to figure out why interrupts will not work....Tried a simple 1 second GPT0 example and I can see the counter running but never get an invocation of the overflow interrupt. Same for the UART. I can send & receive character but none of the interrupts are working.Here's what I've tried...Since I have UART working I can explore and verify some settings once GPT0 is opened and running.I can see the counter is running and it's resetting at some point (overflow?).Added a global counter variable in the GPT0 callback and it's NOT getting incremented.added the same counter to gpt_counter_overflow_isr() still no change.
I've added code to watch the overflow flag TCFP0 and it is getting set after what seems like the appropriate time (0.5sec)I've read the contents of R_ICU->IELSR[GPT0_COUNTER_OVERFLOW_IRQn] and it contains the appropriate 0x5D.
I got the location of the vector table from SCB->VTOR and found the address of gpt_counter_overflow_isr() in what appears to be the correct offset. Since GPT0 is using IRQ4 and I found the address of the isr at 0x4050 (remember flash now starts at 0x4000) On the Arduino R4 board, I'm assuming the flash start needs to move because of the Arduino bootloader loaded on the chip.I'm also guessing the bootloader, if not detecting bootloader activity, re-locates the vector table pointer and stack (and what else???)Then jumps to the (new) reset vector to launch the code. (thus my LED blinks) Tonight I modified my project to add support for a GPIO pin external interrupt using yet another counter variable in it's callback.Nothing happening there either when I short the I/O pin to GND. Other code verifies the I/O level change.
I don't own a debugger so all this is done using print statements.Anybody out there have additional suggestions??? (other than "buy a J-Link")ThanksEric
Eric, it will be difficult debugging without a debugger. There are other options than the rather-expensive Jlink, like the E2-lite. https://www.digikey.com/en/products/detail/renesas-electronics-corporation/RTE0T0002LKCE00000R/6193684
I am not familiar with the board you're using. I assume it has a 10-pin emulator connector.
As for the timer, you have to call both the open and enable API functions.
Dale.
Thanks for the response Dale;Per your suggestion I added a call to R_GPT_Enable() but still no interrupts.
BUT I'm very excited to have found a solution !!! (it came to me while lying in bed awake at 3:30am ).
A call the arm function __enable_irq(); did the trick!! (yay!!!)I'm guessing the Arduino bootloder turns control over to the user's code with interrupts disabled.
Update 2/5/2024
Anybody interested can read about my experience with this here:https://sites.google.com/site/ericmklaus/projects-1/arduino-r4-wifi
Complete with setup instructions and sample projects.CheersEric