i2c how to read and write

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

i2c how to read and write

8,639件の閲覧回数
wade985136
Contributor II

Use 1837 sdk  periph_i2cm_polling  example

IDE LPCXpresso

I tried to read and write some data, and I read some information
But I don’t know how to write 3bit
E.g
Write 0x2e
Read out as 0x00
As shown below 1.png

Hope someone can help me
Thank you

static void SetupXferRecAndExecute(uint8_t devAddr,
uint8_t *txBuffPtr,
uint16_t txSize,
uint8_t *rxBuffPtr,
uint16_t rxSize)
{
/* Setup I2C transfer record */
i2cmXferRec.slaveAddr = devAddr;
i2cmXferRec.options = 0;
i2cmXferRec.status = 0;
i2cmXferRec.txSz = txSize;
i2cmXferRec.rxSz = rxSize;
i2cmXferRec.txBuff = txBuffPtr;
i2cmXferRec.rxBuff = rxBuffPtr;
Chip_I2CM_XferBlocking(LPC_I2C0, &i2cmXferRec);
}

static void WriteBoard_I2CM(int writeVal)
{
uint8_t tx_buffer[3];

/* set configuration to default value */
tx_buffer[0] = BANK_0; /* Write to Config register */
tx_buffer[1] = 0;

SetupXferRecAndExecute(SMB_ADDR, tx_buffer, 3, NULL, 0);
}


static void BANK0_read()
{
uint8_t tx_buffer[3];
uint8_t rx_buffer[3];

tx_buffer[0] = BANK_0; /* Read the Voltage across the shunt */
rx_buffer[0] = 0;
Write_BAN0();
SetupXferRecAndExecute(SMB_ADDR, tx_buffer, 1, rx_buffer, 2);
DEBUGOUT("BANK_0: 0x%02X%02X\r\n", rx_buffer[0], rx_buffer[1]);

}

0 件の賞賛
返信
14 返答(返信)

8,574件の閲覧回数
Alexis_A
NXP TechSupport
NXP TechSupport

Hello Wade,

I still don't understand what you mean with 3bit, but since this sometimes works and other times don't I will suggest checking the signal with an oscilloscope to discard any hardware problems.

Also, I'm not familiarized with this device so be sure the write sequence an address is doing correctly.

Let me know your findings.

Best Regards,

Alexis Andalon

0 件の賞賛
返信

8,566件の閲覧回数
wade985136
Contributor II

HI Alexis_A

Excuse me, how does this board enter ISP MODE?

I do not see COME ACMO in LINUX

0 件の賞賛
返信

8,560件の閲覧回数
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @wade985136 ,

There are two ways to enter the ISP mode:

  • In the power-on hold low the P2_7.
  • Call the reinvoke ISP ROM API in your software.

Best Regards,
Alexis Andalon

 

0 件の賞賛
返信

8,552件の閲覧回数
wade985136
Contributor II

hi Alexis_A

How to modify it? ISP ROM API in your software.

Thank you

0 件の賞賛
返信

8,543件の閲覧回数
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @wade985136 ,

In the following link you can find a list of example to use with the LPC18xx. In this package there's an example called flashIAP that has a list of ROM commands, the reinvoke IAP between them.

You need to also import these projects to your workspace if you want to run these examples:

Alexis_A_0-1599771812070.png

Best Regards,

Alexis Andalon

 

0 件の賞賛
返信

8,454件の閲覧回数
wade985136
Contributor II

hiAlexis_A

1. How do I see vcom on linux?
2. Do you want to change from uart isp mode?
3. Which version of sdk are you using in the iap mode mentioned earlier
I am using sdk 3.02 version

Thank you

Best Regards

0 件の賞賛
返信

8,438件の閲覧回数
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @wade985136 ,

1. How do I see vcom on linux?

 Please try this command:

dmesg | grep tty

2. Do you want to change from uart isp mode?

I'm not understanding this question, but the usual procedure to communicate with the ISP is to send the command unlock to start the communication.


3. Which version of sdk are you using in the iap mode mentioned earlier

I'm using the SDK including in the MCUXpresso 2.20 but the one you're using the latest one should be better.

Best Regards,

Alexis Andalon

0 件の賞賛
返信

8,385件の閲覧回数
wade985136
Contributor II

Hello, Alexis_A

I tried many times, I still can’t change uart isp to usb isp
Can you help me, how can I modify it?

0 件の賞賛
返信

8,373件の閲覧回数
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @wade985136,

Please check the Table 16. Boot mode when OTP BOOT_SRC bits are zero, this section mention the state the boot pins need to be to boot from the different available sources:

 
 
 

Screenshot 2020-10-05 154837.png

Best Regards,

Alexis Andalon

0 件の賞賛
返信

8,511件の閲覧回数
wade985136
Contributor II

1. Is there any tool to do FLASH update on ARM LINUX

2. When I execute the IAP SDK, after displaying the ID, no other things will be displayed. Do I need to enter other commands?

0 件の賞賛
返信

8,496件の閲覧回数
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @wade985136 ,

Usually, we use the flash magic tool (link) to communicate with LPC devices in ISP mode but this is only available for windows.

Also, we have a tool called LPCScrypt (link) that can be used for this purpose.

Best Regards,

Alexis Andalon

0 件の賞賛
返信

8,613件の閲覧回数
Alexis_A
NXP TechSupport
NXP TechSupport

Hello Wade,

I don't understand what are you trying to achieve, for what I'm understanding is that you're trying to read/write a register from other device but the device is not answering as expected, am I right?

Best Regards,

Alexis Andalon

0 件の賞賛
返信

8,599件の閲覧回数
wade985136
Contributor II

HI  Alexis_A 

When I tried to write 3BIT,
Sometimes it succeeds, sometimes it fails
tx_buffer [0] = 0x03;
tx_buffer [1] = 0x0C;
tx_buffer [2] = 0x30;
tx_buffer [3] = 0xC0;

thank you for your help

 

0 件の賞賛
返信

8,606件の閲覧回数
wade985136
Contributor II

YES

 

0 件の賞賛
返信