1471 views|2 replies

221

Posts

2

Resources
The OP
 

[National Technology N32WB031_STB development board review] GPIO flip performance test [Copy link]

N32WB03x GPIO flip performance test

Preface

In some cases, GPIO is needed to simulate some peripherals, although this will take up more MCU. In order to find out the upper limit of the MCU's GPIO flip speed, it is still necessary to test it.

Official GPIO flip project

In this directory, there is an official GPIO flip top speed project

N32WB03x_V1.3.0\5-Software Development Kit\N32WB03x_SDK_V1.3\projects\n32wb03x_EVAL\peripheral\GPIO\IOToggle_MaxFrequency

Open this project with Keil and you can see the main.c program

int main(void)
{
    /* -1- Enable GPIOx Clock (to be able to program the configuration registers) */
    RCC_EnableAPB2PeriphClk(GPIOx_CLK, ENABLE);

    /* -2- Configure GPIOx_PIN in output push-pull mode */
    GPIO_InitStruct(&GPIO_InitStructure);
    GPIO_InitStructure.Pin = GPIOx_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_HIGH;
    GPIO_InitPeripheral(GPIOx, &GPIO_InitStructure);

    /* -3- Toggle GPIOx_PIN in an infinite loop */
    while (1)
    {          
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
    }
}

After compiling and burning, use an oscilloscope to test and the flip speed is around 8Mhz. To further test the upper limit, try to put the function into RAM for execution.


What is the difference between MCU programs in Flash and RAM?

Since the resources of MCU are relatively small, the Flash of common products also supports XIP, that is, the MCU can directly fetch instructions from the Flash and execute them directly. Therefore, unlike PC, the program must be loaded into RAM before it can be run. At the same time, because the speed of many MCUs is much higher than the speed of Flash, in order to improve the execution efficiency, engineers generally use three methods (if there are other methods, please help to add them).

  1. Add ICache, add instruction buffer between the core and Flash, and speed up execution.
  2. Use part of SRAM as zero buffer and automatically load most of Flash into zero buffer when MCU starts (data synchronization between buffer and Flash is done by hardware without user intervention).
  3. Load some functions from Flash to RAM when the MCU starts up, and execute these functions in RAM.

How to specify some functions to load into RAM in Keil

  1. Click the Options for Target.. icon, and then select the Linker tab in the pop-up tab
  2. Uncheck the Use Memory Layout from Target Dialog in the upper left corner, then click the edit button next to the sct file below (see picture), then click OK to close the tab
  3. Modify the .sct file, customize a section (here we use RAMCODE), and put it in the RW_IRAM1 segment
  4. Put #pragma arm section code = "RAMCODE" before the main function and #pragma arm section after the main function.

The final content of .sct is as follows

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x01000000 0x00040000  {    ; load region size_region
  ER_IROM1 0x01000000 0x00040000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x0000C000  {  ; RW data
   *.o(RAMCODE)
   .ANY (+RW +ZI)
  }
}

The final content of the main function after modification is as follows

#pragma arm section code = "RAMCODE"
int main(void)
{
    /* -1- Enable GPIOx Clock (to be able to program the configuration registers) */
    RCC_EnableAPB2PeriphClk(GPIOx_CLK, ENABLE);

    /* -2- Configure GPIOx_PIN in output push-pull mode */
    GPIO_InitStruct(&GPIO_InitStructure);
    GPIO_InitStructure.Pin = GPIOx_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_HIGH;
    GPIO_InitPeripheral(GPIOx, &GPIO_InitStructure);

    /* -3- Toggle GPIOx_PIN in an infinite loop */
    while (1)
    {          
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
        GPIOA->POD = 1;
        GPIOA->POD = 0;
    }
}
#pragma arm section

After compiling and burning, you can see that the speed increases to 9.25MHz, which should be the maximum flip speed of the GPIO of this MCU. See the screenshot for details.

This post is from RF/Wirelessly

Latest reply

It would be more practical to assemble it directly rather than put it in memory or flash.  Details Published on 2023-5-12 19:14
 

6841

Posts

11

Resources
2
 
It would be more practical to assemble it directly rather than put it in memory or flash.
This post is from RF/Wirelessly

Comments

You can try to compile the GPIO speed. I can't write assembly.  Details Published on 2023-5-12 20:55
 
 

221

Posts

2

Resources
3
 
lugl4313820 posted on 2023-5-12 19:14 It is better to assemble directly than to put it in memory or flash.

You can try to compile the GPIO speed. I can't write assembly.

This post is from RF/Wirelessly
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Comprehensive ranking of online banks to help you choose online banking services

Online banking first tier (120 points or more): Industrial and Commercial Bank of China, China Merchants Bank   Online ...

LAN design plan

If enterprise informatization is compared to a construction project, then the construction of the enterprise network is ...

PIC series microcontroller programming basics

This book is a great help to those who want to learn PIC microcontrollers. This book is a basic tutorial book and a good ...

Home electronics teaches you a trick

1. The magnesium rod of the electric water heater should be replaced frequently. The inner tank of the electric water h ...

ST MEMS sensor official Chinese technical documentation summary (continuously updated)

Netizens who are interested in ST MEMS sensors or use sensors are welcome to gather in the "ST Sensor and Wireless Commu ...

Research on high-speed and high-precision frequency measurement based on FPGA.docx

Research on high-speed and high-precision frequency measurement based on FPGA.docx

【AT32F421 Review】+ COMP Comparator Usage

This post was last edited by dmzdmz666666 on 2021-4-30 23:33 In this chapter, I will test the internal comparator of AT ...

Start the Allwinner V853 platform GUI "Hello World!" journey in 5 minutes

Last time, I experienced the superposition effect of camera and UI on V853 development board, and realized the freedom o ...

Knowledge points about spectrum analyzer measuring RF signals

There is relatively little knowledge on the Internet about spectrum analyzers measuring RF signals. Is there any expert ...

Impact on communication signal voltage in a system where isolated CAN and non-isolated CAN devices coexist

825143 As shown above, in the vehicle system: 1. The battery supplies power to the electronic control, and the ba ...

快速回复 返回顶部 Return list