Hserin, 1st character always lost!


Closed Thread
Results 1 to 7 of 7

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    what happen if you place a ON INTERUPT GOTO myint and define a simple ISR as bellow?

    Code:
    disable
    myint:
    
    resume
    enable
    Even if it doesn't care of anything, you should see some difference. At very least, your program know where to go when an interrupt happen.
    Steve

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

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The problem is that you have interrupts enabled, but you don't have an interrupt handler routine.

    PBP issues a CALL to a routine called hserinloop. The return address is pushed onto the stack. In this loop, it will continuously check the RCIF USART interrupt flag bit, and loop until it's set.

    While in this loop, if your interrupt happens, the address within this loop (wherever it happens to be) is pushed onto the return stack.

    Note that now you have a return address on the stack that is still inside this loop. Not to where PBP issued the CALL hserinloop.

    Once RCIF is set, the received value is loaded into the W reg, and PBP exits hserinloop with GOTO DONE. Inside DONE you land on a RETURN, and you're right back in the hserinloop until the 2nd character arrives.

    It works OK for the 2nd character because global interrupts are still disabled.

    The original return address is now OK, and on RETURN it shows the 2nd character.

    If you disable interrupts this problem goes away since the RETURN will always be to the proper location after PBP issues the CALL to hserinloop.

    It has the same problem after a reset because your code is enabling interrupts again.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Wow Bruce, that was detailed analysis! That was exactly the problem.

    Thanks all that contributed.

    I have attached the first attempt to write some VB6 user interface that configures the LCD of the connected device. For anyone interested to use it, be my guest. I know it is not some super-duper code, but, hey I just started VB! Any suggestions most welcome.

    Also a great thanks for Darrel's LCDbar_INC.bas that helped me a lot in this project.

    Ioannis
    Attached Files Attached Files

Similar Threads

  1. HSERIN and STR - character encoding
    By boban in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 13th August 2008, 17:36
  2. Replies: 6
    Last Post: - 30th June 2008, 16:33
  3. HSERIN each character cost 3 pgm words
    By boban in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 7th April 2008, 16:49
  4. Hserin problems
    By nicjo in forum Serial
    Replies: 0
    Last Post: - 27th November 2006, 10:16
  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