Using STM32 to run UCOS, I wrote a very simple program and compiled it as follows
Program Size: Code=24562 RO-data=746 RW-data=88 ZI-data=7456
Based on this calculation, if the FLASH is less than 24K and the RAM is less than 8K, then the UCOS of STM32 cannot be considered at all, and it can only be run bare.
The FLASH of STM32 is relatively satisfactory, generally 64K, mainly RAM. It seems that there is not much hope for STM32F0XX STM32F100
----------------------The following is main.c-----------------------
#define MAIN_C
#include "includes.h"
void
first_task(void *pdata);
void task_2(void *pdata);
void task_3(void
*pdata);
int main()
{
RCC_ClocksTypeDef OS_Clocks;
bsp_Ini(); //Initialize each driver, put in bsp_ini.c
OSInit(); //ucos system initialization
RCC_GetClocksFreq(&OS_Clocks);
OS_CPU_SysTickInit( OS_Clocks.HCLK_Frequency / OS_TICKS_PER_SEC ); //Set clock tick, 1ms
OSTaskCreate(first_task,0,&stk1[99],task1_sn); //Create the first task
OSStart(); //Task start
}
void first_task(void *pdata) //Create other tasks in the first task (official recommendation)
{
INT8U err;
int AD_value;
pdata=pdata;
flag1=OSFlagCreate(0,&err);
OSTaskCreate(task_2,0,&stk2[99],task2_sn);
OSTaskCreate(task_3,0,&stk3[99],task3_sn);
while(1)
{
AD_value=(int)
( (double) ADC_GetConversionValue(ADC1) *3/4096 * 100 )
;
DEBUG_COM_STREAM("\r\nAD=%L",(u8*)&AD_value);//USART_SendData(USART1,
test);
OSTimeDly(1000);
}
}
void task_2(void *pdata) //Create other tasks in the first task (official recommendation)
{
INT8U err1;
char test;
pdata=pdata;
while(1)
{
OSFlagPend(flag1,EVENT_1,OS_FLAG_WAIT_SET_ALL+OS_FLAG_CONSUME,0,&err1);
test = (char)USART_Date;
DEBUG_COM_STREAM("\r\nReceived:%c",(u8*)&test);//USART_SendData(USART1, test);
DAC_SetChannel1Data(DAC_Align_12b_R, test*16);
}
}
u8 count;
void task_3(void *pdata) //Create other tasks in the first task (official recommendation)
{
pdata=pdata;
GPIO_INITIAL();
EXTI_INITIAL(ENABLE);
while(1)
{
OSTimeDly(1000);
count++;
if(count==3000)
{PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
RCC_Ini();//bsp_Ini();
count=0;
}
else if(wake_id!=0)
{DEBUG_COM_STREAM("wake_id=%x",(u8*)&wake_id);
wake_id=0;
}
DEBUG_COM_STREAM(" I am task 3=%x",&count);
}
}
Previous article:STM32 HSE LSE crystal oscillator official recommendation
Next article:Finally, I can summarize the STM32 low power consumption
Recommended ReadingLatest update time:2024-11-16 13:55
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Application of RFID and other Internet of Things technologies in smart ranches
- EEWORLD University Hall ---- Engineering Test Technology Foundation Huazhong University of Science and Technology
- Looking for national standards? Here is the national standards website, which will definitely be useful to you!
- How to achieve automated testing of LCR?
- Which company can make PCB boards with a width of about 2MM?
- How to speed up the program running speed of Huada HC32F460 HC32F4A0?
- FPDLINK Spark Interference Optimization
- Why do electrolytic capacitors explode? Find out in one article!
- A brief history of hard disk interface evolution
- Hot plug and unplug