2015-05-29 10:48 PM
I tried to interface Digital Temperature Sensor DS18B20 with STM32F051xx but am getting struct in configuring the pin for the sensor. As in controller we doesn't have the dual mode so how we can configure single pin as OUT and IN for the communication to be done. So that we can get the sensor values....
2015-05-30 05:10 AM
Find in this post's attachments a library (license GPL3) by Tilen Majerle for DS18B20 implementing 1-wire for STM32F4 and another, simpler one for STM32F1. I'm sure those can help you when developing it for STM32F0.
________________ Attachments : stm32f1_ds18b20.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I17Z&d=%2Fa%2F0X0000000bid%2Fl3pPob0HgVcZX5tbGijtu7zW5yMABqa5N3FhthYegNw&asPdf=falsestm32f4_ds18b20.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I17P&d=%2Fa%2F0X0000000bie%2FRhKrtDpB066IzLn6YYfrebAtXcX2wywB_s8n_Ga0xqo&asPdf=false2015-05-30 05:12 AM
Hello,
I have to measure DS18B20 too and I have used this program to initialze the ort of DS18B20:#define DQ_PORT GPIOC #define DQ GPIO_Pin_6 #define DQ_RCC_PORT RCC_AHBPeriph_GPIOC #define ResetDQ() GPIO_ResetBits(DQ_PORT,DQ) // bit value is 0#define SetDQ() GPIO_SetBits(DQ_PORT,DQ) // bit value is 1 #define GetDQ() GPIO_ReadInputDataBit(DQ_PORT, DQ) void InDQ(void){ GPIO_InitTypeDef GPIO_InitStructure; RCC_AHBPeriphClockCmd(DQ_RCC_PORT, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = DQ; GPIO_Init(DQ_PORT, &GPIO_InitStructure); }void OutDQ(uint8_t pos){ GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(DQ_RCC_PORT, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = DQ; GPIO_Init(DQ_PORT, &GPIO_InitStructure); if(pos) SetDQ(); else ResetDQ(); }Have a good day......