Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Ow_Write
Library Example
This example reads the temperature using DS18x20 connected to pin PORTB.2. After reset,
MCU obtains temperature from the sensor and prints it on the Lcd. Make sure to pull-up PORTB.2
line and to turn off the PORTB leds.
program OneWire;
// Lcd module connections
var LCD_RS : sbit at PORTD.B2;
LCD_EN : 
sbit at PORTD.B3;
LCD_D4 : 
sbit at PORTD.B4;
LCD_D5 : 
sbit at PORTD.B5;
LCD_D6 : 
sbit at PORTD.B6;
LCD_D7 : 
sbit at PORTD.B7;
LCD_RS_Direction : 
sbit at DDRD.B2; 
LCD_EN_Direction : 
sbit at DDRD.B3;
LCD_D4_Direction : 
sbit at DDRD.B4; 
298
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure Ow_Write(par: byte);
Returns
Nothing.
Description
Writes one byte of data via the OneWire bus.
Parameters : 
par
: data to be written 
Requires
Devices compliant with the Dallas OneWire protocol.
Global variables : 
OW_Bit_Read
: OneWire read line 
OW_Bit_Write
: OneWire write line. 
OW_Bit_Direction
: Direction of the OneWire pin 
must be defined before using this function.
Example
// OneWire pinout
var OW_Bit_Read : sbit at PINB.B2;     
var OW_Bit_Write : sbit at PORTB.B2;   
var OW_Bit_Direction : sbit at DDRB.B2;
// end of OneWire pinout
// Send a byte to the One-Wire Bus
Ow_Write(0xCC);