Instant Interrupts and HSERIN


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    I thought you were joking with your offer to re-write my code. I do like to have a stab at things myself but I would very much appreciate a hand with the RX handler if you don't mind taking a quick look please?

    I've got it very simple at the moment but I realise that this code only works correctly if I know exactly how many databytes I am going to receive:

    <font color="#000080"><i>'****************************** *************************************************
    'RX Interrupt Handler: Get Time
    '************************************************* ******************************

    </i></font>GetTime:

    ' Databyte START 0 1 2 3 4 5 6
    ' $FD SS MM HH DD MM YY YY

    </i></font><b>HSERIN </b>100,Timeout, [DataByte(0), <b>STR </b>DataByte\7]

    </i></font>DataReceived = Yes

    <font color="#008000">@ INT_RETURN


    </font>Timeout:

    DataReceived = No

    <font color="#008000">@ INT_RETURN</font>


    If you need the whole code I can do so by attachment - although I'm afraid everyone would laugh at me ;-)

    Thanks very much

    Rob

  2. #2
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Question

    I can't seem to receive 8 bytes. I've looked at this post, but still can't solve the problem. The LED is not toggling. If I set to 5 bytes, no problem.
    I've enable rx int in the main loop after I have process the data.

    Code:
    DEFINE OSC 20
    datain var byte[8]
    DEFINE HSER_BAUD 9600 ' Select the baud rate
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 129 ' 9600 Baud @ 20MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically  
    
    
    Int_RX:
    
     HSERIN 100, Timeout, [ STR datain\8]
    
    @    INT_DISABLE   RX_INT
    toggle LED 
    
    @ INT_RETURN    
    
    Timeout:           'serial timeout
    
    @ INT_RETURN
    Last edited by Pic2008; - 27th January 2009 at 15:27.

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


    Did you find this post helpful? Yes | No

    Default

    The way the above is written, bypass most/all DT's INT call convention.

    Could you post your Whole code, PIC model and Configuration fuses?

    A small description of what you want to do would also be great.
    Steve

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

  4. #4
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    I think the main loop is taking too long, hence the serial interrupt can't receive all 8 bytes properly. Still trying to reduce the serial processing time in main loop.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic2008 View Post
    I think the main loop is taking too long,...
    Could be, but it won't affect Instant Interrupts. It doesn't pay any attention to what the main loop is doing. Unlike ON INTERRUPT.

    But if there was something in the main loop.
    Like Steve may have hinted ...

    Can't say without more information/code.

    Gimmee gimmmee ....
    <br>
    DT

  6. #6
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Note that in the Int_RX ISR, the INT is disabled.
    In the main loop, I will check the serial data whether the serial data match a predefined format before it is enabled again in main loop. I didn't use any pause for this serial data checking, I want it to check all 8 bytes before determining which command to execute. I use RB INT, but this INT is not trigger during serial comm. I also use ADC in main loop with PAUSE.

    One thing I'm not really sure is how does "HSERIN 100, Timeout, [ STR datain\8]" really work in ISR? From this thread, it said it receive 2 bytes, this means ISR need to execute another 3 times to receive 8 bytes completely?
    If the packet size is always 8 bytes, declaring datain as 8 bytes is sufficient right?

    I remembered if PC send 8 bytes to PIC, the LED is not toggle, meaning this Int_RX ISR is not trigger at all.

    Should I use "@ INT_DISABLE RX_INT" in ISR or main loop? When is the proper time to enable RX_INT again?
    Last edited by Pic2008; - 30th January 2009 at 05:18.

  7. #7
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    After going through the code over and over again, I still can't find the problem until my colleague check her application code which sends the 8 bytes. There is a bug from her application.

    Now, the problem is solved, PIC confirmed can receive 8 bytes using DT interrupt.

    Thanks for all the guidance.

Similar Threads

  1. Hserin with Instant Interrupts.
    By ronjodu in forum Serial
    Replies: 17
    Last Post: - 30th December 2014, 20:17
  2. HSerin problems on power up
    By Luckyborg in forum Serial
    Replies: 8
    Last Post: - 21st April 2009, 19:49
  3. TMR0 interrupt and HSERIN
    By boban in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2008, 11:48
  4. Usbin and hserin
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th October 2007, 15:26
  5. HserIn and Interrupts
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th December 2006, 07:15

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