source: trunk/firmware_v2/SES/src/chip_temperature.c@ 24

Last change on this file since 24 was 24, checked in by f.jahn, 4 months ago
LVP, OVP, LVP
OVP modes implementiert
  • Lüftersteuerung in eigenes Modul verlagert
File size: 2.5 KB
Line 
1/******************************************************************************
2*
3* @file chipTemperature.c
4* @author ECS, Joseph Zimmer
5* @version V1.0.0
6* @date 24-04-2019
7* @brief
8*
9******************************************************************************/
10
11// --- INCLUDES -----------------------------------------------------------------
12#include <stdio.h>
13//#include <stdlib.h>
14#include "chip_temperature.h"
15
16// --- EXTERNE VARIABLEN --------------------------------------------------------
17
18// --- LOKALE DEFINES - bitte hier dokumentieren --------------------------------
19
20// --- LOKALE TYPE DEFS - bitte hier dokumentieren-------------------------------
21
22// --- DEFINITIONEN GLOBALER VARIABLEN - Bitte in Header dokumentieren ----------
23
24// --- LOKALE VARIABLEN - bitte hier dokumentieren ------------------------------
25uint32_t calTemperatureSensor30Value; // Kalibrierungswert für den Temperatursensor auf dem STM32G0 (Werksmäßig im SCB Bereich gespeichert wird beim Programmstart ausgelesen)
26 // Daten Temperaturanzeige µProzessor
27int32_t temp;
28// --- LOKALE FUNKTIONS PROTOTYPEN ----------------------------------------------
29
30void calc_temp_compensation(void);
31
32
33// --- LOKALE FUNKTIONEN - bitte hier dokumentieren -----------------------------
34
35/*
36* @brief
37* @param kein
38* @retval kein
39*/
40
41// --- GLOBALE FUNKTIONEN - bitte in Header dokumentieren------------------------
42void CHIP_TEMPERATURE_Calibration(void)
43{
44 uint16_t * pCalibrationData;
45 float calibrationData30;
46 float calibrationData130;
47
48 // lade Temperatur Kalibrierungswert (Wert bei 30°C)
49 pCalibrationData = (uint16_t *)TEMPSENSOR_CAL1_ADDR;
50 calibrationData30 = * pCalibrationData;
51
52 //Berechnung Spannung in mV bei CAL Punk 30°C
53 //Kalbibrierung wurde mit 12 Bit und 3000mV Vref durchgeführt
54 calibrationData30 = calibrationData30 / 4096;
55 calTemperatureSensor30Value = calibrationData30 * 3000 ; // jetzt haben wir die Kalibrierungsspannung in mVolt bei 30°C;
56}
57
58void CHIP_TEMPERATURE_Exec(uint32_t adcValue)
59{
60
61 //Aktuelle Spannung am Temp Sensor
62 temp = (3300 * (uint32_t)adcValue) / 65536;
63
64
65 temp = temp - (calTemperatureSensor30Value);
66
67 temp = temp / 2.530; //2,53mV/°C
68 temp = temp + 25; //30000 da Erste Kalibrierpunkt bei 25°C --> 25
69
70}
71
72int CHIP_TEMPERATURE_GetTemp(void)
73{
74 return temp;
75}
76
77
78//------------------------------------------------------------------------------
79
80
81
Note: See TracBrowser for help on using the repository browser.