M5213EVB I2C data I/O register problems

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

M5213EVB I2C data I/O register problems

1,699 Views
jrowland
Contributor I
Hi everyone, I've just started messing with I2C and i seem to have run into a little problem, For some reason I cannot write to the I2DR register. I've used the driver example given by Dr Seuss with a change in I2C pins to :
 
/* I2C pins configuration */
 MCF_GPIO_PASPAR |= ( MCF_GPIO_PASPAR_PASPAR0(0x01)
                                  | MCF_GPIO_PASPAR_PASPAR1(0x01));
 
My next step was setting up the I2C for transmit because I needed to transmitt the id of the device like so:
 
uint8 I2CreceivedByte(uint8 address, uint8 id)
 {
  int i;
  uint8 data;
  
  MCF_I2C_I2CR = 0xB0 ;  //enable I2C set to master transmit mode
  
  MCF_I2C_I2DR =  0xC0; //set the id to the I/O register

 
I was watching the registers while running the program in debug mode. From what I observed the I2DR register never gets the id. I'm not exactly sure what is wrong however I feel like i'm missing something. The following is what my registers look like up to this line of code.
 
/*I2C Registers*/
I2ADR     0x00
I2FDR     0x32
I2CR       0xB0
I2SR       0x81
I2DR       0x00
 
/*General Purpose I/O Port AS Registers*/
PORTAS  0x03
DDRAS    0x00
SETAS     0x03
CLRAS     0x00
PASPAR  0x05
 
Thanks in advance for any helps or hints anyone can give me
Labels (1)
0 Kudos
Reply
2 Replies

682 Views
jrowland
Contributor I
Looking at the sample code for the I2C module for the M5213EVB it turns out that I was using/initializing the wrong port. I turns out that I needed to use PORT QS correcting my initialization to :

/* I2C pins configuration */
 MCF_GPIO_PQSPAR = 0 | ( MCF_GPIO_PQSPAR_P
QSPAR3(2)
                                  | MCF_GPIO_PQSPAR_PQSPAR2(2));

In doing this I am finally able to change the I2DR register value. What I don't understand is from looking at the MCF5213 Reference Manual it mentions that Port AS has SDA and SCL . Does this mean that both Port AS and Port QS have I2C SDA and SCL ports? If so, why could I not modifiy the I2DR register when setting the Port AS? Thanks in advance for any information that can help me clear up this confusion.



Message Edited by jrowland on 2008-03-28 06:50 PM
0 Kudos
Reply

682 Views
SimonMarsden_de
Contributor II
Hi

The I2C module can be connected to one of two different sets of physical pins (or not connected at all if you're not using it - you might need the pins for something else). The choice is made through the Pin Assignment registers.

Obviously you need to choose the mapping which matches how you've actually wired up the I2C port to the processor.

The reason that Pin Assignment Registers are needed is because there are more possible sources of signals from the processor modules (UARTs, timers, GPIO, I2C, etc, etc), than there are pins. It's not possible to use all of the modules on a ColdFire processor at the same time.


Hope this clears up the mystery


Simon
0 Kudos
Reply