PDA

View Full Version : PIC lcd ds1820



wchpikus
- 24th May 2007, 09:18
Hello!
I starting programm this device.
I have some code, but ds not working.
Could someone check this?

Define CONF_WORD = 0x3f72
Define CLOCK_FREQUENCY = 6
AllDigital

Define LCD_BITS = 8
Define LCD_DREG = PORTD
Define LCD_DBIT = 0
Define LCD_RSREG = PORTE
Define LCD_RSBIT = 0
Define LCD_RWREG = PORTE
Define LCD_RWBIT = 1
Define LCD_EREG = PORTE
Define LCD_EBIT = 2
Define LCD_READ_BUSY_FLAG = 1
Define 1WIRE_REG = PORTA
Define 1WIRE_BIT = 1
Lcdinit


Dim i As Byte
Dim j1 As Byte
Dim j2 As Byte
Dim por1 As Byte
Dim por2 As Byte
Dim text As char

main:
text = "Temperature:"
PORTB = 0 ' initialize PORTB to 0
PORTA = 255 ' initialize PORTA to 255
TRISB = 0 ' PORTB is output
TRISA = 255 ' PORTA is input
lcd_init(PORTB)
lcd_cmd(lcd_cursor_off)
lcd_out(1, 1, text)
do
ow_reset(PORTA, 5) ' 1-wire reset signal
ow_write(PORTA, 5, $cc) ' issue command to DS1820
ow_write(PORTA, 5, $44) ' issue command to DS1820
delay_ms(120)
i = ow_reset(PORTA, 5)
ow_write(PORTA, 5, $cc) ' issue command to DS1820
ow_write(PORTA, 5, $be) ' issue command to DS1820
delay_ms(1000)
j1 = ow_read(PORTA, 5) ' get result
j2 = ow_read(PORTA, 5) ' get result
j1 = j1 > > 1 ' assuming the temp. >= 0C
bytetostr(j1, text) ' convert j1 to text
lcd_out(2, 8, text) ' print text
lcd_chr(2, 10, 223) ' degree character (°)
lcd_chr(2, 11, "C")
delay_ms(500)
loop until False ' endless loop
End .

skimask
- 24th May 2007, 13:25
Hello!
I starting programm this device.
I have some code, but ds not working.
Could someone check this?


That's Proton Basic. This is PicBasicPro.
Proton Basic <> PicBasicPro.

mister_e
- 24th May 2007, 14:46
It's not Proton, looks more OshonSoft's PICBasic to me

http://www.oshonsoft.com/pic.html

Sorry, i can't help much :(