Monday, June 25, 2018

Led Blinking Example


Today we try to write a small program on DK-S7G2 development kit. There are two bicolor LED's(Green and Red) comprising four LED's (LED1- Green and Red, LED2 - Green and Red). Before going into deep, I suggest you to download DK-S7G2 user manual.
Open the development kit user manual and go to Connectivity chapter ->User Led's section. You can see the GPIO connections to each LED. Please see the below table for corresponding GPIO connections
Pin
Description
GPIO
LED1
Green
P807(p8_7)
LED1
Red
P808(p8_8)
LED2
Green
P809(p8_9)
LED2
Red
P810(p8_10)

Follow the below steps to start a project.
1. Download and install E2Studio 6.2.0
2. Open E2Studio and create a workspace.
3. After that goto File->New->Synergy C/C++ Project

4. A window will open and Select Renesas Synergy C executable project and click Next


5. In the project name field give the project name(Example LedBlink) click next, you will see the below screen, check the details and development kit details should match your board and device. Click Next


6. Select BSP and click Finish and now your project is created with hal_entry.c source file.
7. If you are using BSP package the LED pins are already muxed to GPIO and you no need to do basic GPIO settings you can directly use the BSP functions to turn on and off the LED. All the GPIO details are present in r_ioport_api.h file.
8. If you want to Turn on the green LED1 give this below line in hal_entry.c file main() function.
void hal_entry(void)
{
    /* TODO: add your own code here */
    while(1)
    {
    
        g_ioport.p_api->pinWrite(IOPORT_PORT_08_PIN_07, IOPORT_LEVEL_HIGH);

    }
}
Now you have able to turn on the LED. We will see how to blink the LED(periodic Turn On and OFF). We don't know the exact delay in the for loop so the below code you won't be able to see the blinking effect as it happens very fast.
void hal_entry(void)
{
    /* TODO: add your own code here */
    while(1)
    {

       for (i = 0; i < 0x100E6; i++)
            g_ioport.p_api->pinWrite(IOPORT_PORT_08_PIN_07,                                                       IOPORT_LEVEL_LOW);
       for ( i = 0; i < 0x100E6; i++)
            g_ioport.p_api->pinWrite(IOPORT_PORT_08_PIN_07,                                                       IOPORT_LEVEL_HIGH);

    }
}
Now we will see the actual delay implementation say like 1 Sec delay between each On and OFF operation so that you can see LED is really blinking .
void hal_entry(void)
{
    /* TODO: add your own code here */
    while(1)
    {

        g_ioport.p_api->pinWrite(IOPORT_PORT_08_PIN_07, IOPORT_LEVEL_LOW);
        R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_SECONDS);
        g_ioport.p_api->pinWrite(IOPORT_PORT_08_PIN_07, IOPORT_LEVEL_HIGH);
        R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_SECONDS);
    }
}
Now compile the code and Run the program and you will see the LED blinking.

Now see the above code , lines which I have highlighted  in red colour text. As we already said that we are going to use SSP package which contains Renesas BSP. I have used the BSP functions to give the exact 1 second delay between each ON and OFF operation.
R_BSP_SoftwareDelay(uint32_t delay, bsp_delay_units_t units)  takes two arguments. Below are the values which we can give to 2nd argument.
typedef enum
{
    BSP_DELAY_UNITS_SECONDS =1000000,  ///< Requested delay amount is in                                                            seconds
    BSP_DELAY_UNITS_MILLISECONDS = 1000,     ///< Requested delay amount is                                                         in milliseconds
    BSP_DELAY_UNITS_MICROSECONDS = 1         ///< Requested delay amount is                                             in microseconds
} bsp_delay_units_t;

In the above code in order to get 1 second delay I have given R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_SECONDS) , 1 is number of seconds and second argument is units.

Thank You

Friday, June 22, 2018

Working on Renesas Synergy

Of lately Renesas started developing Cortex-M based controller/products. Recently we started exploring MCU's from Renesas for our product development. We have got hands on experience on their RL78 G13 family controllers and felt quiet impressive.
We thought of having RTOS in every product for more responsiveness and durability of the Software. Renesas came up with their Renesas Synergy product line. The first impression after going through their marketing presentation, we were very much impressed as they offer everything to quick start your development.
I have a Renesas Synergy DK-S7G2 development board. Below is the picture of the Development kit
Image result for dk-s7g2 schematic

In the coming posts I will try to cover most of the peripherals working and sample codes.


Monday, December 18, 2017

What is Poky?

Poky is the Yocto Project reference system and is composed of collection of tools and metadata. Poky is platform-independent and performs cross-compiling, using Bitbake Tool, OpenEmbedded-Core, and a default set of metadata. The main objective of Poky is to provide all the features an embedded developer needs. It is similar to Buildroot which is used to cross compile Kernel or to create RFS for different architectures such as ARM, x86, PowerPC etc. 
Below is the pictorial representation of relationship of Poky, Bitbake, OpenEmbedded-Core
BitBake: 
BitBake was originally a part of the OpenEmbedded project. BitBake is a generic task execution engine that allows shell and Python tasks to be run efficiently and in parallel while working within complex inter-task dependency constraints.

MetaData: 
Metadata is stored in recipe (.bb), configuration (.conf), and class (.bbclass) files and provides BitBake with instructions on what tasks to run and the dependencies between those tasks.

OpenEmbedded-Core: 
Also called as OE-Core,  is a base layer of recipes, classes and associated files that is meant to be common among many different OpenEmbedded-derived systems and forms the basis of the new structure for OpenEmbedded. 

What is Yocto??


The Yocto  project  is an Embedded Linux distribution builder that makes use of several other open source projects.
The Yocto project provides a reference build system for embedded Linux called Poky,  which has the Bitbake  and Openembedded-Core (OE-Core)  projects.  The purpose of Poky is to build the components needed for an embedded Linux product
> A Bootloader Image
> A Linux Kernel Image
> A rootfile system (RFS) image
> Toolchains and software development kits for application development.

From these observations we can say that Yocto project covers the needs of both system and application developers.

In the next post we will get in details like what is Poky , OpenEmbedded-Core and how to get start with these tools.