what happen if...
Now how aboutCode:Disable HSEROUT ["Your String"] WHILE TXREG : WEND Enable END
Code:HSEROUT ["YourString"] WHILE TXREG : WEND end
what happen if...
Now how aboutCode:Disable HSEROUT ["Your String"] WHILE TXREG : WEND Enable END
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.
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
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
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
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.
Bookmarks