AdyMareshal
Newbie level 1

I am using 18F2550 connected to a DS18B20 using PORTC.RC1, compiled with MikroC for PIC and virtual terminal in proteus. The terminal is working, but the rest doesn't
Here's the code I am using
Anyone can give me a working code in 18F2550, or make this code work? I've tried the mikroC example code, but didn't succeded.
Thanks a lot
Here's the code I am using
Code:
char t;
int temp;
void ds1820_read()
{
Ow_Reset(&PORTC, 1); // 'Reset
Ow_Write(&PORTC, 1, 0xCC);// 'Skip ROM
Ow_Write(&PORTC, 1, 0x4E);// 'Write to scratchpad
Ow_Write(&PORTC, 1, 0x55);// 'TH register value (85 degrees C)
Ow_Write(&PORTC, 1, 0x19);// 'TL register value (25 degrees C)
Ow_Write(&PORTC, 1, 0x7F);// 'Config register value (12bit)
// 'Do temp conversion
Ow_Reset(&PORTC, 1);// ' Reset
Ow_Write(&PORTC, 1, 0xCC);// 'SKIP_ROM
Ow_Write(&PORTC, 1, 0x44);// ' Issue command CONVERT_T
Delay_us(120);
// 'Read Temp
Ow_Reset(&PORTC, 1);
Ow_Write(&PORTC, 1, 0xCC);// 'SKIP_ROM
Ow_Write(&PORTC, 1, 0xBE);// 'READ_SCRATCHPAD
temp = Ow_Read(&PORTC, 1);
temp = (Ow_Read(&PORTC, 1) << 8) + temp;
}
void main() {
UART1_Init(9600);
Delay_ms(100);
UART1_Write_Text("DS18B20: ");
TRISC = 0b00000010;
while(1)
{
ds1820_read();
UART1_Write_Text(temp);
UART1_Write('\r\n');
Delay_ms(300);
}
}
Anyone can give me a working code in 18F2550, or make this code work? I've tried the mikroC example code, but didn't succeded.
Thanks a lot