WAIT problem with MCF51QE128

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

WAIT problem with MCF51QE128

521 Views
JBM
Contributor IV

I have an MCF51QE128 with a serial interface hooked to the computer.  I can send a command to the microcontroller  to go to wait.  This works fine -- it writes to the EEPROM (using I2C) as it should then enters wait. 

 

When I send it another serial command, it wakes up and processes normally as far as I can tell -- I've stepped through with the debugger and watched it.  The problem is when I send a second wait command, it cannot write to the EEPROM.  It cannot transmit a byte. 

 

The only thing that I can figure out is that the clock frequency has changed somehow.  I've read through the manual and thought it might have been the voltage regulator, so I set LPWUI to 1 to keep it powered up, but no luck.

 

Unfortuneately, I'm working with production hardware and it's so small I can't get a scope probe on it to check.

 

Here's my current startup code (I think the macros are self explanatory):

 

SOPT1 = bWAIT | bBKGDPE;SOPT2 = bCOPCLKS | BIIC1PS;SMPSC1 = bLVDE;SMPSC2 = bLPWUI | bLPR;SCGC1 = bCKENTPM3 | bCKENTPM2 | bCKENIIC1 | bCKENSCI1 | bCKENADC;

 and this is where I go into wait:

 

/* Stop clocks we don't need */SCGC1 = bCKENSCI1;_Wait;/* Start the clocks */SCGCI1 = bCKENTPM3 | bCKENTPM2 | bCKENIIC1 | bCKENSCI1 | bCKENADC;

 

Any ideas on how to troubleshoot?  Am I missing something obvious?  I've not used WAIT before, so maybe I'm making assumptions that aren't correct.  If there is something else that might be helpful, ask.  I can't post all of my code.

 

Thanks for your help!

 

Brad

Labels (1)
0 Kudos
4 Replies

338 Views
TomE
Specialist II

> Any ideas on how to troubleshoot?


Same as I've had to do. Get wires soldered to the board and connect your CRO probes to them.

 

When you say "it cannot write to the EEPROM", where are you detecting the errors? Is the I2C port working? Is it clocked? Do the transfers complete? Can you write some code to read from the EEPROM before you write it? Can you read back status registers from the EEPROM? Does it seem to write (all the commands work), but then when you read the data back later it hasn't worked? There's so many different ways for it "not to work".

 

Tom

 

0 Kudos

338 Views
JBM
Contributor IV

It hangs in my I2C write routine here:

 

int i2c_transmit(byte data){  IIC1C_TXAK = 0;    IIC1D = data;  while (!IIC1S_IICIF);  return !IIC1S_RXAK;}

 (note -- I retyped this, so if there's an error, it may be in my copying).

 

The only time I've seen it hang in this routine is when the frequency is wrong, or the wrong pullup resistors were installed on a board.  I've worked with the electrical engineer doing the work and have asked him to check bus frequency.

 

Brad

 

 

0 Kudos

338 Views
TomE
Specialist II
/* Stop clocks we don't need */
SCGC1 = bCKENSCI1;

 

You're stopping the clock to the I2C module (as well as almost everything else).

 

Are you doing this after coming out of the WAIT?

 

5.6 Peripheral Clock Gating

 

NOTE
Software should disable the peripheral before disabling the clocks to the
peripheral. After clocks are re-enabled to a peripheral, the peripheral
registers need to be re-initialized by software.

 

Tom

 

0 Kudos

338 Views
JBM
Contributor IV

That's what I intended.   All the peripherals are stopped prior to going to WAIT, so the clocks can be stopped (except for the serial port).  After WAIT, the clocks are enabled and the I2C module is configured when used (after the clock is enabled).

 

Brad

0 Kudos