771 views|1 replies

2870

Posts

4

Resources
The OP
 

【Renesas RA6E2 Evaluation Board】EXIT Interrupt Test [Copy link]

The ordinary GPIO input of Renesas RA6E2 MCU can use interrupts, but the condition of these interrupts is falling edge trigger, and the pins are usually weakly pulled down, so even if the GPIO is not processed externally, it can be used. The advantage of this design is that it increases anti-interference, unlike some microcontrollers whose GPIO is in high impedance state when in input mode, so it needs to be processed when input. This design may vary from person to person, but I personally think it is better.

Here is the test process:

1. Create the project exit_FSP_Project and select the FPB_RA6E2 development board keil project

2. Confirm that the pin of P304 is set to IRQ9

3. Add input external stack

4. Change the default channel 0 to channel 9 5. Add uart settings to ensure that the pins are P411 and P410, otherwise the jtag virtual serial port cannot be used. Other defaults, the callback function is user_uart_callback

6. After the settings are completed, generate the code and open the Keil project

7. Add code to hal_entry.c file


#include "hal_data.h"

/* Macro definition */
#define CARRIAGE_ASCII            (13u)     /* Carriage return */
#define ZERO_ASCII                (48u)     /* ASCII value of zero */
#define NINE_ASCII                (57u)     /* ASCII value for nine */
#define DATA_LENGTH               (4u)      /* Expected Input Data length */
#define UART_ERROR_EVENTS         (UART_EVENT_BREAK_DETECT | UART_EVENT_ERR_OVERFLOW | UART_EVENT_ERR_FRAMING | \
                                    UART_EVENT_ERR_PARITY)    /* UART Error event bits mapped in registers */
#define RESET_VALUE               (0x00)

void R_BSP_WarmStart(bsp_warm_start_event_t event);

extern bsp_leds_t g_bsp_leds;

/* Flag for user callback */
static volatile uint8_t g_uart_event = RESET_VALUE;
static uint8_t g_temp_buffer[DATA_LENGTH] = {RESET_VALUE};
/* Counter to update g_temp_buffer index */
static volatile uint8_t g_counter_var = RESET_VALUE;
/* Flag to check whether data is received or not */
static volatile uint8_t g_data_received_flag = false;

static volatile bool g_sw_press;

/*******************************************************************************************************************//**
 * [url=home.php?mod=space&uid=159083]@brief[/url] Blinky example application
 *
 * Blinks all leds at a rate of 1 second using the software delay function provided by the BSP.
 *
 **********************************************************************************************************************/
void hal_entry (void)
{
#if BSP_TZ_SECURE_BUILD

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

	  fsp_err_t  err = FSP_SUCCESS;
	  uint32_t local_timeout = (DATA_LENGTH * UINT16_MAX);
  	unsigned char send_buff[32]="RA Keil DAC\r";
	
    /* Define the units to be used with the software delay function */
    const bsp_delay_units_t bsp_delay_units = BSP_DELAY_UNITS_MILLISECONDS;

    /* Set the blink frequency (must be <= bsp_delay_units */
    const uint32_t freq_in_hz = 2;

    /* Calculate the delay in terms of bsp_delay_units */
    const uint32_t delay = bsp_delay_units / freq_in_hz;

    /* LED type structure */
    bsp_leds_t leds = g_bsp_leds;

    /* If this board has no LEDs then trap here */
    if (0 == leds.led_count)
    {
        while (1)
        {
            ;                          // There are no LEDs on this board
        }
    }

    /* Holds level to set for pins */
    bsp_io_level_t pin_level = BSP_IO_LEVEL_LOW;

		err = R_SCI_UART_Open(&g_uart0_ctrl, &g_uart0_cfg);
    if(FSP_SUCCESS != err) __BKPT();
		
		size_t buff_len = strlen((char *)send_buff);
		
		err = R_SCI_UART_Write(&g_uart0_ctrl, send_buff, buff_len);
		if(FSP_SUCCESS != err) __BKPT();
		
		while ((UART_EVENT_TX_COMPLETE != g_uart_event) && (--local_timeout))
    {
        /* Check if any error event occurred */
        if (UART_ERROR_EVENTS == g_uart_event)
        {
            break;
        }
    }
	
		err = R_ICU_ExternalIrqOpen(&g_external_irq9_ctrl,&g_external_irq9_cfg);
		if(FSP_SUCCESS != err) __BKPT();
		
		err = R_ICU_ExternalIrqEnable(&g_external_irq9_ctrl);
		if(FSP_SUCCESS != err) __BKPT();
		
    while (1)
    {
        /* Enable access to the PFS registers. If using r_ioport module then register protection is automatically
         * handled. This code uses BSP IO functions to show how it is used.
         */
        R_BSP_PinAccessEnable();

        /* Update all board LEDs */
        for (uint32_t i = 0; i < leds.led_count; i++)
        {
            /* Get pin to toggle */
            uint32_t pin = leds.p_leds[i];

            /* Write to this pin */
            R_BSP_PinWrite((bsp_io_port_pin_t) pin, pin_level);
        }

				if(g_sw_press)
        {
							err = R_SCI_UART_Write(&g_uart0_ctrl, send_buff, buff_len);
							if(FSP_SUCCESS != err) __BKPT();
		
							while ((UART_EVENT_TX_COMPLETE != g_uart_event) && (--local_timeout))
							{
									/* Check if any error event occurred */
									if (UART_ERROR_EVENTS == g_uart_event)
									{
											break;
									}
							}
							g_sw_press = false;	
				}
				
        /* Protect PFS registers */
        R_BSP_PinAccessDisable();

        /* Toggle level for next write */
        if (BSP_IO_LEVEL_LOW == pin_level)
        {
            pin_level = BSP_IO_LEVEL_HIGH;
        }
        else
        {
            pin_level = BSP_IO_LEVEL_LOW;
        }

        /* Delay */
        R_BSP_SoftwareDelay(delay, bsp_delay_units);
    }
}

