getting a program to display on usart

Status
Not open for further replies.

MrDEB

Well-Known Member
trying to get a OW device (DS18B20) to display on an LCD display.
Starting from ground zero again and seeing if I can even communicate with the sensor
tried several codes but nada
going to start with the code that displays using the usart but how to get it to display on computer screen?
figure I would start there again
using a Junebug for programming.
And yes I can get text to display on the LCD by including LCD bas and removing usart bas
Code:
// device and clock speed...
device = 18F452
clock = 20

// import modules...
include "DS18B20.bas"
include "convert.bas"
include "usart.bas"

// FAMILY $28 ($1D) ($0000002CDBAE) <- DS18B20
// FAMILY $28 ($3F) ($0000002CD16E) <- DS18B20
const Sensor_A(8) as byte = ($28, $AE, $DB, $2C, $00, $00, $00, $1D)
const Sensor_B(8) as byte = ($28, $6E, $D1, $2C, $00, $00, $00, $3F)

// display a sensor value...
sub DisplaySensor(byrefconst pID() as byte)
   dim TempA as shortint
   dim TempB as word
   RomID = pID
   Convert
   GetTemp(TempA, TempB)
   USART.Write(DecToStr(TempA),".",DecToStr(TempB,2), $BA, "C",13,10)
end sub

// program start...
SetBaudrate(br115200)
SetPin(PORTC.0)
while true
   DisplaySensor(Sensor_A)
   DisplaySensor(Sensor_B)
   delayms(1000)
wend
 
Found Usart tool in Pickit2

but switch setting on Junebug?
have TX on but can't program the pic.
turn off TX and can program the PIC
BUT get no reading on Usart?
The LED comes on but does not blink as it is supposed to?
Code:
device = 18F452
clock = 20

// import modules...
include "DS18B20.bas"
include "convert.bas"
include "usart.bas"

// working variables...
dim
   TempA as shortint,
   TempB as word,
   LED as PORTB.0

// Start Of Program...
SetBaudrate(br19200)
SetPin(PORTC.0)
output(LED)

// Find() will search the bus for a single DS1820 device
// and load its ROM ID into the DS1820 public variable RomID - you
// could do this manually. For example, RomID = MyRomID...

if DS18B20.Find then
    while true
      Convert
      GetTemp(TempA, TempB)
      USART.Write(DecToStr(TempA),".",DecToStr(TempB,4), " C", 13, 10)
      toggle(LED)
      delayms(1000)
    wend 
else
    high(LED)   
    USART.Write("No device found", 13, 10)
endif
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…