Skip to content

Latest commit

 

History

History
77 lines (52 loc) · 4.1 KB

File metadata and controls

77 lines (52 loc) · 4.1 KB

CH32V003 Microcontroller OneWire Example with DS18x20 Sensors

Overview

This example demonstrates how to use a CH32V003 microcontroller to communicate with DS18S20, DS1820, DS18B20, or DS1822 temperature sensors using the OneWire protocol. The CH32V003 is a cost-effective 48 MHz RISC-V microcontroller with 16kB of flash and 2kB of RAM, suitable for various applications.

Features

  • Searches for temperature sensors on Pin C4.
  • Iterates over each sensor to prompt a temperature read.
  • Waits for the read to occur and then prints the temperatures.
  • Utilizes printf() over the CHLINK single-wire serial interface for output.

Installation and Setup

  • For detailed installation instructions of the development environment, refer to the ch32v003fun project wiki.
  • The project supports printf debugging and gdbserver-style debugging via minichlink.
  • Building and flashing instructions can be found in the examples/blink directory.

Hardware Requirements

  • SWIO on PD1 is required for programming/debugging.
  • PC4 connected to DS18x20 sensor data. (Don't forget the external pull-up resistor to VCC)

Additional Resources

Resources from Pallav Aggarwal's Blog

Sensors and Maxim OneWire Library

  • The example is compatible with DS18S20, DS1820, DS18B20, and DS1822 temperature sensors.
  • The simplified Maximum OneWire library is designed to efficiently handle communication with multiple sensors over a single wire.

Notes on CH32V003

  • The CH32V003 operates at different performance levels depending on whether it runs from RAM or FLASH due to varying wait states.
  • For further technical details, refer to the Debugging Manual and Processor Manual.
  • An external oscillator was used during testing.

Microcontroller Information (CH32V003)

  • CH32V003 Microcontroller Details
    • Features a 48MHz system main frequency, 2KB SRAM, 16KB Flash.
    • Includes a variety of peripherals such as USART, I2C, SPI, ADC, and timers.
    • Offers multiple low-power modes and a 1-wire serial debug interface.

In a tiny world of silicon and wire,

Lives a microcontroller, CH32V003, with a desire.

To speak in tongues of RISC-V, so clear,

Whispering to sensors, both far and near.

Through OneWire it travels, a single thread,

Carrying tales of temperatures, both blue and red.

"Too hot or cold?" the sensors keenly measure,

In a dance of bytes, they find their treasure.

In this realm of circuits, small and spry,

Micro wonders unfold, under the digital sky.