This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM42L432: RM42: N2HET I2C Emulation no interrupts

Part Number: RM42L432
Other Parts Discussed in Thread: HALCOGEN

Hi,

i ported the N2HET I2C emulation to RM42 and it is already working. I can see SCL/SDA being correct with my oszilloscope.

But i didnt connect any slave and so i expect to get an no-ack interrupt. But i didnt get any interrupt at all.

Does somebody had made the same experiences?

ISR from N2HET IC2 sample code:

#pragma CODE_STATE(het1HighLevelInterrupt, 32)
#pragma INTERRUPT(het1HighLevelInterrupt, IRQ)

void het1HighLevelInterrupt(void)
{
    uint32_t vect = hetREG1->OFF1;
	switch (vect)
    {
    case 11: /*--------------------------->      Transmit interrupt */
    	if(Data_Send_HET<3)
    	{
    		HetI2CPutData(*I2C1_txptr++, IntEna);
    		Data_Send_HET++;
    	}
    	if(Start_Repeat==1)
    	{
    		if(Data_Send_HET<5)
    		{
    			HetI2CPutData(*I2C1_txptr++, IntEna);
    			Data_Send_HET++;
    		}
    		else if(Data_Send_HET==5)
    		{
    			RW = 1; //Read
    			IntEna = 0;//no transmit interrupt
    			HetI2CPutAddr(I2C2_ADDR, RW, 2, IntEna, 1);//now, start to receive two data bytes and generate stop bit
    		}
    	}
    	break;
    case 15: /*--------------------------->      Receive interrupt */
    	*I2C1_rxptr++ = (hetRAM1->Instruction[0x2C].Data>>8) & 0xFF;  // read the data
    	Data_Rece_HET++;
        break;
   	case 18:  /*--------------------------->      No ACK interrupt */

   	case 29: /* timeout2*/
   	case 8: /* timeout6*/
   	case 2: /* timeout9*/

   	default:
        	/* timeout + phantom interrupt, clear flags and return */
       	while(1);
       	break;
    }


	//*I2C2_rxptr++ = i2cREG1->DRR;  // read the data
    //		Data_Rece++;
    //        break;
    //    case 5:  /*--------------------------->      Transmit interrupt */
    //    		i2cREG1->DXR = *I2C2_txptr++;  // send the data
    //    		Data_Send++;
	//hetNotification(hetREG1,vec);
}

/* USER CODE BEGIN (6) */
/* USER CODE END */

Best regards,

Malte

  • Hello,

    This emulated I2C example code supports the interrupts of TX, RX, NACK, and timeout.

    Did you enable the NHET interrupt using hetREG1->INTENAS = 0xFFFFFFFFU and IRQ interrupt _enable_IRQ()?

    If the interrupts are enabled, did you get I2C TX interrupt?

  • Hi,

    yes i did. I already received interrupts from a previous n2het programm running (configured by halcogen).

    But to make sure i also used the example code and even there i didnt receive a NAK or TIMEOUT interrupt.

    Dont have any peripheral connected to I2C bus. Maybe this makes a difference? So i can see the NAK on the address on oscillisocope. Now im not sure whether these interrupts do happen when writing the address?

  • Sorry my mistake... :/ disabled interrupts again.

    Nevertheless thanks for ur support!!