1272 views|2 replies

410

Posts

3

Resources
The OP
 

【CW32L052 Review】 Porting rt-thread nano [Copy link]

 

In this article, we will learn how to port the rt-thread nano system to the CW32L052 development board.

1. Create rt-thread nano project

The project adds rt-thread nano file based on the previous https://bbs.eeworld.com.cn/thread-1250118-1-1.html project

1.1. Add source files

There are two ways to add source files. One is to download the source files from the rt-thead official website and add them manually. The other is to install the IDE and the MDK software pack. Here we use the pack installation method.

Download the rt-thread package

Add kernel source files to the project

Added project files

1.2. Modify the file

1.2.1、Shield the PendSV_Handler function

1.2.2. Shield the HardFault_Handler function

1.2.3. Shield the SysTick_Handler function

1.2.4. Modify the memory stack space RT_HEAP_SIZE

The internal RAM of CW32L050 is 8K, modify it here.

1.2.5. Add hardware initialization and SysTick_Handler function

1.3 Test Procedure

Modify the main.c main program

#include "main.h"
#include "rtthread.h"

void rcc_config(void)
{
	uint8_t res = 0U;
	RCC_AHBPeriphClk_Enable(RCC_AHB_PERIPH_FLASH, ENABLE);
	RCC_LSI_Enable( );                                                   //开启外部高速时钟LSI
	res = RCC_SysClk_Switch( RCC_SYSCLKSRC_LSI );                        //切换系统时钟到LSI
	if( res == 0x00 )                                                    //系统时钟切换成功
	{
			RCC_HSI_Disable();                                               //切换时钟到PLL后关闭源时钟HSI
			FirmwareDelay( 400 );   //about 100mS
	}
	
	RCC_HSI_Enable( RCC_HSIOSC_DIV1 );                                   //开启内部高速时钟HSI = HSIOSC / 2
	FLASH_SetLatency(FLASH_Latency_3); 
	res = RCC_SysClk_Switch( RCC_SYSCLKSRC_HSI );                        //切换系统时钟到HSI
	if( res == 0x00 )                                                    //系统时钟切换成功
	{
			RCC_LSI_Disable();                                               //切换时钟到HSI后关闭LSI时钟
			FirmwareDelay( 275000 );  //about 100mS
	}
	
	RCC_HCLKPRS_Config(RCC_HCLK_DIV1);
	
	RCC_HCLK_OUT();                           //通过PA04观察HCLK频率
}

int32_t main(void)
{
    while (1)
    {
      led2_tog();
			rt_thread_mdelay(100);
    }
}

2. Program operation

After the modification is completed, compile, download, and power on and reset the development board. The running video is as follows:

cw32

3. Attachments

Source code: cw32l052_rt-thread_nano_20230719.rar (950.65 KB, downloads: 3)
This post is from Domestic Chip Exchange

Latest reply

The installation of MDK software pack is not complicated. Why do we need to block the PendSV_Handler function before modifying the file?   Details Published on 2023-7-19 22:56
 
 

1668

Posts

0

Resources
2
 

The installation of MDK software pack is not complicated.

Why do we need to block the PendSV_Handler function before modifying the file?

This post is from Domestic Chip Exchange

Comments

rt-thread nano The system comes with this function, and you need to disable the default function when creating a project  Details Published on 2023-7-20 06:36
 
 
 

410

Posts

3

Resources
3
 
Hot Ximi Show posted on 2023-7-19 22:56 The installation of MDK software pack is not complicated. Why should the PendSV_Handler function be blocked before modifying the file?

rt-thread nano The system comes with this function, and you need to disable the default function when creating a project

This post is from Domestic Chip Exchange
 
 
 

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