Hi forum
This is my first post so be patient.
I am migrating a program from a 16f887 to 18f452. My windows application loads position map data to code space via serial comms to position a stepper motor. The 16f887 works fine. The 18f452 loaded half the data in each memory row and the data is incorrect.
I have a test program mostly the same as a sample from this web site see below and also see the result in the pic memory.(should be decimal 0 1 2 3 4 5 6 7)

regards Paul


DEFINE HSER_RCSTA 90h
' Set transmit register to transmitter enabled
DEFINE HSER_TXSTA 24h
' Set baud rate
DEFINE HSER_BAUD 9600
DEFINE HSER_EVEN 1


DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
TRISA = 255 ' Set PORTA to all input
ADCON1 = 2 ' PORTA is analog
DEFINE OSC 20


OSCCON.0 = 0


TRISD = 000011


TRISB = 111000


TRISB = 110000


PORTB = 000000


'####################


I Var word ' Loop count
D Var word ' Data
A Var word ' Address
D=0 'set start value for data
For I = 0 To 7 ' Loop 8 times, once for each address $1800 to $1807


A = $1800 + I ' Increment Address


D = D+1 ' Change Data 0,1,2,3,4,5,6,7


Writecode A,D ' Send value in D to code space location A


Next I


mainloop:


For I = 0 To 7 ' Loop 8 times, once for each address $1800 to $1807


A = $1800 + I ' Increment Address


' Change Data


readcode A,D ' Send value in D to code space location A
HSEROUT [dec D,13]
Next I





High 0 ' Turn on LED connected to PORTB.0


if OSCCON.3 = 1 then PORTB.1 = 1
if OSCCON.3 = 0 then PORTB.1 = 0
if OSCCON.0 = 0 then PORTB.2 = 1 'test for osc start




HSEROUT [BIN OSCCON,13]


Pause 50 ' Delay for .5 seconds


Low 0 ' Turn off LED connected to PORTB.0
Pause 50 ' Delay for .5 seconds


Goto mainloop ' Go back to loop and blink LED forever
End



memory result 1800- 00513 01027 01541 00007 65535 65535 65535 65535