/*******************************************************************************************************************//**
 * This function is called at various points during the startup process.  This implementation uses the event that is
 * called right before main() to set up the pins.
 *
 * @param[in]  event    Where at in the start up process the code is currently at
 **********************************************************************************************************************/
void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
    if (BSP_WARM_START_RESET == event)
    {
#if BSP_FEATURE_FLASH_LP_VERSION != 0

        /* Enable reading from data flash. */
        R_FACI_LP->DFLCTL = 1U;

        /* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
         * C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
#endif
    }

    if (BSP_WARM_START_POST_C == event)
    {
        /* C runtime environment and system clocks are setup. */

        /* Configure pins. */
        R_IOPORT_Open(&g_ioport_ctrl, g_ioport.p_cfg);
    }
}

void user_irq_callback(external_irq_callback_args_t * p_args)
{

		if(p_args->channel == 9)
    {
			g_sw_press = true;
		}
}


void user_uart_callback(uart_callback_args_t * p_args)
{

/* Logged the event in global variable */
    g_uart_event = (uint8_t)p_args->event;

    /* Reset g_temp_buffer index if it exceeds than buffer size */
    if(DATA_LENGTH == g_counter_var)
    {
        g_counter_var = RESET_VALUE;
    }

    if(UART_EVENT_RX_CHAR == p_args->event)
    {
        switch (p_args->data)
        {
            /* If Enter is pressed by user, set flag to process the data */
            case CARRIAGE_ASCII:
            {
                g_counter_var = RESET_VALUE;
                g_data_received_flag  = true;
                break;
            }
            /* Read all data provided by user until enter button is pressed */
            default:
            {
                g_temp_buffer[g_counter_var++] = (uint8_t ) p_args->data;
                break;
            }
        }
    }
}

The program is relatively simple. When the button is pressed, g_sw_press = true; triggers the program, and then responds to the program.

8. Anti-interference test

This time I used a lighter again, and the method was the same: I kept lighting a fire above the chip. I had intended to use a better power supply test solution, but it was never completed, so I didn't test it. I kept lighting the fire, but no freeze was found.

Summary: This test went smoothly, but the ADC and DAC tests a few days ago, the settings and procedures were all based on the previous RA4E1 board test. I thought there should be no problem, but none of them went smoothly and none of them could be completed. I don’t know if there is a problem with the software settings or the hardware of the board. I suspect it is a problem with the analog circuit, that is, what is the use of this AREF, please let me know if you know.

This post is from Renesas Electronics MCUs

Latest reply

Renesas should have an anti-interference design, so just enable the filter.   Details Published on 2023-11-7 12:01

6075

Posts

6

Resources
2
 

Renesas should have an anti-interference design, so just enable the filter.

This post is from Renesas Electronics MCUs
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 

Guess Your Favourite
Just looking around
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