Guys, I need some help here. This is probably one of the strangest bugs I've tried to figure out and I'm starting to believe it's actually not me (for once) doing something wrong.

From a much larger piece of code I've reduced this as much as I possibly can, here it is in its current state:
Code:
DEFINE OSC 48

BTN1            VAR PortD.7
BTN2            VAR PortH.3
LD1             VAR LATD.4
LD2             VAR LATE.4

CRC             VAR WORD
Number_Of_Bytes VAR BYTE

Buffer          VAR BYTE[256]

TRISD.4 = 0
TRISE.4 = 0
TRISD.7 = 1
TRISH.3 = 1


   
LD1 = 0
LD2 = 0
T0CON = %10000011       ' 1:16 prescaler TMR0 on

Main:
    IF INTCON.2 = 1 THEN        ' TMR0 interrupt flag? 
        LD2 = ~LD2              ' Toggle LED so we know we're alive and kickin'
        INTCON.2 = 0
    ENDIF
    

    If BTN1 = 0 THEN
        LD1 = 1
        GOSUB SendMsg_1
        LD1 = 0
        WHILE BTN1 = 0 : WEND
    ENDIF
    
    IF BTN2 = 0 THEN
        LD1 = 1
        GOSUB SendMsg_2
        LD1 = 0
        WHILE BTN2 = 0 :WEND
    ENDIF

Goto Main


SendMsg_1:
    Buffer[0] = $87
    Buffer[1]  = $02
    Buffer[2]  = $06
    Buffer[3]  = $00
    Buffer[4]  = $40
    Buffer[5] = $00
    Buffer[6]  = $00
    Buffer[7]  = $ea
    Buffer[8]  = $c4
    Buffer[9]  = $50
    Buffer[10] = $00
    Buffer[11] = $62
    Buffer[12] = $3b
    Buffer[13] = $30
    Buffer[14] = $00
    Buffer[15] = $b8
    Buffer[16] = $9d
    Buffer[17] = $80
    Buffer[18] = $01
    Buffer[19] = $6c
    Buffer[20]  = $00
    Buffer[21]  = $b8
    Buffer[22]  = $d5
    Buffer[23]  = $80
    Buffer[24]  = $01
    Buffer[25]  = $70
    Buffer[26]  = $00
    Buffer[27]  = $b8
    Buffer[28]  = $b7
    Buffer[29]  = $80
    Buffer[30]  = $01
    Buffer[31]  = $6a
    Buffer[32]  = $00
    Buffer[33]  = $b8
    Buffer[34]  = $57
    Buffer[35]  = $80
    Buffer[36]  = $01
    Buffer[37]  = $6c
    Buffer[38]  = $00
    Buffer[39]  = $b8
    Buffer[40]  = $c4
    Buffer[41]  = $80
    Buffer[42]  = $01
    Buffer[43]  = $7c
    Buffer[44]  = $00
    Buffer[45]  = $b8
    Buffer[46]  = $a7
    Buffer[47]  = $80
    Buffer[48]  = $01
    Buffer[49]  = $69
    Buffer[50]  = $00
    Buffer[51]  = $27
    Buffer[52]  = $0f
    Buffer[53]  = $80
    Buffer[54]  = $01
    Buffer[55]  = $8b
    Buffer[56]  = $00
    Buffer[57]  = $8b
    Buffer[58]  = $73
    Buffer[59]  = $80
    Buffer[60]  = $00
    Buffer[61]  = $0b
    Buffer[62]  = $00
    Buffer[63]  = $b8
    Buffer[64]  = $a3
    Buffer[65]  = $80
    Buffer[66]  = $01
    Buffer[67]  = $6c
    Buffer[68]  = $00
    Buffer[69]  = $b8
    Buffer[70]  = $88
    Buffer[71]  = $80
    Buffer[72]  = $01
    Buffer[73]  = $6c
    Buffer[74]  = $00
 '*********************************************************
    Pause 5            ' If this PAUSE is removed the program crashes
' *********************************************************    
    Buffer[75]  = $b8
    Buffer[76]  = $ce
    Buffer[77]  = $80
    Buffer[78]  = $01
    Buffer[79]  = $7c
    Buffer[80]  = $00
    Buffer[81]  = $b8
    Buffer[82]  = $aa
    Buffer[83]  = $80
    Buffer[84]  = $01
    Buffer[85]  = $6e
    Buffer[86]  = $00
    Buffer[87]  = $f6
    Buffer[88]  = $71
    Buffer[89]  = $80
    Buffer[90]  = $00
    Buffer[91]  = $0b
    Buffer[92]  = $00
    Buffer[93]  = $2c
    Buffer[94]  = $88
    Buffer[95]  = $80
    Buffer[96]  = $01
    Buffer[97]  = $93
    Buffer[98]  = $00
    Buffer[99]  = $14
    Buffer[100]  = $a5
    Buffer[101]  = $80
    Buffer[102]  = $01
    Buffer[103]  = $84
    Buffer[104]  = $00
    Buffer[105]  = $b8
    Buffer[106]  = $ae
    Buffer[107]  = $80
    Buffer[108]  = $01
    Buffer[109]  = $69
RETURN


SendMsg_2:
@ NOP 
RETURN
The target is the 18F87J50 and I'm using a PIC Clicker 2 from MikroE with their USB bootloader so the CONFIG is whatever their BL is using. No hardware other than what's on the PIC Clicker 2 itself is connected. The board is powered by the USB cable which is also used to download the code via their bootloader.

At this point the code isn't really doing much at all. If one button is pressed does a NOP and returns, if the other button is pressed it loads an array with values and returns.

Here's the thing: See that PAUSE 5 about 2/3 down thru the SendMsg_1 subroutine?
If I remove that PAUSE 5 statement the program works fine until that SendMsg_1 routine is called at which point it just locks up. Do not ask me how I came to that conclusion, it's been MANY hours of head scratching and trial'n'error and I'm probably close to having worn out the FLASH on the poor 87J50.

I do believe it's some sort of RAM allocation/acces issue because the very last thing I tried before posting here was to remove the declaration of the CRC variable (which isn't used) and then it all of sudden worked without the PAUSE statement in there. But if it IS some sort of RAM allocation/access issue what difference does the PAUSE do? And what exactly am I doint wrong? Even if I go back to my full program and it starts to work if I put that magic PAUSE 5 in there I really don't trust it - besides I really can't waste 5ms...

Compiling with PBP 3.1.2.4, assembling with MPASM 5.84.

Any insight here would be most appreciated, thanks!

/Henrik.