I2C Scanner using Processor Expert for S32K146EVB

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

I2C Scanner using Processor Expert for S32K146EVB

ソリューションへジャンプ
1,377件の閲覧回数
Nibesh
Contributor III

Hello I am working on I2C Scanner by using S32K146EVB using Processor Expert.

I am able to initialize I2C and while reading the Acknowledge, it is giving a problem.

I have attached my file for your kind reference..
I hope to hear from you soon..
@VaneB @Senlent 

0 件の賞賛
返信
1 解決策
1,350件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Nibesh,

Sorry for not testing it for you in the previous question I2C Scanner using S32K146EVB-Q144. But as I mentioned there, since the LPI2C_init of S32K146_Project_LPI2C configure MCFGR1[IGNACK] to Ignore NACK by default, and its LPI2C_Transmit uses MTDR[CMD]=5 by default:101b  Generate (repeated) START and transmit address in DATA[7:0]. This transfer expects a NACK to be returned.
So you can't judge the acknowledgement by polling MSR[NDF](NACK Detect Flag).

Please try to test the following code:

void LPI2C_Transmit (uint8_t address)/* Transmit ID and expects an ACK to be returned */
{
LPI2C0->MTDR = (0x04<<8)|((address<<1)|0);
}

 

LPI2C_DRV_MasterInit(0, &lpi2c1_MasterConfig0, &lpi2c1MasterState);
LPI2C0->MCFGR1 |= LPI2C_MCFGR1_AUTOSTOP_MASK; //Automatic STOP Generation

 

       for(i=1; i<127; i++)
       {
//       LPI2C_DRV_MasterSetSlaveAddr(INST_LPI2C1, i, false);
       LPI2C_Transmit(i);
       delay(100);
        if((((LPI2C0->MSR) & LPI2C_MSR_NDF_MASK) >> LPI2C_MSR_NDF_SHIFT)==true)
        {
        LPI2C0->MSR &= LPI2C_MSR_NDF_MASK;
        LPUART_DRV_SendDataBlocking(INST_LPUART2, Space, sizeof(Space), TIMEOUT);
        }
        else
        {
sprintf( Buffer,"0x%X", i);
LPUART_DRV_SendDataBlocking(INST_LPUART2, Buffer, sizeof(Buffer), 10000);
        }
       }

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
1,351件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Nibesh,

Sorry for not testing it for you in the previous question I2C Scanner using S32K146EVB-Q144. But as I mentioned there, since the LPI2C_init of S32K146_Project_LPI2C configure MCFGR1[IGNACK] to Ignore NACK by default, and its LPI2C_Transmit uses MTDR[CMD]=5 by default:101b  Generate (repeated) START and transmit address in DATA[7:0]. This transfer expects a NACK to be returned.
So you can't judge the acknowledgement by polling MSR[NDF](NACK Detect Flag).

Please try to test the following code:

void LPI2C_Transmit (uint8_t address)/* Transmit ID and expects an ACK to be returned */
{
LPI2C0->MTDR = (0x04<<8)|((address<<1)|0);
}

 

LPI2C_DRV_MasterInit(0, &lpi2c1_MasterConfig0, &lpi2c1MasterState);
LPI2C0->MCFGR1 |= LPI2C_MCFGR1_AUTOSTOP_MASK; //Automatic STOP Generation

 

       for(i=1; i<127; i++)
       {
//       LPI2C_DRV_MasterSetSlaveAddr(INST_LPI2C1, i, false);
       LPI2C_Transmit(i);
       delay(100);
        if((((LPI2C0->MSR) & LPI2C_MSR_NDF_MASK) >> LPI2C_MSR_NDF_SHIFT)==true)
        {
        LPI2C0->MSR &= LPI2C_MSR_NDF_MASK;
        LPUART_DRV_SendDataBlocking(INST_LPUART2, Space, sizeof(Space), TIMEOUT);
        }
        else
        {
sprintf( Buffer,"0x%X", i);
LPUART_DRV_SendDataBlocking(INST_LPUART2, Buffer, sizeof(Buffer), 10000);
        }
       }

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛
返信
%3CLINGO-SUB%20id%3D%22lingo-sub-1886934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EProcessor%20Expert%20for%20S32K146EVB%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%9FI2C%E3%82%B9%E3%82%AD%E3%83%A3%E3%83%8A%E3%83%BC%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1886934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF%E3%80%81%E7%A7%81%E3%81%AFProcessor%20Expert%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6S32K146EVB%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6I2C%E3%82%B9%E3%82%AD%E3%83%A3%E3%83%8A%E3%83%BC%E3%81%AB%E5%8F%96%E3%82%8A%E7%B5%84%E3%82%93%E3%81%A7%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3EI2C%E3%82%92%E5%88%9D%E6%9C%9F%E5%8C%96%E3%81%A7%E3%81%8D%E3%80%81Acknowledge%E3%82%92%E8%AA%AD%E3%82%93%E3%81%A7%E3%81%84%E3%82%8B%E3%81%A8%E5%95%8F%E9%A1%8C%E3%81%8C%E7%99%BA%E7%94%9F%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E7%A7%81%E3%81%AF%E3%81%82%E3%81%AA%E3%81%9F%E3%81%AE%E8%A6%AA%E5%88%87%E3%81%AA%E5%8F%82%E7%85%A7%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AB%E7%A7%81%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E6%B7%BB%E4%BB%98%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F..%3CBR%20%2F%3E%E3%81%99%E3%81%90%E3%81%AB%E3%81%94%E9%80%A3%E7%B5%A1%E3%82%92%E3%81%8A%E5%BE%85%E3%81%A1%E3%81%97%E3%81%A6%E3%81%8A%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F201913%22%20target%3D%22_blank%22%3E%40VaneB%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F188029%22%20target%3D%22_blank%22%3E%40Senlent%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E