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
PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
Moderator: Benj
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
It helps if you post your flowchart so we can look at the actual code and settings.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Flowcode V4 User
- Posts: 54
- Joined: Mon Jan 19, 2009 11:43 am
- Has thanked: 41 times
- Been thanked: 9 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
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
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 272 times
-
- Flowcode V4 User
- Posts: 54
- Joined: Mon Jan 19, 2009 11:43 am
- Has thanked: 41 times
- Been thanked: 9 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
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
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
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
That sounds like it could be a hardware issue, do you have any floating pins, such as hold?
-
- Flowcode V4 User
- Posts: 54
- Joined: Mon Jan 19, 2009 11:43 am
- Has thanked: 41 times
- Been thanked: 9 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
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
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
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
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.
Maybe the answer will be forthcoming some point down the line.
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.
Maybe the answer will be forthcoming some point down the line.
-
- Flowcode V4 User
- Posts: 54
- Joined: Mon Jan 19, 2009 11:43 am
- Has thanked: 41 times
- Been thanked: 9 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
Hi Leigh,
Thanks for your input. I'll keep trying and post if I get it right.
Regards.
Leo
Thanks for your input. I'll keep trying and post if I get it right.
Regards.
Leo
-
- Flowcode V4 User
- Posts: 54
- Joined: Mon Jan 19, 2009 11:43 am
- Has thanked: 41 times
- Been thanked: 9 times
- Contact:
Re: PIC24FJ128GA202 problems reading 25AA02E48 EEPROM - resolved
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
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