I tried to compile ME's "OneWire Library"
"Mikroelektronika\mikroBasic dsPIC\Examples\LV_24_33\Extra examples\One_Wire"
code just changing the MCU to PIC33FJ128GP710
but it gave "Identifier 'ADPCFG' was not declared " error .Is it ok to compile this code just commenting the error line or what are the necessary changes to Compile and work this
My tools are Lv 24-33 development board with PIC33FJ128GP710, Lcd 2x16 and ds1820,
mikroBasic compiler for Microchip dsPIC 30/33 and PIC 24 microcontrollers Version: 5.0.0.0
Help me please.
Code: Select all
' *
' * Project name:
' Onewire_Test (Interfacing the DS1820 temperature sensor)
' * Target Platform:
' dsPIC, PIC24;
' * Copyright:
' (c) Mikroelektronika, 2006.
' * Revision History:
' 20060512:
' - Initial release
' * Description:
' This code demonstrates one-wire communication with temperature sensor DS1820.
' After reset, dsPIC obtaines temperature from sensor and prints it on LCD.
' * Test configuration:
' MCU: PIC24FJ96GA010
' Dev.Board: LV 24-33
' Oscillator: XT-PLL4, 10.000 MHz
' Modules: DS18x20, Lcd_2x16
' SW: mikroBasic for dsPIC30/33 and PIC24 v4.0.0.0
' * NOTES:
' - In order to have valid readings, the 1Wire pin must be connected to
' pull-up resistor and 1Wire diode turned off! In this example, it is the PORTD.10 pin.
' - Connect temp sensor to RD10 with jumper j2
program OneWire
' Set TEMP_RESOLUTION to the corresponding resolution of your DS18x20 sensoras
' 18S20as 9 (default setting can be 9,10,11,or 12)
' 18B20as 12
const TEMP_RESOLUTION as byte = 12
dim
j as byte
temp as word
text as string[8] ' "000.0000"
sub procedure Read_Temperature()
Ow_Reset(PORTD,10) ' Onewire reset signal
Ow_Write(PORTD,10,0xCC) ' Issue command SKIP_ROM
Ow_Write(PORTD,10,0x44) ' Issue command CONVERT_T
Delay_us(120)
Ow_Reset(PORTD,10)
Ow_Write(PORTD,10,0xCC) ' Issue command SKIP_ROM
Ow_Write(PORTD,10,0xBE) ' Issue command READ_SCRATCHPAD
Delay_ms(400)
j = OW_Read(PORTD,10) ' Get temperature LSB
temp = OW_Read(PORTD,10) ' Get temperature MSB
temp = temp << 8
temp = temp + j ' Form the 2byte variable
end sub
sub procedure Write_Temp(dim temp2write as word)
const
RES_SHIFT as byte = TEMP_RESOLUTION - 8
dim
temp_whole as byte
temp_fraction as word
if ((temp and 0x8000) > 0) then
text[0] = "-"
temp2write = (not temp2write) + 1
end if
temp_whole = temp2write >> RES_SHIFT
if (temp_whole div 100) then
text[0] = temp_whole div 100 + 48
end if
text[1] =(temp_whole div 10) mod 10 + 48
text[2] = temp_whole mod 10 + 48
temp_fraction = temp2write << (4-RES_SHIFT)
temp_fraction = temp_fraction and 0x000F
temp_fraction = temp_fraction * 625
text[4] = temp_fraction div 1000 + 48
text[5] = (temp_fraction div 100) mod 10 + 48
text[6] = (temp_fraction div 10) mod 10 + 48
text[7] = temp_fraction mod 10 + 48
Lcd_Out(2,1,text)
end sub
' ----Main----
main:
text = "000.0000"
ADPCFG = 0xFFFF
Lcd_Init_LV_24_33()
Lcd_Cmd(LCD_CLEAR)
Lcd_Cmd(LCD_CURSOR_OFF)
Lcd_Out(1,1,"temperature")
'--- main loop
while TRUE
Read_Temperature()
Write_Temp(temp)
Delay_ms(1000)
wend
end.