0% found this document useful (0 votes)
14 views3 pages

DSP Temperature Measurement Code

Uploaded by

GBEDOUROROU
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)
14 views3 pages

DSP Temperature Measurement Code

Uploaded by

GBEDOUROROU
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

REPUBLIQUE DU BENIN

********
UNIVERSITE D’ABOMEY-CALAVI
********
ECOLE POLYTECHNIQUE D’ABOMEY-CALAVI
********
Filière : GE (4 -ème année)
********

Applications sur DSP


Mesure de température

Réalisé par : Sous la direction de :


AHOUANSOU Rostand Mr MONTERO Léonard

BANOUGNIN Alimoudine

GBEDOUROROU Adam

GNELE Mauriac

GUEDENON Ange

HOUNDJO Odiyas

SEKOU Sidoine

TOPANOU Hergie

TOSSOU Elysée

ANNEE ACADEMIQUE : 2022-2023

1
CODE
float temp;
int main(void) {
/* Init system clock for maximum system speed */
TM_RCC_InitSystem();
/* Init HAL layer */
HAL_Init();
/* Init leds */
TM_DISCO_LedInit();
/* Init ONEWIRE port on PB4 pin */
TM_OneWire_Init(&OW, GPIOB, GPIO_PIN_4);
/* Check if any device is connected */
if (TM_OneWire_First(&OW)) {
/* Set LED GREEN */
TM_DISCO_LedOn(LED_GREEN);
/* Read ROM number */
TM_OneWire_GetFullROM(&OW, DS_ROM);
} else {
/* Set LED RED */
TM_DISCO_LedOn(LED_RED);
}
/* Start temp conversion */
if (TM_DS18B20_Is(DS_ROM)) {
/* Set resolution */
TM_DS18B20_SetResolution(&OW,DS_ROM,
TM_DS18B20_Resolution_12bits);
/* Set high and low alarms */
TM_DS18B20_SetAlarmHighTemperature(&OW, DS_ROM, 30);
TM_DS18B20_SetAlarmLowTemperature(&OW, DS_ROM, 10);
/* Start conversion on all sensors */
TM_DS18B20_StartAll(&OW);
}
while (1) {

2
/* Check if connected device is DS18B20 */
if (TM_DS18B20_Is(DS_ROM)) {
/* Everything is done */
if (TM_DS18B20_AllDone(&OW)) {
/* Read temperature from device */
if (TM_DS18B20_Read(&OW, DS_ROM, &temp)) {
/* Temp read OK, CRC is OK */
/* Start again on all sensors */
TM_DS18B20_StartAll(&OW);
/* Check temperature */
if (temp > 30) {
TM_DISCO_LedOn(LED_RED);
} else {
TM_DISCO_LedOff(LED_RED);
}
} else {
/* CRC failed, hardware problems on data line */
}
}
}
}
}

You might also like