mirror of
https://github.com/BreizhHardware/TP-STM32-CIPA3.git
synced 2026-01-18 16:17:23 +01:00
TP5 Exo 2 P2 (Mesurer la température avec le capteur interne)
This commit is contained in:
@@ -55,7 +55,6 @@ void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void ADC1_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
@@ -77,8 +77,8 @@ void affiche_nombre(uint32_t nombre, uint8_t col, uint8_t ligne) {
|
||||
displayChar_TFT(col + 12, ligne, cen + 0x30, ST7735_YELLOW, ST7735_BLACK, 2);
|
||||
displayChar_TFT(col + 24, ligne, diz + 0x30, ST7735_YELLOW, ST7735_BLACK, 2);
|
||||
displayChar_TFT(col + 36, ligne, uni + 0x30, ST7735_YELLOW, ST7735_BLACK, 2);
|
||||
displayChar_TFT(col + 48, ligne, 'm', ST7735_YELLOW, ST7735_BLACK, 2);
|
||||
displayChar_TFT(col + 60, ligne, 'V', ST7735_YELLOW, ST7735_BLACK, 2);
|
||||
displayChar_TFT(col + 48, ligne, ' ', ST7735_YELLOW, ST7735_BLACK, 2);
|
||||
displayChar_TFT(col + 60, ligne, 'C', ST7735_YELLOW, ST7735_BLACK, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,11 @@ int main(void)
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
const uint16_t TS_CAL1 = *(uint16_t*)0x1FF800FA;
|
||||
const uint16_t TS_CAL2 = *(uint16_t*)0x1FF800FE;
|
||||
const uint16_t VREFINT_CAL = *(uint16_t*)0x1FF800F8;
|
||||
const int32_t vrefint_value = 1210;
|
||||
float vdda_div_3 = (float)VREFINT_CAL / vrefint_value;
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE END WHILE */
|
||||
@@ -132,11 +136,10 @@ int main(void)
|
||||
/* USER CODE BEGIN 3 */
|
||||
HAL_ADC_Start(&hadc);
|
||||
HAL_ADC_PollForConversion(&hadc, 1000);
|
||||
uint32_t value = HAL_ADC_GetValue(&hadc);
|
||||
uint32_t temp_value = (HAL_ADC_GetValue(&hadc) / 4096.0) * 3300;
|
||||
HAL_ADC_Stop(&hadc);
|
||||
uint32_t milivolt = (value / 4096.0) * 3300;
|
||||
affiche_nombre(milivolt, 10, 80);
|
||||
|
||||
float temperature = 80 * (temp_value * vdda_div_3 - TS_CAL1) / (TS_CAL2 - TS_CAL1) + 30;
|
||||
affiche_nombre((uint32_t)(temperature), 10, 80);
|
||||
}
|
||||
|
||||
/* USER CODE END 3 */
|
||||
@@ -224,7 +227,7 @@ static void MX_ADC_Init(void)
|
||||
|
||||
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_VREFINT;
|
||||
sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_4CYCLES;
|
||||
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
|
||||
|
||||
@@ -104,9 +104,6 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* ADC1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(ADC1_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(ADC1_IRQn);
|
||||
/* USER CODE BEGIN ADC1_MspInit 1 */
|
||||
|
||||
/* USER CODE END ADC1_MspInit 1 */
|
||||
@@ -136,8 +133,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0);
|
||||
|
||||
/* ADC1 interrupt DeInit */
|
||||
HAL_NVIC_DisableIRQ(ADC1_IRQn);
|
||||
/* USER CODE BEGIN ADC1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END ADC1_MspDeInit 1 */
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern ADC_HandleTypeDef hadc;
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
@@ -198,20 +198,6 @@ void SysTick_Handler(void)
|
||||
/* please refer to the startup file (startup_stm32l1xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles ADC global interrupt.
|
||||
*/
|
||||
void ADC1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN ADC1_IRQn 0 */
|
||||
|
||||
/* USER CODE END ADC1_IRQn 0 */
|
||||
HAL_ADC_IRQHandler(&hadc);
|
||||
/* USER CODE BEGIN ADC1_IRQn 1 */
|
||||
|
||||
/* USER CODE END ADC1_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
../Core/Src/main.c:66:6:affiche_nombre 2
|
||||
../Core/Src/main.c:91:5:main 1
|
||||
../Core/Src/main.c:149:6:SystemClock_Config 3
|
||||
../Core/Src/main.c:190:13:MX_ADC_Init 3
|
||||
../Core/Src/main.c:245:13:MX_SPI1_Init 2
|
||||
../Core/Src/main.c:283:13:MX_GPIO_Init 1
|
||||
../Core/Src/main.c:348:6:Error_Handler 1
|
||||
../Core/Src/main.c:152:6:SystemClock_Config 3
|
||||
../Core/Src/main.c:193:13:MX_ADC_Init 3
|
||||
../Core/Src/main.c:248:13:MX_SPI1_Init 2
|
||||
../Core/Src/main.c:286:13:MX_GPIO_Init 1
|
||||
../Core/Src/main.c:351:6:Error_Handler 1
|
||||
|
||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
../Core/Src/main.c:66:6:affiche_nombre 32 static
|
||||
../Core/Src/main.c:91:5:main 24 static
|
||||
../Core/Src/main.c:149:6:SystemClock_Config 80 static
|
||||
../Core/Src/main.c:190:13:MX_ADC_Init 24 static
|
||||
../Core/Src/main.c:245:13:MX_SPI1_Init 8 static
|
||||
../Core/Src/main.c:283:13:MX_GPIO_Init 48 static
|
||||
../Core/Src/main.c:348:6:Error_Handler 4 static,ignoring_inline_asm
|
||||
../Core/Src/main.c:91:5:main 40 static
|
||||
../Core/Src/main.c:152:6:SystemClock_Config 80 static
|
||||
../Core/Src/main.c:193:13:MX_ADC_Init 24 static
|
||||
../Core/Src/main.c:248:13:MX_SPI1_Init 8 static
|
||||
../Core/Src/main.c:286:13:MX_GPIO_Init 48 static
|
||||
../Core/Src/main.c:351:6:Error_Handler 4 static,ignoring_inline_asm
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
../Core/Src/stm32l1xx_hal_msp.c:63:6:HAL_MspInit 1
|
||||
../Core/Src/stm32l1xx_hal_msp.c:87:6:HAL_ADC_MspInit 2
|
||||
../Core/Src/stm32l1xx_hal_msp.c:124:6:HAL_ADC_MspDeInit 2
|
||||
../Core/Src/stm32l1xx_hal_msp.c:154:6:HAL_SPI_MspInit 2
|
||||
../Core/Src/stm32l1xx_hal_msp.c:192:6:HAL_SPI_MspDeInit 2
|
||||
../Core/Src/stm32l1xx_hal_msp.c:121:6:HAL_ADC_MspDeInit 2
|
||||
../Core/Src/stm32l1xx_hal_msp.c:149:6:HAL_SPI_MspInit 2
|
||||
../Core/Src/stm32l1xx_hal_msp.c:187:6:HAL_SPI_MspDeInit 2
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
../Core/Src/stm32l1xx_hal_msp.c:63:6:HAL_MspInit 24 static
|
||||
../Core/Src/stm32l1xx_hal_msp.c:87:6:HAL_ADC_MspInit 48 static
|
||||
../Core/Src/stm32l1xx_hal_msp.c:124:6:HAL_ADC_MspDeInit 16 static
|
||||
../Core/Src/stm32l1xx_hal_msp.c:154:6:HAL_SPI_MspInit 48 static
|
||||
../Core/Src/stm32l1xx_hal_msp.c:192:6:HAL_SPI_MspDeInit 16 static
|
||||
../Core/Src/stm32l1xx_hal_msp.c:121:6:HAL_ADC_MspDeInit 16 static
|
||||
../Core/Src/stm32l1xx_hal_msp.c:149:6:HAL_SPI_MspInit 48 static
|
||||
../Core/Src/stm32l1xx_hal_msp.c:187:6:HAL_SPI_MspDeInit 16 static
|
||||
|
||||
@@ -7,4 +7,3 @@
|
||||
../Core/Src/stm32l1xx_it.c:157:6:DebugMon_Handler 1
|
||||
../Core/Src/stm32l1xx_it.c:170:6:PendSV_Handler 1
|
||||
../Core/Src/stm32l1xx_it.c:183:6:SysTick_Handler 1
|
||||
../Core/Src/stm32l1xx_it.c:204:6:ADC1_IRQHandler 1
|
||||
|
||||
Binary file not shown.
@@ -7,4 +7,3 @@
|
||||
../Core/Src/stm32l1xx_it.c:157:6:DebugMon_Handler 4 static
|
||||
../Core/Src/stm32l1xx_it.c:170:6:PendSV_Handler 4 static
|
||||
../Core/Src/stm32l1xx_it.c:183:6:SysTick_Handler 8 static
|
||||
../Core/Src/stm32l1xx_it.c:204:6:ADC1_IRQHandler 8 static
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -80,5 +80,6 @@
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#MicroXplorer Configuration settings - do not modify
|
||||
ADC.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_VREFINT
|
||||
ADC.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag
|
||||
ADC.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR
|
||||
ADC.IPParameters=Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,NbrOfConversionFlag
|
||||
ADC.NbrOfConversionFlag=1
|
||||
ADC.Rank-0\#ChannelRegularConversion=1
|
||||
ADC.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_4CYCLES
|
||||
ADC.Rank-1\#ChannelRegularConversion=1
|
||||
ADC.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_4CYCLES
|
||||
CAD.formats=
|
||||
CAD.pinconfig=
|
||||
CAD.provider=
|
||||
@@ -23,7 +23,7 @@ Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PC0
|
||||
Mcu.Pin1=PC1
|
||||
Mcu.Pin10=PB7
|
||||
Mcu.Pin11=VP_ADC_Vref_Input
|
||||
Mcu.Pin11=VP_ADC_TempSens_Input
|
||||
Mcu.Pin12=VP_SYS_VS_Systick
|
||||
Mcu.Pin2=PC2
|
||||
Mcu.Pin3=PC3
|
||||
@@ -39,7 +39,6 @@ Mcu.UserConstants=
|
||||
Mcu.UserName=STM32L152RETx
|
||||
MxCube.Version=6.14.1
|
||||
MxDb.Version=DB.6.0.141
|
||||
NVIC.ADC1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
@@ -150,8 +149,8 @@ SPI1.Direction=SPI_DIRECTION_2LINES
|
||||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
|
||||
SPI1.Mode=SPI_MODE_MASTER
|
||||
SPI1.VirtualType=VM_MASTER
|
||||
VP_ADC_Vref_Input.Mode=IN-Vrefint
|
||||
VP_ADC_Vref_Input.Signal=ADC_Vref_Input
|
||||
VP_ADC_TempSens_Input.Mode=IN-TempSens
|
||||
VP_ADC_TempSens_Input.Signal=ADC_TempSens_Input
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
board=custom
|
||||
|
||||
Reference in New Issue
Block a user