0% found this document useful (0 votes)
8 views5 pages

Lab03_part02

Uploaded by

zinlyly61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Lab03_part02

Uploaded by

zinlyly61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

Timer Configuration [PCS,ARR,Enable Auto-reload preload](500ms)


2. LED pin PA4 (3.3V->LED->PA4)
4. PTC output voltage PA3
3. Define Desired Temperature (float Dtemp)
4. write a program to control temperature

---------------TIMER CALCULATOR--------------------------------------
https://deepbluembedded.com/stm32-timer-calculator/
----------------------------------------------------

/* USER CODE BEGIN 0 */---------------------------------------LOOP 500ms


void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim->Instance == TIM14) {
// Your code here
// This function will be called when the TIM14 interrupt occurs
// For example, toggle an LED
if (MCONTROL == 1){// System in Control
if(Dtemp-temperature>=0){// if error>=0
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_4,0);//LED ON
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3,1);//PTC on
Volt = 10;
}else{
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_4,1);//LED OFF
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3,0);//PTC off
Volt = 0;

}
}
else{
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3,0);//PTC off
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_4,1);//LED off
Volt = 0;
}

}
}
/* USER CODE END 0 */----------------------------------------

/* USER CODE BEGIN 2 */----------------------------------


HAL_TIM_Base_Start_IT(&htim14);
/* USER CODE END 2 */-----------------------------------

------------------------------------------------------
#include <stdbool.h>

---------------------------------------------------
float temperature;
float Dtemp=0;
//bool LED = 0;// Control to LED
bool MCONTROL = 0;//Control to PTC
int Volt = 0;
-------------------------------------------------
STM32CubeMonitor
----------------------------write the value to memory address------------------
{
"variablelist":[
{
"address":"0x20000000",
"type":1,
"value":"{{payload}}"
}
],
"accesspoint":0
}

-----------------------bool to uint8_t----------------------
msg.payload = msg.payload ? 1 : 0;
return msg;
------------------------------------------------------

------------------------unit8_t to bool----------------
msg.payload = !!msg.payload;
return msg;
------------------------------------------------------
Configure

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy