Hello,

I would appreciate your help and need a fresh pair of eyes on the issue I have.
I currently have a byte that is saved every time the UART interrupts with RCREG data ready. This only allows me at 4800bps 2ms between received bytes.

The main section of the code takes two consecutive bytes and merges them into a word in basic. Then drops through to send out a 1 ~ 2ms pulse width proportional to servo position.
The servo movement is a bit coarse which tells me that in the time I am sitting in the pauseus timing the pulse width, that I am dropping received UART bytes. This is because the part of the code that merges the bytes never runs since it iterrupts every 2ms in the middle of a pausus command.

If I handle the byte to word merging in the interrupt it will give me about 4ms of time to take care of servicing the servo (2ms max needed).
I would like to handle the merging of the two consecutive bytes in the interrupt assembly section to minimize PBP overhead. How can I do this with the least amount of clock cycles? see below snippet.







' Assembly language UART INTERRUPT handler
Asm
myint

; Uncomment the following if the device has less than 2k of code space
; movwf wsave ; Save W
; swapf STATUS, W ; Swap STATUS to W (swap avoids changing STATUS)
; clrf STATUS ; Clear STATUS
; movwf ssave ; Save swapped STATUS
; movf PCLATH, W ; Move PCLATH to W
; movwf psave ; Save PCLATH

; Save the FSR value for later
movf FSR, W ; Move FSR to W
movwf fsave ; Save FSR


; Read and store the character from the USART
movf RCREG, W ; Read the received character
movwf _tempbyte ; contains new UART received byte
incf _Btcounter,F ; passed to main to track 2 consecutive bytes





; Restore FSR, PCLATH, STATUS and W registers
finished
movf fsave, W ; retrieve FSR value
movwf FSR ; Restore it to FSR
movf psave, W ; Retrieve PCLATH value
movwf PCLATH ; Restore it to PCLATH
swapf ssave, W ; Retrieve the swapped STATUS value (swap to avoid changing STATUS)
movwf STATUS ; Restore it to STATUS
swapf wsave, F ; Swap the stored W value
swapf wsave, W ; Restore it to W (swap to avoid changing STATUS)
retfie ; Return from the interrupt



EndAsm