commit deedcbe1f1a3b9ef45a6121cb2a796d68086554f
parent 7587fc13f8a1432a2cf5b132bab66083274a0299
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Sat, 25 Oct 2025 14:57:10 -0300
Implementation of `task_pwm_update` and `task_adc_update`
In `task_adc_update` an average of various samples are taken for the
shared variable `adc_value`
Diffstat:
10 files changed, 569 insertions(+), 551 deletions(-)
diff --git a/Core/Inc/stm32f1xx_it.h b/Core/Inc/stm32f1xx_it.h
@@ -22,7 +22,7 @@
#define __STM32F1xx_IT_H
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
/* Private includes ----------------------------------------------------------*/
diff --git a/Core/Src/main.c b/Core/Src/main.c
@@ -226,7 +226,7 @@ static void MX_TIM3_Init(void)
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim3.Init.Period = 65535;
+ htim3.Init.Period = 2048;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
@@ -295,8 +295,8 @@ static void MX_USART2_UART_Init(void)
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
-/* USER CODE BEGIN MX_GPIO_Init_1 */
-/* USER CODE END MX_GPIO_Init_1 */
+ /* USER CODE BEGIN MX_GPIO_Init_1 */
+ /* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
@@ -324,8 +324,8 @@ static void MX_GPIO_Init(void)
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
-/* USER CODE BEGIN MX_GPIO_Init_2 */
-/* USER CODE END MX_GPIO_Init_2 */
+ /* USER CODE BEGIN MX_GPIO_Init_2 */
+ /* USER CODE END MX_GPIO_Init_2 */
}
/* USER CODE BEGIN 4 */
@@ -346,8 +346,7 @@ void Error_Handler(void)
}
/* USER CODE END Error_Handler_Debug */
}
-
-#ifdef USE_FULL_ASSERT
+#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
diff --git a/Core/Src/stm32f1xx_hal_msp.c b/Core/Src/stm32f1xx_hal_msp.c
@@ -84,19 +84,19 @@ void HAL_MspInit(void)
}
/**
-* @brief ADC MSP Initialization
-* This function configures the hardware resources used in this example
-* @param hadc: ADC handle pointer
-* @retval None
-*/
+ * @brief ADC MSP Initialization
+ * This function configures the hardware resources used in this example
+ * @param hadc: ADC handle pointer
+ * @retval None
+ */
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hadc->Instance==ADC1)
{
- /* USER CODE BEGIN ADC1_MspInit 0 */
+ /* USER CODE BEGIN ADC1_MspInit 0 */
- /* USER CODE END ADC1_MspInit 0 */
+ /* USER CODE END ADC1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_ADC1_CLK_ENABLE();
@@ -108,27 +108,27 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- /* USER CODE BEGIN ADC1_MspInit 1 */
+ /* USER CODE BEGIN ADC1_MspInit 1 */
- /* USER CODE END ADC1_MspInit 1 */
+ /* USER CODE END ADC1_MspInit 1 */
}
}
/**
-* @brief ADC MSP De-Initialization
-* This function freeze the hardware resources used in this example
-* @param hadc: ADC handle pointer
-* @retval None
-*/
+ * @brief ADC MSP De-Initialization
+ * This function freeze the hardware resources used in this example
+ * @param hadc: ADC handle pointer
+ * @retval None
+ */
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
{
if(hadc->Instance==ADC1)
{
- /* USER CODE BEGIN ADC1_MspDeInit 0 */
+ /* USER CODE BEGIN ADC1_MspDeInit 0 */
- /* USER CODE END ADC1_MspDeInit 0 */
+ /* USER CODE END ADC1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_ADC1_CLK_DISABLE();
@@ -137,31 +137,31 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0);
- /* USER CODE BEGIN ADC1_MspDeInit 1 */
+ /* USER CODE BEGIN ADC1_MspDeInit 1 */
- /* USER CODE END ADC1_MspDeInit 1 */
+ /* USER CODE END ADC1_MspDeInit 1 */
}
}
/**
-* @brief TIM_PWM MSP Initialization
-* This function configures the hardware resources used in this example
-* @param htim_pwm: TIM_PWM handle pointer
-* @retval None
-*/
+ * @brief TIM_PWM MSP Initialization
+ * This function configures the hardware resources used in this example
+ * @param htim_pwm: TIM_PWM handle pointer
+ * @retval None
+ */
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
{
if(htim_pwm->Instance==TIM3)
{
- /* USER CODE BEGIN TIM3_MspInit 0 */
+ /* USER CODE BEGIN TIM3_MspInit 0 */
- /* USER CODE END TIM3_MspInit 0 */
+ /* USER CODE END TIM3_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM3_CLK_ENABLE();
- /* USER CODE BEGIN TIM3_MspInit 1 */
+ /* USER CODE BEGIN TIM3_MspInit 1 */
- /* USER CODE END TIM3_MspInit 1 */
+ /* USER CODE END TIM3_MspInit 1 */
}
@@ -172,9 +172,9 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(htim->Instance==TIM3)
{
- /* USER CODE BEGIN TIM3_MspPostInit 0 */
+ /* USER CODE BEGIN TIM3_MspPostInit 0 */
- /* USER CODE END TIM3_MspPostInit 0 */
+ /* USER CODE END TIM3_MspPostInit 0 */
__HAL_RCC_GPIOA_CLK_ENABLE();
/**TIM3 GPIO Configuration
@@ -185,48 +185,48 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- /* USER CODE BEGIN TIM3_MspPostInit 1 */
+ /* USER CODE BEGIN TIM3_MspPostInit 1 */
- /* USER CODE END TIM3_MspPostInit 1 */
+ /* USER CODE END TIM3_MspPostInit 1 */
}
}
/**
-* @brief TIM_PWM MSP De-Initialization
-* This function freeze the hardware resources used in this example
-* @param htim_pwm: TIM_PWM handle pointer
-* @retval None
-*/
+ * @brief TIM_PWM MSP De-Initialization
+ * This function freeze the hardware resources used in this example
+ * @param htim_pwm: TIM_PWM handle pointer
+ * @retval None
+ */
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm)
{
if(htim_pwm->Instance==TIM3)
{
- /* USER CODE BEGIN TIM3_MspDeInit 0 */
+ /* USER CODE BEGIN TIM3_MspDeInit 0 */
- /* USER CODE END TIM3_MspDeInit 0 */
+ /* USER CODE END TIM3_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM3_CLK_DISABLE();
- /* USER CODE BEGIN TIM3_MspDeInit 1 */
+ /* USER CODE BEGIN TIM3_MspDeInit 1 */
- /* USER CODE END TIM3_MspDeInit 1 */
+ /* USER CODE END TIM3_MspDeInit 1 */
}
}
/**
-* @brief UART MSP Initialization
-* This function configures the hardware resources used in this example
-* @param huart: UART handle pointer
-* @retval None
-*/
+ * @brief UART MSP Initialization
+ * This function configures the hardware resources used in this example
+ * @param huart: UART handle pointer
+ * @retval None
+ */
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART2)
{
- /* USER CODE BEGIN USART2_MspInit 0 */
+ /* USER CODE BEGIN USART2_MspInit 0 */
- /* USER CODE END USART2_MspInit 0 */
+ /* USER CODE END USART2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_USART2_CLK_ENABLE();
@@ -240,27 +240,27 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- /* USER CODE BEGIN USART2_MspInit 1 */
+ /* USER CODE BEGIN USART2_MspInit 1 */
- /* USER CODE END USART2_MspInit 1 */
+ /* USER CODE END USART2_MspInit 1 */
}
}
/**
-* @brief UART MSP De-Initialization
-* This function freeze the hardware resources used in this example
-* @param huart: UART handle pointer
-* @retval None
-*/
+ * @brief UART MSP De-Initialization
+ * This function freeze the hardware resources used in this example
+ * @param huart: UART handle pointer
+ * @retval None
+ */
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
{
if(huart->Instance==USART2)
{
- /* USER CODE BEGIN USART2_MspDeInit 0 */
+ /* USER CODE BEGIN USART2_MspDeInit 0 */
- /* USER CODE END USART2_MspDeInit 0 */
+ /* USER CODE END USART2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART2_CLK_DISABLE();
@@ -270,9 +270,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
*/
HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin);
- /* USER CODE BEGIN USART2_MspDeInit 1 */
+ /* USER CODE BEGIN USART2_MspDeInit 1 */
- /* USER CODE END USART2_MspDeInit 1 */
+ /* USER CODE END USART2_MspDeInit 1 */
}
}
diff --git a/app/inc/logger.h b/app/inc/logger.h
@@ -51,7 +51,7 @@ extern "C" {
/********************** macros ***********************************************/
-#define LOGGER_CONFIG_ENABLE (1)
+#define LOGGER_CONFIG_ENABLE (0)
#define LOGGER_CONFIG_MAXLEN (64)
#define LOGGER_CONFIG_USE_SEMIHOSTING (1)
diff --git a/app/src/app.c b/app/src/app.c
@@ -53,31 +53,28 @@
/********************** macros and definitions *******************************/
-#define G_APP_CNT_INI 0ul
-#define G_APP_TICK_CNT_INI 0ul
+#define G_APP_CNT_INI 0ul
+#define G_APP_TICK_CNT_INI 0ul
-#define TASK_X_WCET_INI 0ul
+#define TASK_X_WCET_INI 0ul
typedef struct {
- void (*task_init)(void *); // Pointer to task (must be a
- // 'void (void *)' function)
- void (*task_update)(void *); // Pointer to task (must be a
- // 'void (void *)' function)
- void *parameters; // Pointer to parameters
+ void (*task_init)(void *);
+ void (*task_update)(void *);
+ void *parameters;
} task_cfg_t;
typedef struct {
- uint32_t WCET; // Worst-case execution time (microseconds)
+ uint32_t WCET;
} task_dta_t;
/********************** internal data declaration ****************************/
-
shared_data_type shared_data;
const task_cfg_t task_cfg_list[] = {
{task_adc_init, task_adc_update, &shared_data},
- {task_pwm_init, task_pwm_update, &shared_data},
+ {task_pwm_init, task_pwm_update, &shared_data},
};
#define TASK_QTY (sizeof(task_cfg_list)/sizeof(task_cfg_t))
@@ -86,14 +83,11 @@ const task_cfg_t task_cfg_list[] = {
/********************** internal data definition *****************************/
-
-const char *p_sys = " Bare Metal - Event-Triggered Systems (ETS)\n";
-const char *p_app = " ADC + PWM\n";
-
+const char *p_sys = " Bare Metal - Event-Triggered Systems (ETS)\n";
+const char *p_app = " ADC + PWM\n";
/********************** external data declaration *****************************/
-
uint32_t g_app_cnt;
uint32_t g_app_time_us;
@@ -104,82 +98,77 @@ task_dta_t task_dta_list[TASK_QTY];
void app_init(void)
{
- uint32_t index;
+ uint32_t index;
- /* Print out: Application Initialized */
- LOGGER_LOG("\n");
- LOGGER_LOG("%s is running - Tick [mS] = %lu\r\n", GET_NAME(app_init), HAL_GetTick());
+ /* Print out: Application Initialized */
+ LOGGER_LOG("\n");
+ LOGGER_LOG("%s is running - Tick [mS] = %lu\r\n", GET_NAME(app_init), HAL_GetTick());
- LOGGER_LOG(p_sys);
- LOGGER_LOG(p_app);
+ LOGGER_LOG(p_sys);
+ LOGGER_LOG(p_app);
- g_app_cnt = G_APP_CNT_INI;
+ g_app_cnt = G_APP_CNT_INI;
- /* Print out: Application execution counter */
- LOGGER_LOG(" %s = %lu\n", GET_NAME(g_app_cnt), g_app_cnt);
+ /* Print out: Application execution counter */
+ LOGGER_LOG(" %s = %lu\n", GET_NAME(g_app_cnt), g_app_cnt);
- /* Go through the task arrays */
- for (index = 0; TASK_QTY > index; index++)
- {
-
- /* Run task_x_init */
- (*task_cfg_list[index].task_init)(task_cfg_list[index].parameters);
+ /* Go through the task arrays */
+ for (index = 0; TASK_QTY > index; index++)
+ {
+ /* Run task_x_init */
+ (*task_cfg_list[index].task_init)(task_cfg_list[index].parameters);
- /* Init variables */
- task_dta_list[index].WCET = TASK_X_WCET_INI;
- }
+ /* Init variables */
+ task_dta_list[index].WCET = TASK_X_WCET_INI;
+ }
- cycle_counter_init();
+ cycle_counter_init();
}
void app_update(void)
{
+ uint32_t index;
+ //uint32_t cycle_counter;
+ uint32_t cycle_counter_time_us;
- uint32_t index;
- //uint32_t cycle_counter;
- uint32_t cycle_counter_time_us;
-
- /* Check if it's time to run tasks */
- if (G_APP_TICK_CNT_INI < g_app_tick_cnt)
+ /* Check if it's time to run tasks */
+ if (G_APP_TICK_CNT_INI < g_app_tick_cnt)
{
+ g_app_tick_cnt--;
- g_app_tick_cnt--;
-
- /* Update App Counter */
- g_app_cnt++;
- g_app_time_us = 0;
-
- /* Print out: Application execution counter */
- //LOGGER_LOG(" %s = %lu\r\n", GET_NAME(g_app_cnt), g_app_cnt);
-
- /* Go through the task arrays */
- for (index = 0; TASK_QTY > index; index++)
- {
+ /* Update App Counter */
+ g_app_cnt++;
+ g_app_time_us = 0;
- cycle_counter_reset();
+ /* Print out: Application execution counter */
+ //LOGGER_LOG(" %s = %lu\r\n", GET_NAME(g_app_cnt), g_app_cnt);
- /* Run task_x_update */
- (*task_cfg_list[index].task_update)(task_cfg_list[index].parameters);
+ /* Go through the task arrays */
+ for (index = 0; TASK_QTY > index; index++)
+ {
+ cycle_counter_reset();
+ /* Run task_x_update */
+ (*task_cfg_list[index].task_update)(task_cfg_list[index].parameters);
- //cycle_counter = cycle_counter_get();
- cycle_counter_time_us = cycle_counter_time_us();
- /* Update variables */
- g_app_time_us += cycle_counter_time_us;
+ //cycle_counter = cycle_counter_get();
+ cycle_counter_time_us = cycle_counter_time_us();
- if (task_dta_list[index].WCET < cycle_counter_time_us)
- {
- task_dta_list[index].WCET = cycle_counter_time_us;
- }
+ /* Update variables */
+ g_app_time_us += cycle_counter_time_us;
+ if (task_dta_list[index].WCET < cycle_counter_time_us)
+ {
+ task_dta_list[index].WCET = cycle_counter_time_us;
+ }
- /* Print out: Cycle Counter */
- //LOGGER_LOG(" %s: %lu - %s: %lu uS\r\n", GET_NAME(cycle_counter), cycle_counter, GET_NAME(cycle_counter_time_us), cycle_counter_time_us);
- //LOGGER_LOG(" %s: %lu uS\r\n", GET_NAME(g_app_time_us), g_app_time_us);
- }
+ /* Print out: Cycle Counter */
+ //LOGGER_LOG(" %s: %lu - %s: %lu uS\r\n", GET_NAME(cycle_counter), cycle_counter, GET_NAME(cycle_counter_time_us), cycle_counter_time_us);
+ //LOGGER_LOG(" %s: %lu uS\r\n", GET_NAME(g_app_time_us), g_app_time_us);
+ }
- LOGGER_LOG("%d,%d\n", shared_data.pwm_active, shared_data.adc_value);
+ LOGGER_LOG("%d,%d\n", shared_data.pwm_active, shared_data.adc_value);
}
}
@@ -195,10 +184,6 @@ void app_update(void)
void HAL_SYSTICK_Callback(void)
{
g_app_tick_cnt++;
-
-
-
- //HAL_GPIO_TogglePin(LED_A_PORT, LED_A_PIN);
}
/********************** end of file ******************************************/
diff --git a/app/src/task_adc.c b/app/src/task_adc.c
@@ -49,6 +49,8 @@
/********************** macros and definitions *******************************/
+#define ADC_AVG_SAMPLES 10
+
/********************** internal data declaration ****************************/
@@ -57,7 +59,7 @@
HAL_StatusTypeDef ADC_Poll_Read(uint16_t *value);
/********************** internal data definition *****************************/
-const char *p_task_adc = "Task ADC";
+const char *p_task_adc = "Task ADC";
/********************** external data declaration *****************************/
@@ -66,41 +68,54 @@ extern ADC_HandleTypeDef hadc1;
/********************** external functions definition ************************/
void task_adc_init(void *parameters)
{
- shared_data_type *shared_data = (shared_data_type *) parameters;
+ shared_data_type *shared_data = (shared_data_type *) parameters;
- /* Print out: Task Initialized */
- LOGGER_LOG(" %s is running - %s\r\n", GET_NAME(task_adc_init), p_task_adc);
+ /* Print out: Task Initialized */
+ LOGGER_LOG(" %s is running - %s\r\n", GET_NAME(task_adc_init), p_task_adc);
- shared_data->adc_end_of_conversion = false;
+ shared_data->adc_end_of_conversion = false;
}
void task_adc_update(void *parameters)
{
-
- shared_data_type *shared_data = (shared_data_type *) parameters;
-
- if (HAL_OK==ADC_Poll_Read(&shared_data->adc_value)) {
- shared_data->adc_end_of_conversion = true;
- }
- else {
- LOGGER_LOG("error\n");
- }
+ shared_data_type *shared_data = (shared_data_type *) parameters;
+
+ if (HAL_OK == ADC_Poll_Read(&shared_data->adc_value))
+ {
+ shared_data->adc_end_of_conversion = true;
+ }
+ else
+ {
+ LOGGER_LOG("error\n");
+ }
}
-
-
-// Requests start of conversion, waits until conversion done
+// Requests start of conversion, waits until conversion done
HAL_StatusTypeDef ADC_Poll_Read(uint16_t *value) {
- HAL_StatusTypeDef res;
-
- res=HAL_ADC_Start(&hadc1);
- if ( HAL_OK==res ) {
- res=HAL_ADC_PollForConversion(&hadc1, 0);
- if ( HAL_OK==res ) {
- *value = HAL_ADC_GetValue(&hadc1);
- }
- }
- return res;
+ // HAL_StatusTypeDef res;
+ uint32_t sum = 0;
+
+ for (int i = 0; i < ADC_AVG_SAMPLES; i++)
+ {
+ HAL_ADC_Start(&hadc1);
+ HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);
+ sum += HAL_ADC_GetValue(&hadc1);
+ HAL_ADC_Stop(&hadc1);
+ }
+
+ /*
+ res = HAL_ADC_Start(&hadc1);
+ if (HAL_OK == res)
+ {
+ res = HAL_ADC_PollForConversion(&hadc1, 0);
+ if (HAL_OK == res)
+ {
+ *value = HAL_ADC_GetValue(&hadc1);
+ }
+ }
+ */
+ *value = (sum / ADC_AVG_SAMPLES);
+ return HAL_OK;
}
diff --git a/app/src/task_dummy.c b/app/src/task_dummy.c
@@ -1,75 +1,75 @@
-/*
- * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @file : task_dummy.c
- * @date : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version v1.0.0
- */
-
-/********************** inclusions *******************************************/
-/* Project includes. */
-#include "main.h"
-
-/* Demo includes. */
-#include "logger.h"
-#include "dwt.h"
-
-/* Application & Tasks includes. */
-#include "board.h"
-#include "app.h"
-
-/********************** macros and definitions *******************************/
-
-/********************** internal data declaration ****************************/
-
-/********************** internal functions declaration ***********************/
-
-/********************** internal data definition *****************************/
-const char *p_task_dummy = "Task Dummy";
-
-/********************** external data declaration *****************************/
-
-
-/********************** external functions definition ************************/
-void task_dummy_init(void *parameters)
-{
- /* Print out: Task Initialized */
- LOGGER_LOG(" %s is running - %s\r\n", GET_NAME(task_c_init), p_task_dummy);
-
-}
-
-void task_dummy_update(void *parameters)
-{
-
-}
-
-/********************** end of file ******************************************/
+/*
+ * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @file : task_dummy.c
+ * @date : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version v1.0.0
+ */
+
+/********************** inclusions *******************************************/
+/* Project includes. */
+#include "main.h"
+
+/* Demo includes. */
+#include "logger.h"
+#include "dwt.h"
+
+/* Application & Tasks includes. */
+#include "board.h"
+#include "app.h"
+
+/********************** macros and definitions *******************************/
+
+/********************** internal data declaration ****************************/
+
+/********************** internal functions declaration ***********************/
+
+/********************** internal data definition *****************************/
+const char *p_task_dummy = "Task Dummy";
+
+/********************** external data declaration *****************************/
+
+
+/********************** external functions definition ************************/
+void task_dummy_init(void *parameters)
+{
+ /* Print out: Task Initialized */
+ LOGGER_LOG(" %s is running - %s\r\n", GET_NAME(task_c_init), p_task_dummy);
+
+}
+
+void task_dummy_update(void *parameters)
+{
+
+}
+
+/********************** end of file ******************************************/
diff --git a/app/src/task_pwm.c b/app/src/task_pwm.c
@@ -1,122 +1,122 @@
-/*
- * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @file : task_pwm.c
- * @date : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version v1.0.0
- */
-
-/********************** inclusions *******************************************/
-/* Project includes. */
-#include <stdlib.h>
-#include "main.h"
-
-/* Demo includes. */
-#include "logger.h"
-#include "dwt.h"
-
-/* Application & Tasks includes. */
-#include "board.h"
-#include "app.h"
-
-/********************** macros and definitions *******************************/
-
-#define STEP (2048)
-#define PERIOD (65535)
-
-/********************** internal data declaration ****************************/
-
-/********************** internal functions declaration ***********************/
-void setPWM(TIM_HandleTypeDef timer,
- uint32_t channel,
- uint16_t period,
- uint16_t pulse);
-
-/********************** internal data definition *****************************/
-const char *p_task_pwm = "Task PWM";
-
-/********************** external data declaration *****************************/
-extern TIM_HandleTypeDef htim3;
-
-
-/********************** external functions definition ************************/
-void task_pwm_init(void *parameters)
-{
- shared_data_type *shared_data = (shared_data_type *) parameters;
-
- shared_data->pwm_active = 0;
- /* Print out: Task Initialized */
- LOGGER_LOG(" %s is running - %s\r\n", GET_NAME(task_pwm_init), p_task_pwm);
-}
-
-void task_pwm_update(void *parameters)
-{
-
- static uint16_t period=PERIOD;
- static int16_t step = STEP;
-
- shared_data_type *shared_data = (shared_data_type *) parameters;
-
- if ( shared_data->adc_end_of_conversion ) {
- shared_data->adc_end_of_conversion = false;
- setPWM(htim3, TIM_CHANNEL_1, period, shared_data->pwm_active);
- if ( step>0 ) {
- if ( period-step<=shared_data->pwm_active ) {
- step = step * -1;
- }
- }
- else {
- if ( abs(step)>=shared_data->pwm_active ) {
- step = step * -1;
- }
- }
- shared_data->pwm_active = shared_data->pwm_active + step;
- }
-}
-
-
-void setPWM(TIM_HandleTypeDef timer, uint32_t channel,
- uint16_t period, uint16_t pulse) {
- HAL_TIM_PWM_Stop(&timer, channel);
- TIM_OC_InitTypeDef sConfigOC;
- timer.Init.Period = period;
- HAL_TIM_PWM_Init(&timer);
-
- sConfigOC.OCMode = TIM_OCMODE_PWM1;
- sConfigOC.Pulse = pulse;
- sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
- sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
- HAL_TIM_PWM_ConfigChannel(&timer, &sConfigOC, channel);
- HAL_TIM_PWM_Start(&timer,channel);
-}
-
-/********************** end of file ******************************************/
+/*
+ * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @file : task_pwm.c
+ * @date : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version v1.0.0
+ */
+
+/********************** inclusions *******************************************/
+/* Project includes. */
+#include <stdlib.h>
+#include "main.h"
+
+/* Demo includes. */
+#include "logger.h"
+#include "dwt.h"
+
+/* Application & Tasks includes. */
+#include "board.h"
+#include "app.h"
+#include <math.h>
+
+/********************** macros and definitions *******************************/
+
+#define STEP (32)
+#define PERIOD (65535)
+
+/********************** internal data declaration ****************************/
+
+/********************** internal functions declaration ***********************/
+void setPWM(TIM_HandleTypeDef timer,
+ uint32_t channel,
+ uint16_t period,
+ uint16_t pulse);
+
+/********************** internal data definition *****************************/
+const char *p_task_pwm = "Task PWM";
+
+/********************** external data declaration *****************************/
+extern TIM_HandleTypeDef htim3;
+
+/********************** external functions definition ************************/
+void task_pwm_init(void *parameters)
+{
+ shared_data_type *shared_data = (shared_data_type *) parameters;
+
+ shared_data->pwm_active = 0;
+ LOGGER_LOG(" %s is running - %s\r\n", GET_NAME(task_pwm_init), p_task_pwm);
+}
+
+#define min(a, b) a < b ? a : b
+#define max(a, b) a > b ? a : b
+
+
+void task_pwm_update(void *parameters)
+{
+ float x_norm;
+ shared_data_type *data = (shared_data_type *) parameters;
+
+ if (data->adc_end_of_conversion)
+ {
+ data->adc_end_of_conversion = false;
+ uint32_t x = data->adc_value;
+
+ // se mapea el valor leido de adc al intervalo [0, 1]
+ x_norm = ((float)x/4096);
+
+ // se mapea el valor normalizado elevado a la sexta
+ // al intervalo en y [0, PERIODO] esto porque el LED
+ // no tiene un comportamiento lineal
+ data->pwm_active = PERIOD*powf(x_norm, 6);
+
+ setPWM(htim3, TIM_CHANNEL_1, PERIOD, data->pwm_active);
+ }
+}
+
+void setPWM(TIM_HandleTypeDef timer, uint32_t channel,
+ uint16_t period, uint16_t pulse)
+{
+ HAL_TIM_PWM_Stop(&timer, channel);
+ TIM_OC_InitTypeDef sConfigOC;
+ timer.Init.Period = period;
+ HAL_TIM_PWM_Init(&timer);
+
+ sConfigOC.OCMode = TIM_OCMODE_PWM1;
+ sConfigOC.Pulse = pulse;
+ sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
+ sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
+ HAL_TIM_PWM_ConfigChannel(&timer, &sConfigOC, channel);
+ HAL_TIM_PWM_Start(&timer, channel);
+}
+
+/********************** end of file ******************************************/
diff --git a/tdse-tp4-adc_pwm.ioc b/tdse-tp4-adc_pwm.ioc
@@ -1,181 +1,183 @@
-#MicroXplorer Configuration settings - do not modify
-ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_0
-ADC1.IPParameters=Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,NbrOfConversionFlag,master
-ADC1.NbrOfConversionFlag=1
-ADC1.Rank-1\#ChannelRegularConversion=1
-ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
-ADC1.master=1
-CAD.formats=
-CAD.pinconfig=
-CAD.provider=
-File.Version=6
-KeepUserPlacement=false
-Mcu.CPN=STM32F103RBT6
-Mcu.Family=STM32F1
-Mcu.IP0=ADC1
-Mcu.IP1=NVIC
-Mcu.IP2=RCC
-Mcu.IP3=SYS
-Mcu.IP4=TIM3
-Mcu.IP5=USART2
-Mcu.IPNb=6
-Mcu.Name=STM32F103R(8-B)Tx
-Mcu.Package=LQFP64
-Mcu.Pin0=PC13-TAMPER-RTC
-Mcu.Pin1=PC14-OSC32_IN
-Mcu.Pin10=PA13
-Mcu.Pin11=PA14
-Mcu.Pin12=PB3
-Mcu.Pin13=VP_SYS_VS_Systick
-Mcu.Pin2=PC15-OSC32_OUT
-Mcu.Pin3=PD0-OSC_IN
-Mcu.Pin4=PD1-OSC_OUT
-Mcu.Pin5=PA0-WKUP
-Mcu.Pin6=PA2
-Mcu.Pin7=PA3
-Mcu.Pin8=PA5
-Mcu.Pin9=PA6
-Mcu.PinsNb=14
-Mcu.ThirdPartyNb=0
-Mcu.UserConstants=
-Mcu.UserName=STM32F103RBTx
-MxCube.Version=6.13.0
-MxDb.Version=DB.6.0.130
-NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-NVIC.EXTI15_10_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
-NVIC.ForceEnableDMAVector=true
-NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
-NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:false
-NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
-PA0-WKUP.Locked=true
-PA0-WKUP.Signal=ADCx_IN0
-PA13.GPIOParameters=GPIO_Label
-PA13.GPIO_Label=TMS
-PA13.Locked=true
-PA13.Mode=Serial_Wire
-PA13.Signal=SYS_JTMS-SWDIO
-PA14.GPIOParameters=GPIO_Label
-PA14.GPIO_Label=TCK
-PA14.Locked=true
-PA14.Mode=Serial_Wire
-PA14.Signal=SYS_JTCK-SWCLK
-PA2.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_Mode
-PA2.GPIO_Label=USART_TX
-PA2.GPIO_Mode=GPIO_MODE_AF_PP
-PA2.GPIO_PuPd=GPIO_NOPULL
-PA2.GPIO_Speed=GPIO_SPEED_FREQ_LOW
-PA2.Locked=true
-PA2.Mode=Asynchronous
-PA2.Signal=USART2_TX
-PA3.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_Mode
-PA3.GPIO_Label=USART_RX
-PA3.GPIO_Mode=GPIO_MODE_AF_PP
-PA3.GPIO_PuPd=GPIO_NOPULL
-PA3.GPIO_Speed=GPIO_SPEED_FREQ_LOW
-PA3.Locked=true
-PA3.Mode=Asynchronous
-PA3.Signal=USART2_RX
-PA5.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
-PA5.GPIO_Label=LD2 [Green Led]
-PA5.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
-PA5.GPIO_PuPd=GPIO_NOPULL
-PA5.GPIO_Speed=GPIO_SPEED_FREQ_LOW
-PA5.Locked=true
-PA5.Signal=GPIO_Output
-PA6.Locked=true
-PA6.Signal=S_TIM3_CH1
-PB3.GPIOParameters=GPIO_Label
-PB3.GPIO_Label=SWO
-PB3.Locked=true
-PB3.Signal=SYS_JTDO-TRACESWO
-PC13-TAMPER-RTC.GPIOParameters=GPIO_PuPd,GPIO_Label
-PC13-TAMPER-RTC.GPIO_Label=B1 [Blue PushButton]
-PC13-TAMPER-RTC.GPIO_PuPd=GPIO_NOPULL
-PC13-TAMPER-RTC.Locked=true
-PC13-TAMPER-RTC.Signal=GPXTI13
-PC14-OSC32_IN.Locked=true
-PC14-OSC32_IN.Mode=LSE-External-Oscillator
-PC14-OSC32_IN.Signal=RCC_OSC32_IN
-PC15-OSC32_OUT.Locked=true
-PC15-OSC32_OUT.Mode=LSE-External-Oscillator
-PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
-PD0-OSC_IN.Locked=true
-PD0-OSC_IN.Mode=HSE-External-Clock-Source
-PD0-OSC_IN.Signal=RCC_OSC_IN
-PD1-OSC_OUT.Locked=true
-PD1-OSC_OUT.Mode=HSE-External-Clock-Source
-PD1-OSC_OUT.Signal=RCC_OSC_OUT
-PinOutPanel.RotationAngle=0
-ProjectManager.AskForMigrate=true
-ProjectManager.BackupPrevious=false
-ProjectManager.CompilerOptimize=6
-ProjectManager.ComputerToolchain=false
-ProjectManager.CoupleFile=false
-ProjectManager.CustomerFirmwarePackage=
-ProjectManager.DefaultFWLocation=true
-ProjectManager.DeletePrevious=true
-ProjectManager.DeviceId=STM32F103RBTx
-ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.6
-ProjectManager.FreePins=false
-ProjectManager.HalAssertFull=false
-ProjectManager.HeapSize=0x200
-ProjectManager.KeepUserCode=true
-ProjectManager.LastFirmware=true
-ProjectManager.LibraryCopy=1
-ProjectManager.MainLocation=Core/Src
-ProjectManager.NoMain=false
-ProjectManager.PreviousToolchain=
-ProjectManager.ProjectBuild=false
-ProjectManager.ProjectFileName=tdse-tp4-adc_pwm.ioc
-ProjectManager.ProjectName=tdse-tp4-adc_pwm
-ProjectManager.ProjectStructure=
-ProjectManager.RegisterCallBack=
-ProjectManager.StackSize=0x400
-ProjectManager.TargetToolchain=STM32CubeIDE
-ProjectManager.ToolChainLocation=
-ProjectManager.UAScriptAfterPath=
-ProjectManager.UAScriptBeforePath=
-ProjectManager.UnderRoot=true
-ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true
-RCC.ADCFreqValue=4000000
-RCC.AHBFreq_Value=8000000
-RCC.APB1CLKDivider=RCC_HCLK_DIV2
-RCC.APB1Freq_Value=4000000
-RCC.APB1TimFreq_Value=8000000
-RCC.APB2Freq_Value=8000000
-RCC.APB2TimFreq_Value=8000000
-RCC.FCLKCortexFreq_Value=8000000
-RCC.FamilyName=M
-RCC.HCLKFreq_Value=8000000
-RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,RTCClockSelection,RTCFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value
-RCC.MCOFreq_Value=8000000
-RCC.PLLCLKFreq_Value=8000000
-RCC.PLLMCOFreq_Value=4000000
-RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE
-RCC.RTCFreq_Value=32768
-RCC.SYSCLKFreq_VALUE=8000000
-RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
-RCC.TimSysFreq_Value=8000000
-RCC.USBFreq_Value=8000000
-RCC.VCOOutput2Freq_Value=4000000
-SH.ADCx_IN0.0=ADC1_IN0,IN0
-SH.ADCx_IN0.ConfNb=1
-SH.GPXTI13.0=GPIO_EXTI13
-SH.GPXTI13.ConfNb=1
-SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
-SH.S_TIM3_CH1.ConfNb=1
-TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
-TIM3.IPParameters=Channel-PWM Generation1 CH1
-USART2.IPParameters=VirtualMode
-USART2.VirtualMode=VM_ASYNC
-VP_SYS_VS_Systick.Mode=SysTick
-VP_SYS_VS_Systick.Signal=SYS_VS_Systick
-board=NUCLEO-F103RB
-boardIOC=true
-isbadioc=false
+#MicroXplorer Configuration settings - do not modify
+ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_0
+ADC1.IPParameters=Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,NbrOfConversionFlag,master
+ADC1.NbrOfConversionFlag=1
+ADC1.Rank-1\#ChannelRegularConversion=1
+ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
+ADC1.master=1
+CAD.formats=
+CAD.pinconfig=
+CAD.provider=
+File.Version=6
+KeepUserPlacement=false
+Mcu.CPN=STM32F103RBT6
+Mcu.Family=STM32F1
+Mcu.IP0=ADC1
+Mcu.IP1=NVIC
+Mcu.IP2=RCC
+Mcu.IP3=SYS
+Mcu.IP4=TIM3
+Mcu.IP5=USART2
+Mcu.IPNb=6
+Mcu.Name=STM32F103R(8-B)Tx
+Mcu.Package=LQFP64
+Mcu.Pin0=PC13-TAMPER-RTC
+Mcu.Pin1=PC14-OSC32_IN
+Mcu.Pin10=PA13
+Mcu.Pin11=PA14
+Mcu.Pin12=PB3
+Mcu.Pin13=VP_SYS_VS_Systick
+Mcu.Pin2=PC15-OSC32_OUT
+Mcu.Pin3=PD0-OSC_IN
+Mcu.Pin4=PD1-OSC_OUT
+Mcu.Pin5=PA0-WKUP
+Mcu.Pin6=PA2
+Mcu.Pin7=PA3
+Mcu.Pin8=PA5
+Mcu.Pin9=PA6
+Mcu.PinsNb=14
+Mcu.ThirdPartyNb=0
+Mcu.UserConstants=
+Mcu.UserName=STM32F103RBTx
+MxCube.Version=6.15.0
+MxDb.Version=DB.6.0.150
+NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.EXTI15_10_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
+NVIC.ForceEnableDMAVector=true
+NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
+NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:false
+NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+PA0-WKUP.Locked=true
+PA0-WKUP.Signal=ADCx_IN0
+PA13.GPIOParameters=GPIO_Label
+PA13.GPIO_Label=TMS
+PA13.Locked=true
+PA13.Mode=Serial_Wire
+PA13.Signal=SYS_JTMS-SWDIO
+PA14.GPIOParameters=GPIO_Label
+PA14.GPIO_Label=TCK
+PA14.Locked=true
+PA14.Mode=Serial_Wire
+PA14.Signal=SYS_JTCK-SWCLK
+PA2.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_Mode
+PA2.GPIO_Label=USART_TX
+PA2.GPIO_Mode=GPIO_MODE_AF_PP
+PA2.GPIO_PuPd=GPIO_NOPULL
+PA2.GPIO_Speed=GPIO_SPEED_FREQ_LOW
+PA2.Locked=true
+PA2.Mode=Asynchronous
+PA2.Signal=USART2_TX
+PA3.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_Mode
+PA3.GPIO_Label=USART_RX
+PA3.GPIO_Mode=GPIO_MODE_AF_PP
+PA3.GPIO_PuPd=GPIO_NOPULL
+PA3.GPIO_Speed=GPIO_SPEED_FREQ_LOW
+PA3.Locked=true
+PA3.Mode=Asynchronous
+PA3.Signal=USART2_RX
+PA5.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
+PA5.GPIO_Label=LD2 [Green Led]
+PA5.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
+PA5.GPIO_PuPd=GPIO_NOPULL
+PA5.GPIO_Speed=GPIO_SPEED_FREQ_LOW
+PA5.Locked=true
+PA5.Signal=GPIO_Output
+PA6.Locked=true
+PA6.Signal=S_TIM3_CH1
+PB3.GPIOParameters=GPIO_Label
+PB3.GPIO_Label=SWO
+PB3.Locked=true
+PB3.Signal=SYS_JTDO-TRACESWO
+PC13-TAMPER-RTC.GPIOParameters=GPIO_PuPd,GPIO_Label
+PC13-TAMPER-RTC.GPIO_Label=B1 [Blue PushButton]
+PC13-TAMPER-RTC.GPIO_PuPd=GPIO_NOPULL
+PC13-TAMPER-RTC.Locked=true
+PC13-TAMPER-RTC.Signal=GPXTI13
+PC14-OSC32_IN.Locked=true
+PC14-OSC32_IN.Mode=LSE-External-Oscillator
+PC14-OSC32_IN.Signal=RCC_OSC32_IN
+PC15-OSC32_OUT.Locked=true
+PC15-OSC32_OUT.Mode=LSE-External-Oscillator
+PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
+PD0-OSC_IN.Locked=true
+PD0-OSC_IN.Mode=HSE-External-Clock-Source
+PD0-OSC_IN.Signal=RCC_OSC_IN
+PD1-OSC_OUT.Locked=true
+PD1-OSC_OUT.Mode=HSE-External-Clock-Source
+PD1-OSC_OUT.Signal=RCC_OSC_OUT
+PinOutPanel.RotationAngle=0
+ProjectManager.AskForMigrate=true
+ProjectManager.BackupPrevious=false
+ProjectManager.CompilerLinker=GCC
+ProjectManager.CompilerOptimize=6
+ProjectManager.ComputerToolchain=false
+ProjectManager.CoupleFile=false
+ProjectManager.CustomerFirmwarePackage=
+ProjectManager.DefaultFWLocation=true
+ProjectManager.DeletePrevious=true
+ProjectManager.DeviceId=STM32F103RBTx
+ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.6
+ProjectManager.FreePins=false
+ProjectManager.HalAssertFull=false
+ProjectManager.HeapSize=0x200
+ProjectManager.KeepUserCode=true
+ProjectManager.LastFirmware=true
+ProjectManager.LibraryCopy=1
+ProjectManager.MainLocation=Core/Src
+ProjectManager.NoMain=false
+ProjectManager.PreviousToolchain=
+ProjectManager.ProjectBuild=false
+ProjectManager.ProjectFileName=tdse-tp4-adc_pwm.ioc
+ProjectManager.ProjectName=tdse-tp4-adc_pwm
+ProjectManager.ProjectStructure=
+ProjectManager.RegisterCallBack=
+ProjectManager.StackSize=0x400
+ProjectManager.TargetToolchain=STM32CubeIDE
+ProjectManager.ToolChainLocation=
+ProjectManager.UAScriptAfterPath=
+ProjectManager.UAScriptBeforePath=
+ProjectManager.UnderRoot=true
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true
+RCC.ADCFreqValue=4000000
+RCC.AHBFreq_Value=8000000
+RCC.APB1CLKDivider=RCC_HCLK_DIV2
+RCC.APB1Freq_Value=4000000
+RCC.APB1TimFreq_Value=8000000
+RCC.APB2Freq_Value=8000000
+RCC.APB2TimFreq_Value=8000000
+RCC.FCLKCortexFreq_Value=8000000
+RCC.FamilyName=M
+RCC.HCLKFreq_Value=8000000
+RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,RTCClockSelection,RTCFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value
+RCC.MCOFreq_Value=8000000
+RCC.PLLCLKFreq_Value=8000000
+RCC.PLLMCOFreq_Value=4000000
+RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE
+RCC.RTCFreq_Value=32768
+RCC.SYSCLKFreq_VALUE=8000000
+RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
+RCC.TimSysFreq_Value=8000000
+RCC.USBFreq_Value=8000000
+RCC.VCOOutput2Freq_Value=4000000
+SH.ADCx_IN0.0=ADC1_IN0,IN0
+SH.ADCx_IN0.ConfNb=1
+SH.GPXTI13.0=GPIO_EXTI13
+SH.GPXTI13.ConfNb=1
+SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
+SH.S_TIM3_CH1.ConfNb=1
+TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
+TIM3.IPParameters=Channel-PWM Generation1 CH1,Period
+TIM3.Period=2048
+USART2.IPParameters=VirtualMode
+USART2.VirtualMode=VM_ASYNC
+VP_SYS_VS_Systick.Mode=SysTick
+VP_SYS_VS_Systick.Signal=SYS_VS_Systick
+board=NUCLEO-F103RB
+boardIOC=true
+isbadioc=false
diff --git a/tdse-tp4-adc_pwm.launch b/tdse-tp4-adc_pwm.launch
@@ -1,14 +1,31 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.device" value="STM32F103RB"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.endian" value="little"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.init_speed" value="4000"/>
+ <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_check_serial_number" value="false"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_script_path" value=""/>
+ <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_script_used" value="false"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.jlink_txt_serial_number" value=""/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.reset_strategy" value="type_0_normal"/>
+ <intAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.rtos_implementation" value="1"/>
+ <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.scan_chain_auto" value="true"/>
+ <intAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.scan_chain_irpre" value="0"/>
+ <intAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.scan_chain_pos" value="0"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.jlink.selected_rtos" value="RTOSPlugin_Azure"/>
+ <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.jlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
+ <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth__pwd_enable" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_certif_path" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_check_enable" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_key_path" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_permission" value=""/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_pwd_file" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
+ <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.incremental_flashing" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
@@ -21,7 +38,7 @@
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="3344"/>
- <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="64000000"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="8000000"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.CTI_ALLOW_HALT" value="false"/>
@@ -33,10 +50,10 @@
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_RESET_MODE" value="soft"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_STOP_WATCHDOG_THEN_HALTED_ALLOWED" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_GENERATOR_OPTION" value="true"/>
- <stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_NAME" value=""${stm32cubeide_openocd_path}\openocd.exe""/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_NAME" value=""${stm32cubeide_openocd_path}/openocd""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_OTHER_OPTIONS" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_RESTART_CONFIGURATIONS" value="{"fVersion":1,"fItems":[{"fDisplayName":"Reset halt","fIsSuppressible":false,"fResetAttribute":"Reset halt","fResetStrategies":[{"fDisplayName":"Reset halt","fLaunchAttribute":"monitor reset halt","fGdbCommands":["monitor reset halt"],"fCmdOptions":[]},{"fDisplayName":"Reset init","fLaunchAttribute":"monitor reset init","fGdbCommands":["monitor reset init"],"fCmdOptions":[]},{"fDisplayName":"None","fLaunchAttribute":"","fGdbCommands":[],"fCmdOptions":[]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]},"fStartApplication":true},{"fDisplayName":"Reset init","fIsSuppressible":false,"fResetAttribute":"Reset init","fResetStrategies":[{"fDisplayName":"Reset halt","fLaunchAttribute":"monitor reset halt","fGdbCommands":["monitor reset halt"],"fCmdOptions":[]},{"fDisplayName":"Reset init","fLaunchAttribute":"monitor reset init","fGdbCommands":["monitor reset init"],"fCmdOptions":[]},{"fDisplayName":"None","fLaunchAttribute":"","fGdbCommands":[],"fCmdOptions":[]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]},"fStartApplication":true}]}"/>
- <stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_SCRIPT" value="${ProjDirPath}\tdse-tp4-adc_pwm.cfg"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_SCRIPT" value="${ProjDirPath}/tdse-tp4-adc_pwm.cfg"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.OPENOCD_SCRIPT_CHOICE" value="automated"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocdenable_rtos" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
@@ -46,7 +63,7 @@
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
- <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="C:\Users\G\STM32CubeIDE\workspace_1.16.0\tdse-tp4-adc_pwm\Debug\st-link_gdbserver_log.txt"/>
+ <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="/home/mk/dox/fiuba/materias/TA134/tp4/tdse-tp4_03-adc_pwm/Debug/st-link_gdbserver_log.txt"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
@@ -70,7 +87,7 @@
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
- <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
+ <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
@@ -78,7 +95,7 @@
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
- <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
+ <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/tdse-tp4-adc_pwm.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="tdse-tp4-adc_pwm"/>