mikroElektronika PIC Microcontrollers PIC12 User Manual page 243

Mikroc user's manual
Table of Contents

Advertisement

mikroC
making it simple...
Library Example
unsigned temp;
unsigned short
void Display_Temperature(unsigned int temp) {
//...
}
void main() {
ADCON1 = 0xFF;
PORTA
= 0xFF;
TRISA
= 0x0F;
PORTB
= 0;
TRISB
= 0;
// Initialize LCD on PORTB and prepare for output
do {
OW_Reset(&PORTA,5);
OW_Write(&PORTA,5,0xCC);
OW_Write(&PORTA,5,0x44);
Delay_us(120);
OW_Reset(&PORTA,5);
OW_Write(&PORTA,5,0xCC);
OW_Write(&PORTA,5,0xBE);
Delay_ms(400);
j = OW_Read(&PORTA,5);
temp = OW_Read(&PORTA,5);
temp <<= 8; temp += j;
Display_Temperature(temp);
Delay_ms(500);
} while (1);
}//~!
MikroElektronika: Development tools - Books - Compilers
j;
// Configure RA5 pin as digital I/O
// PORTA is input
// PORTB is output
// Onewire reset signal
// Issue command SKIP_ROM
// Issue command CONVERT_T
// Issue command SKIP_ROM
// Issue command READ_SCRATCHPAD
// Get temperature LSB
// Get temperature MSB
// Form the result
// Format and display result on LCD
mikroC - C Compiler for Microchip PIC microcontrollers
page
235

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents