Page 1 of 1

PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Fri Nov 17, 2017 2:31 pm
by leoo
Hi,

I'm using FC7.2.1.4 and a PIC24FJ128GA202 to read the pre-programmed, 6 byte, MAC Address from a Microchip 25AA02E48 EEPROM. Primary Oscillator Mode = HS Crystal Oscillator Mode - 24.576Mhz, Oscillator Source Selection = Primary Oscillator (XT, HS, EC, no PLL), although I've tried almost every possible combination including FRC. Prescale for SPI is Fosc/8.

The problem with the programme is that the MAC Address is read incorrectly after power-up but reads correctly after a reset. The bytes read back were incorrect about 60% of the time until I added a 2 second delay at the start of my code and then I got an incorrect MAC address about 5-10% of the time.

I set up a test programme by deleting almost all of the main programme, not the components. The test programme only has a 100mS delay, initializes the SPI_Master_EB013 and a UART, reads the six EEPROM address locations into an array, which is then printed out via the UART to HyperTerminal with a colon seperating the numbers and a CR and LF. The programme has a "While 1" loop at the end to stop any wrap.

When power is applied to the board, HyperTerminal shows (in most instances, not always) that the MAC Address printout is repeated, so two lines of numbers are output (colons and all) when the programme should only send it once. Where two lines are output, the first line contains an incorrect MAC Address and the second line has the correct MAC Address.

Could you please shed some light on this? Is this something to do with oscillator start-up (I have disable Two speed Oscillator Start-up and clock switching). If so, is there a way I can monitor when the primary oscillator is up to speed and only then proceed, or is there a better solution?

Kind regards.
Leo

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Fri Nov 17, 2017 4:43 pm
by kersing
It helps if you post your flowchart so we can look at the actual code and settings.

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Mon Nov 20, 2017 10:17 am
by leoo
Hi Kersing,

Apologies for the omission.

Please see attached the flowchart.

Below is an example of the output on power up. Both lines are output, with the second line containing the correct numbers.

212:16:252:51:181:255:
84:16:236:35:53:234:

Regards.
Leo

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Tue Nov 21, 2017 10:20 am
by leoo
Hi,

The problem of the double output from the test program was due to not disconnecting the PICkit3 programmer from the circuit. With this disconnected the programme gives the required one line output. Apologies for being an idiot.

So the actual problem is that the EEPROM is read incorrectly (every time) on power up but is read correctly (every time) when the PIC24 is reset via the MCLR pin.

If anyone can offer some assistance, it would be greatly appreciated.

Kind regards.
Leo

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Tue Nov 21, 2017 10:50 am
by LeighM
That sounds like it could be a hardware issue, do you have any floating pins, such as hold?

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Tue Nov 21, 2017 1:52 pm
by leoo
Hi Leigh,

Thanks for the reply.

The EEPROM is a 6-lead SOT-23 device which physically does not have the Hold Input pin or the Write-Protect pin, I assume this is taken care of internally. All other pins are connected and being used.

I have done a bit of a work around in that I now do a soft reset at the start (if it hasn't been done previously) and then the EEPROM data seems to read correctly. Still confused!

Regards.
Leo

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Tue Nov 21, 2017 2:14 pm
by LeighM
hmm, yes, odd.
I did wonder about adding a longer delay after the initial setting high of the CS pin, before attempting to read data.
But I don't see anything in the datasheet to suggest that the 10mS needs to be increased.
And the device has quite a large working voltage range, so does not look like a power rail rise time issue.
Still, at least you have it working now. :D
Maybe the answer will be forthcoming some point down the line.

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Posted: Tue Nov 21, 2017 2:26 pm
by leoo
Hi Leigh,

Thanks for your input. I'll keep trying and post if I get it right.

Regards.
Leo

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM - resolved

Posted: Wed Jun 06, 2018 1:38 pm
by leoo
Hi Leigh,

An update on the above.

I have listed some things we found out regarding the WIZ810MJ module's effect on the SPI buss in another post. It seems that the buss select chip on the Wiznet module stopped the SPI buss from functioning as required, With this chip removed, the Eeprom is read reliably every time (without any work-around).

Kind regards.
Leo