EZPort seems to be resetting while writing pages to a MCF52258

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

EZPort seems to be resetting while writing pages to a MCF52258

Jump to solution
1,314 Views
WilliamW
Contributor III

I have working code that writes to the MCF52258 from another MCF52258 without problems.  However, when I try to write pages using a MK64FX512 I get inconsistent results.  Sometimes I write all the pages and it works fine, other times I get a write error bit.  Sometimes the write is successful but when I compare the flash to the data that was supposed to be written it is either partially or entirely blank.  On a whim I added code to verify that the configuration bit was set and found that when I get these failures it is no longer set.  When it fails it usually does so in the first 20 and more often in the first 10 pages.  It seems as though if I wait a while (15-30min) I have a good chance for success.  When the board with the MCF52258 is running with software it can draw up to 2.5 amps so getting sufficient power to the board isn't an issue.  I tried slowing down the timing between writing pages with no luck.  I believe the most likely issue is the configuration.  I've tried the original value with the DIV8 and a value of 25.  But I'm not sure what clock is used in the EZPort configuration so I've also tried DIV8 with 10 (if it's using our 16MHz oscillator) and then 5 (if it's using it's 8MHz internal oscillator).  Surprisingly the results are the same with either of those values.  The original code works fine using DIV8 and 25 but I'm not sure if that's correct.  Can anyone give me any ideas why the EZPort might be clearing it's configuration bit and what I might be doing to cause it?

0 Kudos
1 Solution
1,287 Views
WilliamW
Contributor III

The problem seems to have been the initialization to put it into EZPort mode.  Works 100% of the time now.  It couldn't find anything in the documentation but I realized that I had the "jist" of what I was doing in the original code but it wasn't exactly the same.  The key bit seems to be that the chip select needed to be high (inactive) when power was applied and then set to low (active) before the reset line is brought low (active).  Here's my original code (which is more succinct than the Kinetis code) in case someone runs into a similar problem in the future:

uint16 nPQSPAR = MCF_GPIO_PQSPAR;
uint8 nDDRQS = MCF_GPIO_DDRQS;

MCF_GPIO_DDRQS = MCF_GPIO_DDRQS_DDRQS3; // Set the port to output
MCF_GPIO_PQSPAR = MCF_GPIO_PQSPAR_QSPI_CS0_GPIO; // Sets EzPort Chip Select to GPIO
MCF_GPIO_PORTQS = MCF_GPIO_PORTQS_PORTQS3; // Set EzPort Chip Select to inactive (high)

// Power it down to avoid problems with the watchdog timer
GPIO_CORE_POWER_DISABLE();
Timer_Wait( 100 );

GPIO_CORE_RESET_ENABLE();
GPIO_CORE_POWER_ENABLE();
Timer_Wait( 1 );
MCF_GPIO_PORTQS = 0; // Set EzPort Chip Select to Active (low)
Timer_Wait( 1 );
GPIO_CORE_RESET_DISABLE();
Timer_Wait( 1 );

MCF_GPIO_DDRQS = nDDRQS;
MCF_GPIO_PQSPAR = nPQSPAR;

View solution in original post

0 Kudos
1 Reply
1,288 Views
WilliamW
Contributor III

The problem seems to have been the initialization to put it into EZPort mode.  Works 100% of the time now.  It couldn't find anything in the documentation but I realized that I had the "jist" of what I was doing in the original code but it wasn't exactly the same.  The key bit seems to be that the chip select needed to be high (inactive) when power was applied and then set to low (active) before the reset line is brought low (active).  Here's my original code (which is more succinct than the Kinetis code) in case someone runs into a similar problem in the future:

uint16 nPQSPAR = MCF_GPIO_PQSPAR;
uint8 nDDRQS = MCF_GPIO_DDRQS;

MCF_GPIO_DDRQS = MCF_GPIO_DDRQS_DDRQS3; // Set the port to output
MCF_GPIO_PQSPAR = MCF_GPIO_PQSPAR_QSPI_CS0_GPIO; // Sets EzPort Chip Select to GPIO
MCF_GPIO_PORTQS = MCF_GPIO_PORTQS_PORTQS3; // Set EzPort Chip Select to inactive (high)

// Power it down to avoid problems with the watchdog timer
GPIO_CORE_POWER_DISABLE();
Timer_Wait( 100 );

GPIO_CORE_RESET_ENABLE();
GPIO_CORE_POWER_ENABLE();
Timer_Wait( 1 );
MCF_GPIO_PORTQS = 0; // Set EzPort Chip Select to Active (low)
Timer_Wait( 1 );
GPIO_CORE_RESET_DISABLE();
Timer_Wait( 1 );

MCF_GPIO_DDRQS = nDDRQS;
MCF_GPIO_PQSPAR = nPQSPAR;

0 Kudos