This tutorial describes a simple application for measuring temperature using the digital sensor DS18B20 and the Arduino Multifunction Shield connected to FRDM K64F. You can use new feature Expansion Boards (expansion shields) included in the Pins tool v9. This feature enables quick integration of shields in an application without the need to study manuals.
In this paper, you can find the environment setup, 1-wire protocol basics, and the steps of preparing a code with MCUXpresso tools (Peripherals and Pins tool).
Figure 1 FRDM K64F EVK board with Arduino Multi-Function shield
See the documentation https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf
This tutorial uses powering with an external supply.
Figure 2 Powering the DS18B20 with an External Supply
See the timing diagrams for communication with the DS18B20, needed for writing 1-Wire communication protocol.
Figure 3 Initialization Timing
Figure 4 Read/Write Time Slot Timing Diagram
The application only uses the following 1-wire protocol commands:
Begin with the hello_word example from SDK, rename the project to frdmk64_termometer.
Figure 5 PIT component in the Peripherals tool
Figure 6 Apply expansion board dialog
Figure 7 Expansion board routing dialog
Figure 8 Expansion header view
Figure 9 Electrical properties in the Routing Details view
Rename the source file hello_world.c to thermometer.c and follow the steps below. Find the completed thermometer.c in the project.
Figure 10 Generated code for ARDUINO_A4_PIN
Figure 11 Methods for reading/writing bytes
Build the project and start debugging.
Figure 12 Output from the application