Hello to everybody,
I have ALSO a problem with HSERIN(?).
My setup is CPU 16F627A internal OSC 4Mhz.I want to send via a termial(hyper or similar) a byte to pic.
The PIC reads the byte and it sends to the DS1620 Digital Thermometer and Thermostat.That is not working......
FOR EXAMPLE if i send via the termial the hex A1 (this is the InChar) I should have take an answer to the terminal with the stored value of high temperature limit.The DS1620 is working with the PIC.
BUT I CAN NOT FIND THE MISTAKE
HERE IS MY FULL CODE
--------------------------------------------------------
include "modedefs.bas"
@ DEVICE pic16F627A, INTRC_OSC_NOCLKOUT ' system clock options
@ DEVICE pic16F627A, WDT_ON ' watchdog timer
@ DEVICE pic16F627A, PWRT_ON ' power-on timer
@ DEVICE pic16F627A, MCLR_OFF ' master clear options (internal)
@ DEVICE pic16F627A, BOD_OFF ' brown-out detect
@ DEVICE pic16F627A, LVP_OFF ' low-voltage programming
@ DEVICE pic16F627A, CPD_OFF ' data memory code Protect
@ DEVICE pic16F627A, PROTECT_OFF ' program code protection
CMCON = 7 'Turn off comparators
VRCON = 0
INTCON = 0 ' Disable interrupts
' DEFINE VARIABLES FOR SERIAL TO PC 2400 8-N-1
;DEFINE NO_CLRWDT 1
DEFINE HSER_CLROERR 1 'Automatically clear over-run errors
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
;DEFINE HSER_CLROERR 1
;DEFINE HSER_RCSTA 90H
;DEFINE HSER_TXSTA 20H
;DEFINE HSER_BAUD 2400
;DEFINE HSER_SPBRG 25
' DS1620 control pins
RST var PORTA.4 ' Reset pin
DQ var PORTA.2 ' Data pin
CLK var PORTA.3 ' Clock pin
INPUT PORTA.3
INPUT PORTA.4
' Allocate variables
temp var word ' Storage for temperature
InChar VAR byte
RCIF VAR PIR1.5
Low RST ' Reset the device
;-----------------------------------------------------------------
START:
While RCIF = 1
hserin 100,start,[InChar]
mainloop:
RST = 1 ' Enable device
Shiftout DQ, CLK, LSBFIRST, [$ee];Shiftout DQ, CLK, LSBFIRST, [$ee] ' Start conversion
RST = 0
Pause 1000 ' Wait 1 second for conversion to complete
RST = 1
Shiftout DQ, CLK, MSBFIRST, [InChar] ' Send read command
HSERout [InChar]
Shiftin DQ, CLK, LSBPRE, [temp\9] ' Read 9 bit temperature
RST = 0
' Display the decimal temperature
hserout [" Temp = ",dec (temp >> 1), ".", dec (temp.0 * 5)," oC",13]
Wend
Goto START ' Do it forever
End
-----------------------------------------------------------
PLEASE I need your advice
Thanks
Nikos
Bookmarks