PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

An area to discuss 16-bit PIC specific problems and examples

Moderator: Benj

leoo
Flowcode V4 User
Posts: 44
Joined: Mon Jan 19, 2009 11:43 am
Has thanked: 35 times
Been thanked: 9 times
Contact:

PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby leoo » Fri Nov 17, 2017 2:31 pm

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

kersing
Valued Contributor
Valued Contributor
Posts: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby kersing » Fri Nov 17, 2017 4:43 pm

It helps if you post your flowchart so we can look at the actual code and settings.
These users thanked the author kersing for the post:
leoo (Mon Nov 20, 2017 10:11 am)
Rating: 5.88%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

leoo
Flowcode V4 User
Posts: 44
Joined: Mon Jan 19, 2009 11:43 am
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby leoo » Mon Nov 20, 2017 10:17 am

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
Attachments
PC3_Rev_3_2_1_3.fcfx
(19.32 KiB) Downloaded 35 times

leoo
Flowcode V4 User
Posts: 44
Joined: Mon Jan 19, 2009 11:43 am
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby leoo » Tue Nov 21, 2017 10:20 am

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

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby LeighM » Tue Nov 21, 2017 10:50 am

That sounds like it could be a hardware issue, do you have any floating pins, such as hold?
These users thanked the author LeighM for the post:
leoo (Tue Nov 21, 2017 1:36 pm)
Rating: 5.88%
 

leoo
Flowcode V4 User
Posts: 44
Joined: Mon Jan 19, 2009 11:43 am
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby leoo » Tue Nov 21, 2017 1:52 pm

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

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby LeighM » Tue Nov 21, 2017 2:14 pm

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.
These users thanked the author LeighM for the post:
leoo (Tue Nov 21, 2017 2:26 pm)
Rating: 5.88%
 

leoo
Flowcode V4 User
Posts: 44
Joined: Mon Jan 19, 2009 11:43 am
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM

Postby leoo » Tue Nov 21, 2017 2:26 pm

Hi Leigh,

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

Regards.
Leo

leoo
Flowcode V4 User
Posts: 44
Joined: Mon Jan 19, 2009 11:43 am
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM - resolved

Postby leoo » Wed Jun 06, 2018 1:38 pm

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
These users thanked the author leoo for the post:
LeighM (Wed Jun 06, 2018 2:41 pm)
Rating: 5.88%