Strange HSEROUT behaviour


Closed Thread
Results 1 to 11 of 11

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...
    Code:
    Disable
    HSEROUT ["Your String"]
    WHILE TXREG : WEND
    Enable
    END
    Now how about
    Code:
    HSEROUT ["YourString"]
    WHILE TXREG : WEND
    end
    Last edited by mister_e; - 7th July 2006 at 20:11.
    Steve

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

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    This is on a 1 millisecond interrupt. Chip is 18F8722

    Here is a portion of the code...


    Asm
    IntHandler

    movwf wsave
    swapf STATUS,W
    clrf STATUS
    movwf ssave
    movf PCLATH,W
    movwf psave
    movf FSR0,W
    movwf fsave

    movlw 0xEC ; Reload TMR0 with 65535 - 5000
    movwf TMR0H
    movlw 0x77
    movwf TMR0L

    btfsc PIR1,5
    goto KeyHit

    bcf INTCON,2 ; Clear the interrupt flag

    infsnz _MasterClock
    incf _MasterClock + 1

    movlw 0x03
    cpfseq _MasterClock + 1
    goto FanRoutine
    movlw 0xE8
    cpfseq _MasterClock
    goto FanRoutine
    clrf _MasterClock
    clrf _MasterClock + 1


    bsf _TPE
    goto DoneForNow


    FanRoutine

    movf PORTB,0,0
    movwf _Temp,0
    xorwf _OldPortB,0,0
    movwf _changedB,0
    movff _Temp,_OldPortB


    Fan1
    btfss _changedB,0
    goto DoneForNow
    infsnz _Fan1Counter
    incf _Fan1Counter+1



    KeyHit
    bsf _KeyHitFlag
    bcf PIR1,5

    DoneForNow

    movf psave,W
    movwf PCLATH
    movf fsave,W
    movwf FSR0
    swapf ssave, W
    movwf STATUS
    swapf wsave, F
    swapf wsave, W
    bsf INTCON,7 ; Turn Global interrupts on
    bsf INTCON,6 ; Turn Peripheral Interrupts on
    retfie ; Return from the interrupt

    EndAsm
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    I suspect it's your int handler.

    btfsc PIR1,5
    goto KeyHit ; <-- you never reset timer0 int flag before exiting

    bcf INTCON,2 ; (skips over this) Clear the interrupt flag

    That may be a problem once retfie re-enables global interrupts.

    And if you have your USART receive interrupt enabled, you're not clearing the
    receive interrupt with BCF PIR1,5. You have to read whatever is in the USART
    receive buffer to clear this flag bit.

    Have a look at the 18F series interrupt handler in this example;
    http://www.microengineeringlabs.com/...p/serbufAx.bas
    Regards,

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

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    That link sends me to a 16F interrupt handler. Will the same code work on an 18F part?

    While I was visiting the MELABS site, I noticed an 18F452 interrupt routine for the timer.

    They only saved/restored "W" and "STATUS".
    In the 18F series, do I not have to worry about any other registers if I'm not explicity changing them?
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    Sorry. Try this one;
    http://www.microengineeringlabs.com/...8F/serA452.bas

    Normally you'll only need to save FSR0L, FSR0H, WREG and STATUS.
    Last edited by Bruce; - 8th July 2006 at 00:39.
    Regards,

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

Similar Threads

  1. I2C Slave with a PIC
    By ralfmayr in forum mel PIC BASIC Pro
    Replies: 129
    Last Post: - 21st August 2016, 18:44
  2. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 20:12
  3. Is HSEROUT corrupting bit 7 ?????
    By Robert Wells in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2008, 17:26
  4. Strange behaviour from PIC16F877 on TMR0
    By mikebar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 19th August 2006, 02:31
  5. Strange HSEROUT execution times
    By SteveB in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st May 2006, 19:34

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