PIC24FJ128GA202 problems reading 25AA02E48 EEPROM
Posted: 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
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