Hi betwixt (and I really am now :^o ),
I tried your suggestion, however the results were the same.
I found this thread:
Then I created these two routines:
unsigned char getLSB(int data)
{
return data & 0xFF;
}
unsigned char getMSB(int data)
{
return data / 256u;
}
After confirming the results from getLSB and getMSB were correct, I called the routines from within my writeIntEE code:
void writeIntEE(unsigned char address, int data)
{
//LSB
EEADR =(address);
EEDATA = getLSB(data); //LSB
//Configuration as per manual
EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.WREN =1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
while (EECON1bits.WR)
{
}
//MSB
EEADR =(address+1);
EEDATA = getMSB(data); //MSB
//Configuration as per manual
EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.WREN =1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
while (EECON1bits.WR)
{
}
}
The same problem persisted@*x!
So... My solution is to pass both the LSB and MSB values as unsigned char to writeIntEE:
void writeIntEE(unsigned char address, unsigned char dataLSB, unsigned char dataMSB)
{
//LSB
EEADR =(address);
EEDATA = dataLSB; //LSB
.....
//MSB
EEADR =(address+1);
EEDATA = dataMSB; //MSB
......
}
Then I call the writeIntEE like this:
writeIntEE(2, getLSB(0x0036), getMSB(0x0036));
No more problem! WT*?
I don't understand what the problem was, but this workaround works for me
)
As a C18 newbie and assembler veteran, I have been amazed by C18, it only took 3 or 4 days to get PC1602 2x16 line LCD working, Timer driven interrupts up and running, 3 channels of ADC reading in under interrupt control, interrupt driven button debounce,
Then along comes a problem like this, chews up nearly a day!
Thank you betwixt and unaided for your assistance, I have clicked both your 'Helped Me' buttons.
Kind regards
Tony
'We can sell our time, but we can't buy it back..'