Hserin


Closed Thread
Results 1 to 12 of 12

Thread: Hserin

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Question Send hex to PIC-->DS160

    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

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by ngeronikolos View Post
    My setup is CPU 16F627A internal OSC 4Mhz.I want to send via a termial(hyper or similar) a byte to pic.
    Use a 4Mhz crystal or resonator instead of the internal 4Mhz.
    HERSIN/HSEROUT are clock sensitive. The DS1620...not so much...

  3. #3
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Default

    I will try to add an external crystal BUT i do not think that this is the brpblem!!!!!!!!!!The echo sample code for HERSIN/HSEROUT is working...


    Something else happend.When It reads the byte and trying to send to DS1620
    (Shiftout).
    Last edited by ngeronikolos; - 16th December 2008 at 09:24.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by ngeronikolos View Post
    I will try to add an external crystal BUT i do not think that this is the brpblem!!!!!!!!!!The echo sample code for HERSIN/HSEROUT is working...


    Something else happend.When It reads the byte and trying to send to DS1620
    (Shiftout).
    Maybe you need to make the variable a number of some kind?
    From the manual...
    Modifier Operation
    {I}{S}BIN{1..16} Send binary digits
    {I}{S}DEC{1..5} Send decimal digits
    {I}{S}HEX{1..4} Send hexadecimal digits
    REP c\n Send character c repeated n times
    STR ArrayVar{\n} Send string of n characters
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Default

    Maybe you need to make the variable a number of some kind?
    My variable is the InChar (look the code) and I set it as a byte.

    The possible value could be $a1 or $a2 or $aa.

    When I type that value via the terminal I have it back (hserout) but I do not have correct answer from the DS1620.

    The strange thing is that I send
    $a1

    and I receive back
    $
    a
    1

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Code:
    hserin 100,start,[WAIT($), HEX InChar]
    Shiftout DQ, CLK, MSBFIRST, ["$",HEX InChar]
    MAYBE????
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Do you have a Pull-Up resistor on PORTA.4 (RST)?

    It's an Open Collector output, so it can't go HIGH on it's own.

    DT

Similar Threads

  1. HSERIN and XOUT command
    By aratti in forum General
    Replies: 20
    Last Post: - 12th May 2009, 11:58
  2. Instant Interrupts and HSERIN
    By Rob in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 31st January 2009, 05:13
  3. TMR0 interrupt and HSERIN
    By boban in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2008, 11:48
  4. 16F877a Interupt driven Hserin
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd November 2006, 00:38
  5. Hserin
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th November 2004, 15:42

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts