how to hserin compare with known value?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2008
    Posts
    13

    Post how to hserin compare with known value?

    hi all ,
    this is my first post and i hope help from all .My problem is i can not compare my file my file is
    $07 $06 $0D $CA $2E $56 $00 $C9 $77 .when this file recive i want flash led portc.3 on with pic16f688. i get corect boud 115200 with crystal 11.0592 Mhz i also check hserin and hserout
    same. my code is below

    @ DEVICE PIC16F688, HS_OSC, WDT_OFF, PWRT_OFF, MCLR_OFF, BOD_OFF,PROTECT_OFF
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 5 ' 115200 Baud @ 11.0592MHz, 0.0%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $24 ' Enable transmit, BRGH = 1
    SPBRG = 5 ' 115200 Baud @ 11.0592MHz, 0.0%
    ANSEL = 0 'ALL DIGITAL
    INTCON = 0 'Disable interrupts
    DATAIN VAR byte[9]
    main:
    HSERIN [WAIT($07), str DATAIN\8]
    'if datain = $07,$06,$0D,$CA,$2E,$56,$00,$C9,$77
    hserout [str datain\9]

    goto main
    END
    sorry for my english

  2. #2
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default

    Try something like this
    Code:
    HSERIN [WAIT($07), str DATAIN\8]
    if datain[0] = $07 and  datain[1] =$06 and  datain[2] =$0D  and  datain[3] =$CA  and  datain[4] =$2E  and  datain[5] =$56 and  datain[6] =$00 and  datain[7] =$C9  and  datain[8] =$77 then hserout [str datain\8]
    or this
    Code:
    str[0]= $07:.....:str[7]=$77
     HSERIN [WAIT($07), str DATAIN\8]
    for i = 0 to 8
    IF str[i]<>datain[i] then goto DO_NOT_SEND
    next i
    hserout [str datain\8]
    do_not_send:

  3. #3
    Join Date
    Oct 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    first of all many thanks for repply dear pedja089
    now my code like this,

    main:
    HSERIN [WAIT($07), str DATAIN\8]
    if datain[1] = $06 then high portc.3
    hserout [str datain\8]
    goto main
    END

    this not working

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default

    Datain[1] is second byte in string.
    If you wait number 7, then that byte isn't in datain array.
    If you sent 7,6,12, then in datain first byte is 6, second is 12, so you need something like this
    Code:
    HSERIN [WAIT($07), str DATAIN\8]
    if datain[0] = $06 then high portc.3
    And now if you send 7,then 6, and 6 more byte portc will go high.

  5. #5
    Join Date
    Oct 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    many many thanks dear pedja089
    now code is working
    what methed in short becuse i have too bytes for compare for example
    hex :07 06 00 82 2D A1 00 D7 D8 , 07 06 00 82 2D CF 35 C4 90 , 07 06 00 82 2E 2F 35 C4 73 , many more ,so
    i want further help?

  6. #6
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default

    Try both ways and see which is faster.

  7. #7
    Join Date
    Oct 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    thanks ,
    now i want write this 9 byte data and read its back .How this posible my mean how to write aray and read it again.
    Regards

Members who have read this thread : 1

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