Good morning gurus.

I'm experiencing a problem with HSERIN2 command using Pic18F97J60 (100 pin version)
A simple code like this, does not receive any character, but the sending of characters it work by the use of HSEROUT2:

Code:
Include "modedefs.bas"          'Inline compiler's pre-defined constants
define OSC 25                   'Set the Crystal Clock speed
DEFINE HSER2_RCSTA 90h          'Set the RX Register for the Serial Port 2
DEFINE HSER2_TXSTA 20h          'Set the Serial Port2 TX enabled
DEFINE HSER2_BAUD 9600          'Set baud rate for Serial Port 2
DEFINE HSER2_SPBRG 40           'Set SPBRG directly ((((1000000*25)/9600)+32)/64)-1

define HSER1_CLROERR 1          'No Error Overflow on Serial Port 1
define HSER2_CLROERR 1          'No Error Overflow on Serial Port 2
ADCON0 = 0                      'AD converter module 0 = disabled
ADCON1 = %00001111              'Set all analog pins to digital
ADCON2 = %00000000
CMCON  = %00000111              'Comparator = disabled
INTCON = %00111000
INTCON2 = %10000000
INTCON3 = %00000000
RCON.7 = %00000000
T0CON  = %00000000              'Timer0 disabled (see page 163)
T1CON  = %00000000              'Timer1 disabled (see page 167)
T2CON  = %00000000              'Timer2 disabled (see page 173)
T3CON  = %00000000              'Timer3 disabled (see page 175)
T4CON  = %00000000              'Timer4 disabled (see page 179)
CCP4CON = %00000000             'Capture/Compare/PWM 4 disabled (see page 181)
CCP5CON = %00000000             'Capture/Compare/PWM 5 disabled (see page 181)
CCP1CON = %00000000             'Capture/Compare/PWM 1 disabled (see page 189)
CCP2CON = %00000000             'Capture/Compare/PWM 2 disabled (see page 181)
CCP3CON = %00000000             'Capture/Compare/PWM 3 disabled (see page 181)
EECON2.5 = 0                    'Ethernet Module Disabled


SSP1CON1.5 = 0                   'Disable SPI 1 and set pins as GPIO
SSP2CON1.5 = 0                   'Disable SPI 2 and set pins as GPIO


BAUDCON1 = %00001000             'BRG16=1; See page 304
'BAUDCON2 = %00001000

                                 'Serial Port 1 speed setting:
SPBRGH1 = $02                    '9600 bps value for serial port =650=$028A
SPBRG1  = $8A
TXSTA1 = %00100100               'Tx1 enabled,8bit,Async, see page 302
RCSTA1 = %10010000               'Rx1 enabled,8 bit,Async,No frame&overfl.err
            
'Port D features setting:
PSPCON.4 = 0                    'Port D set to be used as GPIO

TRISG.0 = 0                     
TRISG.1 = 0                     'PortG1 = Output (External RS232-TX2)
TRISG.2 = 1                     'PortG2 = Input  (External RS232-RX2)
TRISG.3 = 0                     
TRISG.4 = 1                     
TRISG.5 = 1                     
TRISG.6 = 1                     
TRISG.7 = 1                     
LATG = 0
syncByte      var byte

MainLoop:
    LED_SysAlive =  ~ Led_SysAlive 'Blink a led

    HSERIN2 1000, MainLoop,[syncByte]   'Does not work...
    select case syncByte
        case "S"
            HSERIN2 250, MainLoop, [syncByte]                        
            HSEROUT2 ["synByte=", #syncByte, 13,10]
                                      
        'case = "A"
        '    hserin2 250, Main, [DEC syncByte]
        '    HSEROUT2 ["Case A=", #syncByte, 13,10]
        '
        'case = "B"
        case else
            HSEROUT2 ["syncByte=", #syncByte, 13,10]
    end select
    LED_CPUOverT = 0

    Goto MainLoop
This code does not pass neighter the first instruction HSERIN2.
The LED just blink, I saw with a digital scope that data are on to the right pin... and nothing happen.

BUT:
removing the HSERIN2 line and putting instead the line with the Serin2:
Code:
SerIn2 PortG.2,84,1000,MainLoop,[syncByte]   'It work !!!
IT WORK!

Why the hardware serial port 2 does not work with the HSERIN2 ?
Maybe I've missed some register's settings or initialized in a bad sequence?

Thank you very much.