2014-09-19 04:19 AM
Hello friends.
I'm trying to communicate with DS18B20 via 1-wire interface.
Here is the example of reset function (all pins and clk are set erlier). The problem is that the variable data
does not receive UART7 DR value. I use EWARM. I see that DR receives the response from the DS18B20. Is this
some compiler options?print_number (data) � prints 3 digit number on the LCD. In this function it is always 255, however data
variable is unavailable in the watch window.
void ow_reset()
{
USART_InitTypeDef USART_InitStructure;
uint16_t data;
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_Init(UART7,&USART_InitStructure);
USART_Cmd(UART7,ENABLE);
USART_ClearFlag(UART7, USART_FLAG_TC);
USART_SendData(UART7, 0xf0);
data = USART_ReceiveData(UART7);
while(USART_GetFlagStatus(UART7, USART_FLAG_RXNE) == RESET);
while (USART_GetFlagStatus(UART7, USART_FLAG_TC) == RESET);
print_number (data);
}
#debugger-is-invasive #1-wire2014-09-20 03:01 AM
So what would be the best way of checking the correct response from the DS18B20?