Interupts and Command string


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    bah as you wish. You can even do some handshake between PIC and PC.

    PIC side:
    1. Waiting for Flag (must be Fix format 1,2,3 or more character) Lets'say BEER
    2. choose according procedure to do (Corect HSERIN), Send Confirmation to PC (OK i got Beer, send me another Crate now)

    and there still many other way.. it's up to you
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154

    Default

    Sorry Steve, don't understand what you mean.

    Maybe i haven't had enough 'beer'.

    This is what i have come up with so far, but its still not working.

    Code:
    USARTInterrupt:
        '    Here's the interrupt routine
    
        HSERIN [Qualifier]
        Branch QUALIFIER,[Sub1,Sub2,Sub3]
    
    Sub1:
        HSERIN [DEC2 hours, DEC2 Minutes, DEC2 Seconds, DEC2 suseconds]
        Write 5, hours
        Write 6, minutes
        Write 7, seconds
        write 8, suseconds
        HSEROUT ["You sent Red", DEC2 hours, DEC2 Minutes, DEC2 Seconds, DEC2 suseconds]
    return
    
    Sub2:
        HSEROUT ["You sent Blue"]
    
    
    Sub3:
        HSEROUT ["You send Green"]
    
    Resume
    enable interrupt
    I guess i want it to check that the qualifier is either 'Red', 'Blue', or 'Green', If it isn't then come out of the interupt and wait for the next serial string. This is the bit of code i am missing and having problems with !!

    If for example the qualifier Red is received, then it jumps to the Sub1 routine and captures the other 8 bytes.

    Am i on the right tracks with what i have done so far? Can you assist with the qualification side?

    Cheers,

    Steve

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Something to mess 'round with i guess this weekend for me.. one more

    How about that untested version
    Code:
    USARTInterrupt:
        '    Here's the interrupt routine
    
        HSERIN [DEC Qualifier]
        Branch QUALIFIER,[Sub1,Sub2,Sub3]
    
    Sub1:
        HSERIN [DEC2 hours, DEC2 Minutes, DEC2 Seconds, DEC2 suseconds]
        Write 5, hours
        Write 6, minutes
        Write 7, seconds
        write 8, suseconds
        HSEROUT ["You sent Red", DEC2 hours, DEC2 Minutes, DEC2 Seconds, DEC2 suseconds]
        Goto GetOutOfHere
    
    Sub2:
        HSEROUT ["You sent Blue"]
        Goto GetOutOfHere
    
    Sub3:
        HSEROUT ["You send Green"]
    GetOutOfHere:
    Resume
    enable interrupt
    And be sure you have some delay between each PC send.. i Mean wait between QUALIFIER and the rest of the process. Some VBTimer are really usefull in those case.

    Personnally, i never mess with string handling. Just use BRANCH and send the according value. Time saving and work anyway.
    Last edited by mister_e; - 17th March 2006 at 17:08.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154

    Default

    Sorry Steve, that didn't work.

    I presume with this code it is looking for 0,1 or to be the qualifier?

    If so, how do i get it to look for red, green or blue as the qualifier.

    Thats what i would like it to perform as a test example. ie if VB sends out Red, it then goes to the Sub1 routine and then captures the follwoing eight bytes.

    If Blue is sent as the qualifier, then it jumps to Sub2 and just sends out a text string.

    Any ideas?

    I've messed with the code i have so far and with your modified example as above, but no joy.

    This is driving me round the twist, been working on this piece of code for about a week now.

    Many thanks again,

    Steve

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    you may look at the Melanie example
    http://www.picbasic.co.uk/forum/showthread.php?t=573

    Maybe something to play around.

    As i said, i never waste my time 'round string parsing in a PIC. I keep my code space for something else than that.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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