1361 views|6 replies

410

Posts

3

Resources
The OP
 

[Jihai APM32F407 Tiny Board] Porting FreeRTOS system [Copy link]

 This post was last edited by TL-LED on 2023-5-26 11:49

In this article, we will learn how to port the freeRTOS system to the development board.

1. Source code download

Source code download address: https://www.freertos.org/zh-cn-cmn-s/a00104.html

Download the latest source code

2. Add files

Add freeRTOS related files to the project created in the previous article

2.1. Copy the freeRTOS source code to the project folder

2.2. Add freeRTOS source code to the project

Add source C file to the project

Add hardware interface files to the project

Add memory management files to the project

3. Modification and Configuration Files

3.1. After adding the files in the above steps, specify the header file location

3.2 Compile Project

After the modification is completed, execute the compilation and the following error is reported. This is the configuration file, which is the file of the copy example board and needs to be modified according to the hardware of the development board.

3.3. Errors during the migration process

Error content:

Modification method:

Comment out the following function in the interrupt function

The SVC and PendSV interrupt functions have been defined in the freeRTOS system and need to be commented out in the interrupt function.

Shield the definition in the freeRTOS configuration file and use the systick interrupt function in the SDK interrupt.

Modify the following file

Compile the project again

No error is reported. The above is the process of porting freeRTOS.

4. Create a task

4.1、main.c

#include "main.h"
#include "usart.h"

#include "FreeRTOS.h"
#include "task.h"  
     
#define TASK1_PRIO      2                   
#define TASK1_STK_SIZE  128                 
static TaskHandle_t            Task1Task_Handler = NULL;  
           
#define TASK2_PRIO      3                   
#define TASK2_STK_SIZE  128                 
static TaskHandle_t            Task2Task_Handler = NULL;  
 
void start_task(void *pvParameters); 
void task1(void *pvParameters);  
void task2(void *pvParameters);

int main(void)
{
	SysTick_Init();
	init_usart(115200);
	printf("apm32f407-freeRTOS-test\r\n");
	init_led();
	led2_off();
	led3_on();

//task1
	xTaskCreate((TaskFunction_t )task1,                  
							(const char*    )"task1",                
							(uint16_t       )TASK1_STK_SIZE,         
							(void*          )NULL,                   
							(UBaseType_t    )TASK1_PRIO,             
							(TaskHandle_t*  )&Task1Task_Handler);    
	//task2
	xTaskCreate((TaskFunction_t )task2,                  
							(const char*    )"task2",                
							(uint16_t       )TASK2_STK_SIZE,        
							(void*          )NULL,                  
							(UBaseType_t    )TASK2_PRIO,             
							(TaskHandle_t*  )&Task2Task_Handler); 	
	
	vTaskStartScheduler();
  while(1);
}

//task1
void task1(void *pvParameters)
{ 
    while (1)
    {
        printf("task1 run ...\r\n");
        led2_tog();
        vTaskDelay(500);
    }
}

//task2
void task2(void *pvParameters)
{ 
    while (1)
    {	
				led3_tog();
        printf("task2 run ...\r\n");
        vTaskDelay(100);
    }
}

5. Hardware Connection

The serial port on the link strip on the board cannot be used. Use a serial port module to connect to J3 and J5.

6. Program running

6.1、Serial port output content

6.2. Run Video

320

7. Program source code

apm32f407i_freeRTOS.rar (7.78 MB, downloads: 6)
This post is from Domestic Chip Exchange

Latest reply

The good thing about cortex is that it unifies all system-related things into hardware support, making porting very convenient.   Details Published on 2023-5-29 17:48
 
 

5217

Posts

239

Resources
2
 

It looks like it went smoothly, that's awesome. Could you share the code for the successful porting?

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Comments

OK  Details Published on 2023-5-26 11:40
 
 
 

5217

Posts

239

Resources
3
 

@caizhiwei[/url] You can try this

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
 
 

410

Posts

3

Resources
4
 
nmg posted on 2023-5-26 10:04 It looks so smooth, awesome. Can you share the code of the successful transplant?

OK

This post is from Domestic Chip Exchange
 
 
 

266

Posts

0

Resources
5
 
	/** Enable USART1 RXBNE interrput */
    //USART_EnableInterrupt(TINY_COM1, USART_INT_RXBNE);
    //USART_ClearStatusFlag(TINY_COM1, USART_FLAG_RXBNE);
    //NVIC_EnableIRQRequest(TINY_COM1_IRQn,1,0);

As long as the uart interrupt configuration is added, FreeRTOS will get stuck. I wonder if the OP has encountered this before?

This post is from Domestic Chip Exchange

Comments

This has not been tested. My serial port only sends but does not receive, so the receive interrupt is blocked.  Details Published on 2023-5-28 15:46
Personal signature

gitee/casy

 
 
 

410

Posts

3

Resources
6
 
caizhiwei 发表于 2023-5-28 09:14 /** Enable USART1 RXBNE interrput */ //USART_EnableInterrupt(TINY_COM1, USART_INT_RXBNE); ...

This has not been tested. My serial port only sends but does not receive, so the receive interrupt is blocked.

This post is from Domestic Chip Exchange
 
 
 

7422

Posts

2

Resources
7
 

The good thing about cortex is that it unifies all system-related things into hardware support, making porting very convenient.

This post is from Domestic Chip Exchange
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

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