66 views|0 replies

2

Posts

0

Resources
The OP
 

【Follow me Season 2 Episode 3】Introductory Tasks---Debugging Programs, Blink and Key Testing [Copy link]

 This post was last edited by quansirx on 2024-11-16 14:28

one,

The Renesas EK-RA6M5 development board supports e2 studio, IAR, Keil MDK and other IDE tools for programming and development. I use the official e2 studio based on the Eclipse open source IDE. Since it is an official IDE tool, the development support is relatively better.

The installation of e2 studio can refer to the teacher's explanation video. The following is to debug the sample program, LED Blink, button operation, etc.

2. e2 studio debugging sample program

Download the Renesas official FSP example program from

链接已隐藏,如需查看请登录或者注册

The above is the decompressed file content. Open the e2 studio tool and import the development board quickstart routine

Right-click the project and compile it normally before starting the project debugging.

Select the third debug option

Open the plug-in terminal tool and set the parameters as shown above. The serial communication baud rate is 115200

Terminal menu options:

Press the number key 1 on the keyboard to get a list of basic information about the development board.

QSPI, OSPI Flash read and write speed test

3. Blink, button test

3.1LEDBlink

Create a new e2 studio basic FSP project

TrustZone Settings

Screen clip captured at: 2024-11-16 12:38

No RTOS

Click to create a minimum basic project

Overview of basic engineering structure

Onboard LED schematic

Find the pin connection of the onboard LED in the schematic diagram. LED1 is connected to pin P006.

Open the configuration xml file

Select the Pins column and enter the pin number P006 to automatically locate the pin configuration interface

The onboard LED1 is connected in common cathode mode, so P006 is set to output high level by default.

Initialization code for P001 pin configuration

Burn the firmware to the development board

LED1 lights up successfully

Add the LED lighting code in a loop, in the hal_entry function

void hal_entry(void)
{
    /* TODO: add your own code here */

    while(1){

        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_06, BSP_IO_LEVEL_HIGH); //LED1亮
        R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS); //延时500ms

        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_06, BSP_IO_LEVEL_LOW); //LED1灭亮
        R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS); //延时500ms

    }

#if BSP_TZ_SECURE_BUILD
    /* Enter non-secure code */
    R_BSP_NonSecureEnter();
#endif
}

Experimental results

3.2 Key Test

View button schematic

Button 2 is connected to the P004 pin. The pin state is pulled up by default. The pin level is low after the button is pressed.

XML configuration

Example code

void hal_entry(void)
{
    /* TODO: add your own code here */
    uint8_t t=150;
    while(1){

        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_06, BSP_IO_LEVEL_HIGH); //LED3亮
        R_BSP_SoftwareDelay(t, BSP_DELAY_UNITS_MILLISECONDS); //延时500ms

        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_06, BSP_IO_LEVEL_LOW); //LED1灭亮
        R_BSP_SoftwareDelay(t, BSP_DELAY_UNITS_MILLISECONDS); //延时500ms

        KeyScan(BSP_IO_PORT_00_PIN_04);
    }

#if BSP_TZ_SECURE_BUILD
    /* Enter non-secure code */
    R_BSP_NonSecureEnter();
#endif
}
void KeyScan(bsp_io_port_pin_t key);

void KeyScan(bsp_io_port_pin_t key){
    bsp_io_level_t key_state;

    R_IOPORT_PinRead(&g_ioport_ctrl, key, &key_state);

    if(key_state==BSP_IO_LEVEL_LOW){
        //软件消抖
        R_BSP_SoftwareDelay(10, BSP_DELAY_UNITS_MILLISECONDS);
        //点亮LED2
        R_IOPORT_PinWrite(&g_ioport_ctrl, LED2, BSP_IO_LEVEL_HIGH); //LED2亮
        //等待按键松开
        while(key_state==BSP_IO_LEVEL_LOW){
            R_IOPORT_PinRead(&g_ioport_ctrl, key, &key_state);
        }
        //熄灭LED2
        R_IOPORT_PinWrite(&g_ioport_ctrl, LED2, BSP_IO_LEVEL_LOW); //LED2灭
    }

}

Keystroke Experiment Results

This post is from DigiKey Technology Zone
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list