Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Follow+Star Public Account Number, don’t miss wonderful content

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Author | strongerHuang

WeChat Official Account | strongerHuang
Cortex-M is an ARM core designed for MCU, launched about 20 years ago, and the most classic is the Cortex-M3 core, which is one of the most widely used cores on the market today.
Currently (2024-09), the latest and most powerful microcontroller core is Cortex-M85.
https://www.arm.com/zh-TW/product-filter?families=cortex-m

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Cortex-M85 has upgraded many functions compared to the Cortex-M3 core, making it more powerful.
So, as an ordinary user (developer), what are the differences in usingCortex-M85 andCortex-M3 core microcontrollers?

cm3.h and cm85.h

Microcontroller developers are most familiar with the core_cm3.h (core_cm85.h) files, which define most of the content related to the core, and we often call interfaces from here.
Let’s compare these two source files:

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

By comparing the source code, you will intuitively find that cm85 has significantly more lines than cm3, with 1943 lines and 4672 lines respectively. Of course, with so many more lines, the left side red (differences) part is also relatively large.

Although there are more left-side “red” parts, most of them are additional lines and macro definitions. Upon careful comparison, many are actually the same, such as the commonly used system reset function:

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void){  __DSB();                                                          /* Ensure all outstanding memory accesses included                                                                       buffered write are completed before reset */  SCB->AIRCR  = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos)    |                           (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |                            SCB_AIRCR_SYSRESETREQ_Msk    );         /* Keep priority group unchanged */  __DSB();                                                          /* Ensure completion of memory access */  for(;;)                                                           /* wait until reset */  {    __NOP();  }}
For example, the system Tick configuration function:

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks){  if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)  {    return (1UL);                                                   /* Reload value impossible */  }  SysTick->LOAD  = (uint32_t)(ticks - 1UL);                         /* set reload register */  NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */  SysTick->VAL   = 0UL;                                             /* Load the SysTick Counter Value */  SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |                   SysTick_CTRL_TICKINT_Msk   |                   SysTick_CTRL_ENABLE_Msk;                         /* Enable SysTick IRQ and SysTick Timer */  return (0UL);                                                     /* Function successful */}
In fact, you will find that the function interfaces commonly used on the Cortex-M3 microcontroller are basically the same as those on the CM85, which also indicates that most interfaces of CM85 are backward compatible with CM3.

Cortex-M85 Microcontroller SysTick

A timer is a commonly used module in microcontrollers, whether for delays or RTOS heartbeat (system clock), a timer will be used. Therefore, Arm considers this situation, integrating a SysTick module into every Cortex-M core.
Here, I will explain the usage of SysTick with the Renesas RA8D1 (Cortex-M85 core) microcontroller.
Using e2 studio and fsp software package
The software package that comes with the tool is actually the most practical. Here, I will take IO flipping and SysTick delay as examples, teaching you step by step how to create a project and demonstrate the effect.
1. Open e2 studio to create a microcontroller project
Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers
Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers
We named the project: RA8D1_SysTick

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Select the corresponding chip model: R7FA8D1BEC

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers
Basically, you only need to click a few buttons, and a complete project is created.
2. Configure the project
Here, we configure some basic information, using an IO (PA01) to test the SysTick delay time.

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Configure the clock tree:

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Configure the output Hex file:

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

3. Demonstration
This is just a simple demonstration demo, we add an IO flip to test SysTick delay time.
while(1){    R_PORT10->PODR ^= 1<<(BSP_IO_PORT_10_PIN_01 & 0xFF);     //PA01 toggle    R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_MILLISECONDS);    //SysTick delay}

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

This is a 1ms toggle, and the SysTick delay error is relatively small, the error can be ignored compared to 1ms.

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

The sampling frequency is 100MHz, and you can still see some error. Of course, this error is influenced by various factors such as the crystal oscillator and software. Also, the us-level error can be ignored relative to ms.

Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers

If changed to 1us toggle, testing through IO flip, the error becomes relatively noticeable.
4. Source Code Description
Experienced engineers should be able to understand this, but here is a simple explanation for beginners.
R_PORT10->PODR ^= 1<<(BSP_IO_PORT_10_PIN_01 & 0xFF);
To reduce the error caused by software, here we directly manipulate the register for IO flipping.
R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_MILLISECONDS);
R_BSP_SoftwareDelay: a blocking delay function, is a function interface provided by the FSP software package.
BSP_DELAY_UNITS_MILLISECONDS: macro definition, delay unit (milliseconds).
The system defines three macros:
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;
R_BSP_SoftwareDelay: actually utilizes SysTick for delay.
Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers
Further analyzing the code, you can see that the lower-level calls to SysTick are the same for CM0, CM23, etc. Therefore, you will find that there is not much difference in the usage of SysTick between Cortex-M3 and M85 microcontrollers.
———— END ————
Differences in SysTick Usage Between Cortex-M3 and M85 Microcontrollers
Renesas RA8 Series Tutorial | Introduction to Renesas RA8 Series Microcontrollers
●Renesas RA8 Series Tutorial | Setting up the Renesas RA8 Development Environment
●Renesas RA8 Series Tutorial | Developing RA8 Microcontroller Based on Keil
Renesas RA8 Series Tutorial | Implementing RA8 Serial Output Configuration Based on e2s
Follow the public accountReply “Join Group” to join the technical exchange group according to the rules, reply “1024” to see more content.
Click “Read the Original” to see more shares.

Leave a Comment

Your email address will not be published. Required fields are marked *