HCS08: IIC MST-Bit cannot be set (MC9S08DZ60, IIC-Master-Mode)

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

HCS08: IIC MST-Bit cannot be set (MC9S08DZ60, IIC-Master-Mode)

660 Views
alexanderbuerge
Contributor II

Hello all,

 

i am having a problem with IIC Master Mode at MC9S08DZ60CLC MCU. Since two days I try to figure out how to send anything on IIC-bus.

What I did: Initialize IIC -> Try to send 1 byte.

What happens: Nothing (I monitor SDA, SCL with Logic-Analyzer, function verified). SDA, SCL lines stay high always.

What I can do: Toggle the two pins manually when setting them to GPIO.

What I read so far: Datasheet, AN3291 "How to Use IIC Module on M68HC08, HCS08, and HCS12 MCUs", HCS08QRUG.

 

Anybody has any idea what could be the problem?

 

I would expect that my code (at least once) generates a start condition on the bus and/or transmit the data byte...

 

Kind regards,

Alex

 

Here is my (complete!) code:

 

void main(void) {
  MCU_init(); 
  IICC_IICEN = 1;//Enable IIC module
  IICC_TXAK = 1;// SEND ACK
  IICC_MST = 0;//SLAVE MODE    
  IICA = 0b10;//set slave address in IICA  //PTB6=SDA PTB7=SCL

  //set baud rate = BUSCLK/(2xMULTx(SCL Divider))
  //     MUX | ICR|
  //      \\  /////      
  IICF = 0b10010000;//MUX=2,ICR=0x16 Speed=100Khz

  IICS_SRW = 0;//R/W bit  = 0
  IICC_IICIE = 0;//Disable IIC interrupt          

  PTAD_PTAD7 = 1;

  for(;;) {
  
   if(IICC_MST == 1){
     PTAD_PTAD7 = 0;
   }
  
   if(TPM1SC_TOF){

          WriteBytesI2C(0xAB, 0x0);
          IICC_MST = 0;

       TPM1SC_TOF = 0;
   }
            __RESET_WATCHDOG(); //By default COP is disabled with device init. When enabling, also reset the watchdog. */
  } /* loop forever */
  /* please make sure that you never leave main */
}

unsigned char WriteBytesI2C (unsigned char slaveAddress,unsigned char numberOfBytes){
  unsigned char Temp;
 
  /* Format the slave address to place a 0 on the R/W bit (LSB).*/
  slaveAddress &= 0xFE;
  IICC_IICEN = 0;
  IICC_IICEN = 1;
  IICS; /* Clear any pending interrupt */
  IICS_IICIF=1;
  IICC_MST = 0;
  IICS_SRW=0;
  IICC_TX = 1; /* Select Transmit Mode */
  IICC_MST = 1; /* Select Master Mode (Send Start Bit) */
  for(Temp=0;Temp<50;Temp++); /* Small delay */
  IICD=slaveAddress; /* Send selected slave address */
  return(1);
}

Labels (1)
0 Kudos
2 Replies

305 Views
Monica
Senior Contributor III

Hello Alexander,

were these divers helpful? Don't forget to keep us posted :smileyhappy:

Best,

Monica.

0 Kudos

305 Views
weapon
Senior Contributor I

Hi Buergel,

I attached one IIC driver for your reference.

0 Kudos