stm32-async-1wire 3.2.0
Non-blocking 1-Wire master for STM32 with DS18B20 temperature and DS2431 EEPROM drivers
Loading...
Searching...
No Matches
DS18B20 Non-Blocking Resolution Change

Change the temperature conversion resolution (9..12 bit) between measurement cycles. The sensor answers Convert T (0x44) after 93.75ms (9 bit) / 187.5ms (10 bit) / 375ms (11 bit) / 750ms (12 bit); this driver waits exactly as long as the configured resolution requires and parks until the application starts the next measurement cycle. More...

Functions

void ds18b20_set_resolution (uint8_t bits)
 Start a non-blocking resolution change.
uint8_t ds18b20_set_resolution_poll (void)
 Advance the non-blocking resolution change by one hardware operation.
uint8_t ds18b20_get_resolution (void)
 Current conversion resolution in bits.

Detailed Description

Change the temperature conversion resolution (9..12 bit) between measurement cycles. The sensor answers Convert T (0x44) after 93.75ms (9 bit) / 187.5ms (10 bit) / 375ms (11 bit) / 750ms (12 bit); this driver waits exactly as long as the configured resolution requires and parks until the application starts the next measurement cycle.

The configuration is written to the volatile scratchpad (Write Scratchpad 0x4E): it takes effect immediately and is not persisted to the EEPROM. Alarm trigger registers TH/TL are reset to 0x00 (disabled).

Function Documentation

◆ ds18b20_get_resolution()

uint8_t ds18b20_get_resolution ( void )

Current conversion resolution in bits.

Returns
Resolution in bits (9..12); the default is 12
Note
Auto-derived from the last valid scratchpad read (byte 4, R1/R0), so it also tracks a resolution changed externally.

◆ ds18b20_set_resolution()

void ds18b20_set_resolution ( uint8_t bits)

Start a non-blocking resolution change.

Parameters
[in]bitsNew resolution in bits: DS18B20_RES_MIN (9) .. DS18B20_RES_MAX (12)
Note
Out-of-range values are ignored. The change is scheduled only between measurement cycles and only while the device search is idle; otherwise it is ignored. While running, it owns TIM1/DMA; poll it with ds18b20_set_resolution_poll() until it reports completion, then call ds18b20_start_measure() to measure with the new resolution.

◆ ds18b20_set_resolution_poll()

uint8_t ds18b20_set_resolution_poll ( void )

Advance the non-blocking resolution change by one hardware operation.

Returns
1 when the change is finished (successfully or aborted), 0 while running
Note
When this returns 1 the next measurement uses the requested resolution (if the config write actually completed).