688 views|5 replies

8

Posts

0

Resources
The OP
 

I am a novice who wants to know how to use the I2C of N32G430. My knowledge of I2C is limited. I really need help! [Copy link]

This post was last edited by Jiju1 on 2023-12-30 17:32

I want to know that there are two boards now, one board is the minimum system board of N32G430, and the other board is an integrated board

Now I want to use N32G430 to control the clock module DS1307 or memory chip 24c02 in the integrated board through I2C

First attach the integrated circuit diagram halo2015 V2版 电路图.pdf (127.49 KB, downloads: 0)
It can be seen that PE1 and PE2 are connected
Attached is the N32G430 series data sheet UM_N32G430系列用户手册V1.pdf (11.64 MB, downloads: 0)
It can be seen that the pins corresponding to I2C1 are PB6 and PB7
So how can I control it via I2C under these known conditions;
For example, writing some data to the storage chip, or getting the current time through DS1307?
This post is from MCU

Latest reply

In addition to I2C, there is also LIN Can bus   Details Published on 2023-12-31 23:01
 

6593

Posts

0

Resources
2
 

To write data between I2C and storage chip, the I2C control host needs to send control commands to the bus first.

This post is from MCU
 
 

6787

Posts

2

Resources
3
 

You can directly look at the official IIC communication example! It will be more clear there!

This post is from MCU
 
 
 

4771

Posts

12

Resources
4
 

Yes, go and see the official routines and run them first, then add other codes to improve them.

This post is from MCU
 
 
 

4771

Posts

12

Resources
5
 

In addition to I2C, there is also LIN Can bus

This post is from MCU
 
 
 

8

Posts

0

Resources
6
 

I looked at the official example code and found an I2C_Master_Int example code, which also uses I2C to control the 24C02 memory chip.

After I connected the line, I found that the serial port would only have this situation and could not continue to run downwards

So I looked up the usage of the 24C01 chip and found that when A1, A2, and A3 are all connected to GND, the device address is 0XA0

So I looked at the address in the sample code and found that it was defined as 0x10

So I changed the device address to 0xa0 and ran it again and found that the result did not change

It was still stuck there and didn't finish running, so I added serial port output functions to various places in the code to determine where it was stuck.

But I found that it didn't get stuck after adding the output function, so I guessed that it might be due to the lack of delay, so I added a delay function

After adding it, I found that it can run normally until the end.
At this time, I found that the output is incorrect

Output

So the written data and the output data are inconsistent.

So I added

The output result is as shown in the figure (the front is the read data, and the back is the written data)

It turned out that the data was wrong, but I found out from multiple test data and some information on the Internet that

This may be caused by inconsistency in the locations where data is written and read.

So I tried to define the write position and read position, but unfortunately it failed.

I haven't found any information about this, and I really don't know how to do it.

But I found out from the information on the Internet that when writing data, if you write to the end of a page, then when reading, it will start reading from the initial position of this page.

So I changed the size of the data written

The blog I found used a size of 8, but I found it was 16 through experimentation

Then I ran it again

The written data is consistent with the read data;

At this point, the writing and reading of the memory chip is completed.

But obviously this is not correct. What I want is to write data and read data. I need to know where I wrote the data and where I should read the data from. I did not find any information about this in the sample code.

There are also some information on how to write data to a specified location on the Internet, but I found that their method is like this

Send the memory address to be written after sending the address and write bit

But I found

 I2C_7bit_Addr_Send(I2C1, EEPROM_ADDRESS, I2C_DIRECTION_SEND);
    I2C_Data_Send(I2C1, address);  // 发送内存地址
    I2C_Data_Send(I2C1, data);  // 发送数据
It's always like this. I'm curious why sending memory addresses like this is not considered as sending normal data.

And it also needs to be sent when reading, I don’t understand it either
In short, I just haven’t learned it, is there any big guy who can help me

This post is from MCU
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list