How do I format HSERIN?


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Don't send 123:CRLF as 495051581310....send it as 123:<CR> with line feeds turned on at the PC.
    HSERIN doesn't need to use raw hex codes for the data (i.e. sending 10 for a line feed, etc).

    Are you using the internal oscillator on the PIC?
    The internal oscillator isn't always accurate. Could cause your baud rate to be off by just enough to confuse everything.

    Are you using a MAX232 type device between the PIC and the PC?
    The hardware UART uses 'TTL-RS232', commonly called 'Normal' in PBP circles. Try using SERIN2/SEROUT2 and using an inverted mode if you don't have a MAX232.

    Are you sure the PIC is configured correctly for the desired baud rate?
    Can get a bit confusing with all of the options a PIC has. Double check them...

    Are you sure the config registers/any other registers are set up correctly?
    Internal vs. External crystals...and so on and so on...

  2. #2
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    I am using MAX32 between the PC and PIC.

    HSEROUT works every time no matter what I send. Thank makes me assume that the BAUD issue is OK.

    Here is how I check what I am receiving:

    HSEROUT ["B1 ", MyVars(0), $0d,$0a]
    HSEROUT ["B2 ", MyVars(1), $0d,$0a]
    HSEROUT ["B3 ", MyVars(2), $0d,$0a]
    HSEROUT ["B4 ", MyVars(3), $0d,$0a]
    HSEROUT ["B5 ", MyVars(4), $0d,$0a]

    etc..

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by PlantBob View Post
    I am using MAX32 between the PC and PIC.
    HSEROUT works every time no matter what I send. Thank makes me assume that the BAUD issue is OK.
    Ok, just checking, didn't have that info before.
    Like I said before, don't send the raw hex data back and forth, just send the characters themselves.
    Code:
    MyVars VAR BYTE[8] : temp var byte
    Main: HSERIN 5000,NoData,[STR MyVars\6\":"]
    HSEROUT ["Received:", STR myvars\8",13,10] : goto main
    NoData: HSEROUT ["Timeout",$0d,$0a]
    for temp = 0 to 8 : myvars[temp]=0 : next temp 'clean out myvars
    Goto main
    At the PC, type in a few characters (no hex codes, nothing crazy, just a few alpha or number characters), followed by the : character.
    The code above should wait for 5 seconds to 1)get no data, 2) get 6 bytes of data, or 3)will kick out and send back the data you just sent if you sent a : before you sent a total of 6 bytes.

  4. #4
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59


    Did you find this post helpful? Yes | No

    Default

    Hi Skimask

    Counter 0 to 7, perhaps? And possibly no quote marks in third line after 8?

    Adrian

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Adrian View Post
    Hi Skimask
    Counter 0 to 7, perhaps? And possibly no quote marks in third line after 8?
    Adrian
    Quote marks - yes...
    Counter 0 to 7 - perfectly valid.
    MyVars var Byte[8] sets aside 9 bytes, index 0 (zero) is also valid.

  6. #6
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59


    Did you find this post helpful? Yes | No

    Default

    Hi Skimask
    Thanks but there is something I'm not understanding. I've tried your programme and it works fine until the first timeout then it won't 'goto main' and loop through again. Should it? If I change the counter to FOR temp = 0 to 7 then the programme loops round endlessly. What am I not understanding or what am I doing wrong? Please help - going mad here!!

    Adrian

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Might get a couple of hints from this:
    http://www.picbasic.co.uk/forum/show...ht=hserin+idle

    If not there, then try a search on serial and idle and see what happens.

Similar Threads

  1. TMR0 interrupt and HSERIN
    By boban in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2008, 12:48
  2. Serout format
    By aftab in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd August 2007, 08:12
  3. 16F877a Interupt driven Hserin
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd November 2006, 01:38
  4. Can a TMR interrupt stops HSERIN?
    By SergioRM in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th January 2006, 02:07
  5. Hserin
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th November 2004, 16:42

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