我正在使用STM32F4E11发现板和Keil uVision 5。 项目的想法是湿度传感器提供数据。水泵(DC 12 V电机)和两个七段显示器,两档接收数据。显示屏显示湿度百分比,泵根据收到的数据与pwm一起工作。
当我编译我的代码时它会告诉我: Završni_2\Završni_2.axf:错误:L6002U:无法打开文件zavr?ni_2 \ event_groups.o:没有这样的文件或目录
这是我的代码。请帮助我。
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f4xx_hal.h"
#include "cmsis_os.h"
/*Defines(shift register)---------------------------------------------------------------------------------*/
/*Latch on*/
#define STCP_RESET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_9, GPIO_PIN_RESET);
/*Latch off*/
#define STCP_SET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_9, GPIO_PIN_SET);
/*Clock on*/
#define SHCP_RESET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_RESET);
/*Clock off*/
#define SHCP_SET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_SET);
/*No data*/
#define DS_RESET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_RESET);
/*Data in*/
#define DS_SET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_SET);
/*Defines(display digits)---------------------------------------------------------------------------------*/
/*First difit off*/
#define ONE_RESET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_RESET);
/*First digit on*/
#define ONE_SET HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET);
/*Second digit on*/
#define TWO_RESET HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_RESET);
/*Second digit off*/
#define TWO_SET HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_SET);
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim4;
osThreadId ONHandle;
osThreadId OFFHandle;
osThreadId VlagaHandle;
osThreadId PumpaHandle;
osThreadId DisplayHandle;
osThreadId SEMHandle;
QueueHandle_t xQueue;
SemaphoreHandle_t xBinarySemaphore;
long VLA=0;
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_TIM4_Init(void);
static void MX_TIM2_Init(void);
static void MX_ADC1_Init(void);
void StartON(void const * argument);
void StartOFF(void const * argument);
void StartVlaga(void const * argument);
void StartPumpa(void const * argument);
void SegOFF(void);
void DigitDisplay(long);
void StartDisplay(void const * argument);
void StartSEM(void const * argument);
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM4_Init();
MX_TIM2_Init();
MX_ADC1_Init();
/* definition and creation of tasks */
osThreadDef(ON, StartON, osPriorityRealtime, 0, 128);
ONHandle = osThreadCreate(osThread(ON), NULL);
osThreadDef(OFF, StartOFF, osPriorityRealtime, 0, 128);
OFFHandle = osThreadCreate(osThread(OFF), NULL);
osThreadDef(Vlaga, StartVlaga, osPriorityRealtime, 0, 128);
VlagaHandle = osThreadCreate(osThread(Vlaga), NULL);
osThreadDef(Pumpa, StartPumpa, osPriorityRealtime, 0, 128);
PumpaHandle = osThreadCreate(osThread(Pumpa), NULL);
osThreadDef(Display, StartDisplay, osPriorityRealtime, 0, 128);
DisplayHandle = osThreadCreate(osThread(Display), NULL);
osThreadDef(SEM, StartSEM, osPriorityRealtime, 0, 128);
SEMHandle = osThreadCreate(osThread(SEM), NULL);
/*Suspending tasks*/
vTaskSuspend(ONHandle);
vTaskSuspend(VlagaHandle);
vTaskSuspend(PumpaHandle);
vTaskSuspend(DisplayHandle);
/*definition and creation of Queue*/
xQueue=xQueueCreate(1,sizeof(long));
/*definition and creation of Binary Semaphore*/
xBinarySemaphore=xSemaphoreCreateBinary();
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
}
}
/* StartON function */
void StartON(void const * argument)
{
for(;;)
{
/*Blinking green led as indicator that system is ON*/
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_12);
osDelay(250);
}
}
/* StartOFF function */
void StartOFF(void const * argument)
{
/*Infinite loop*/
for(;;)
{
/*Blinking red led as indicator that system is OFF*/
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_14);
}
}
/* StartDisplay function */
void StartDisplay(void const * argument)
{
long rx=0;
short flag=0;
for(;;){
/*Receiving data from a queue*/
if(xQueueReceive(xQueue,&rx,10)){
SegOFF();
osDelay(400);
flag=1;
}
long ones=rx%10;
long tens=(rx%100)/10;
if(flag) {
/*Displaying first digit*/
ONE_RESET;TWO_SET;
DigitDisplay(ones);
/*Displaying second digit*/
ONE_SET;TWO_RESET;
DigitDisplay(tens);
}
}
}
/* StartVlaga function*/
void StartVlaga(void const * argument)
{
/* Infinite loop */
for(;;){
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1,1000);
VLA=HAL_ADC_GetValue(&hadc1);
VLA=(VLA/4091)*100;
xQueueSendToBack(xQueue,&VLA,10);
/*Resuming tasks*/
vTaskResume(DisplayHandle);
vTaskResume(PumpaHandle);
vTaskSuspend(NULL);
osDelay(2000);
}
}/*StartPumpa function*/
void StartPumpa(void const * argument){
long Value=0;
/* Infinite loop */
for(;;){
/*Reciving vlaga to a queue*/
xQueueReceive(xQueue,&Value,10);
HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_1);
if(Value<25)
{htim4.Instance->CCR1=75;
}
if (Value<50)
{htim4.Instance->CCR1=50;
}
if(Value<75)
{htim4.Instance->CCR1=25;
}
vTaskResume(VlagaHandle);
vTaskSuspend(NULL);
}
}
/* StartSEM function */
void StartSEM(void const * argument)
{
short button=0;
/*Infinite loop*/
for(;;){
/*Checking if interrupt occured*/
if(xSemaphoreTake(xBinarySemaphore, portMAX_DELAY )) {
button++;
if (button==1){
/*If button is pressed only pump is working on 50 % */
osDelay(2000);
vTaskSuspend(VlagaHandle);
vTaskSuspend(PumpaHandle);
vTaskSuspend(DisplayHandle);
SegOFF();
vTaskSuspend(ONHandle);
HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_1);
htim4.Instance->CCR1=50;
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_RESET);
vTaskResume(OFFHandle);
}
else if(button==2){
/*when button is pressed second time its start all again*/
vTaskSuspend(OFFHandle);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_RESET);
vTaskResume(ONHandle);
vTaskResume(VlagaHandle);
button=0;
}
}
}
}
/*This function handles EXTI line0 interrupt*/
void EXTI0_IRQHandler(void)
{
for(uint32_t z=0;z<10000000;z++);
xSemaphoreGiveFromISR(xBinarySemaphore, NULL);
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
}
/*Function for putting data in shift register*/
void DigitDisplay(long digit)
{
short i=0;
long field[8][10]= {{1, 0, 1, 1, 0, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 1, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 1, 0, 0, 1, 1, 1},
{0, 0, 1, 1, 1, 1, 1, 0, 1, 1},
{1, 1, 0, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 1, 1, 0, 1, 1, 0, 1, 1},
{1, 0, 1, 0, 0, 0, 1, 0, 1, 0} };
/*Latch off*/
STCP_RESET;
for(i=0;i<8;i++){
/*Clock off*/
SHCP_RESET;
if(field[i][digit] ){
/*Shifting 1*/
DS_SET;
}
else{
/*Shifting 0*/
DS_RESET;
}
/*Clock on*/
SHCP_SET;
}
/*Latch on*/
STCP_SET;
/*Delay*/
osDelay(1);
}
void SegOFF(void)
{
ONE_SET;TWO_SET;
long x=0;
/*Latch off*/
STCP_RESET;
for(x=0;x<8;x++){
/*Clock off*/
SHCP_RESET
/*Shifting 0*/
DS_RESET;
/*Clock on*/
SHCP_SET;
}
/*Latch on*/
STCP_SET;
}
/** System Clock Configuration
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
/**Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 84;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 8;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure the Systick interrupt time
*/
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
/**Configure the Systick
*/
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0);
}
/* ADC1 init function */
static void MX_ADC1_Init(void)
{
ADC_ChannelConfTypeDef sConfig;
/**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.ScanConvMode = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
*/
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
/* TIM2 init function */
static void MX_TIM2_Init(void)
{
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
htim2.Instance = TIM2;
htim2.Init.Prescaler = 0;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 0;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
/* TIM4 init function */
static void MX_TIM4_Init(void)
{
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
TIM_OC_InitTypeDef sConfigOC;
htim4.Instance = TIM4;
htim4.Init.Prescaler = 83;
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
htim4.Init.Period = 99;
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
if (HAL_TIM_PWM_Init(&htim4) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
HAL_TIM_MspPostInit(&htim4);
}
/** Configure pins as
* Analog
* Input
* Output
* EVENT_OUT
* EXTI
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11, GPIO_PIN_RESET);
/*Configure GPIO pin : PC13 */
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pin : PA0 */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PB14 PB15 */
GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : PD8 PD9 PD10 PD11 */
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/* StartDefaultTask function */
void StartDefaultTask(void const * argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END 5 */
}
/**
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM1 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base.
* @param htim : TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
if (htim->Instance == TIM1) {
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
/* USER CODE END Callback 1 */
}
/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
void _Error_Handler(char * file, int line)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
while(1)
{
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
答案 0 :(得分:0)
看起来编译器不喜欢特殊字符。尝试将项目及其所有文件存储在仅包含拉丁字符的路径中(并且确保没有空格)。