求助:KE02的I2C求解(已解决)

2020-02-20 20:52发布

本帖最后由 ayaqby 于 2014-11-13 10:09 编辑

#define I2C_SLAVE_ADDRESS1          0x50
uint8_t u8I2C_SendBuff[64];
uint8_t u8I2C_ReceiveBuff[64];
int main (void)
{
  
部分代码未显示

        while(1)
        {
        I2C_MasterSendWait(I2C0,I2C_SLAVE_ADDRESS1,&u8I2C_SendBuff[0],64);
        I2C_MasterReadWait(I2C0,I2C_SLAVE_ADDRESS1,&u8I2C_ReceiveBuff[0],64);
        printf("Read data from I2C slave: ");
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
            {
                printf("0x%x,", u8I2C_ReceiveBuff[i*8+j]);
            }

            printf(" ");
        }
        u8I2C_SendBuff[0]++;
        for(i=1;i<64;i++)
        {
            u8I2C_SendBuff = i+u8I2C_SendBuff[0];
        }
        for(i=0;i<0xfffff;i++);
        }

}
在读库函数例程的时候#define I2C_SLAVE_ADDRESS1          0x50我理解为从设备地址,请问这个地址是PRDM-KE02Z上面的哪个地址 还是KE02芯片内部的地址呢,求大神帮助,谢谢
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
22条回答
ayaqby
1楼-- · 2020-02-21 17:41
FSL_TICS_ZJJ 发表于 2014-11-13 09:40
对的,需要两块的FRDM板子做I2C通信的。
另外板上有个加速度传感器8451,但是它作为从机,地址不是0X50。
...

I2C_MasterPoll_demo这个例程在一个FRDM板子上运行得到的数据如下
-System Log BEGINS--


Familly ID = 0x0, Sub-family ID = 0x2, Revision ID = 0x0, Pin ID = 0x7
Pin Reset

--System Log ENDS--


Running the I2C_MasterPoll_demo project.
Read data from I2C slave:
0xA1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
Read data from I2C slave:
0xA1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
我的理解是这些数据是从I2C从设备读出来的,请问这个从设备是板子的哪里呢,谢谢
ayaqby
2楼-- · 2020-02-21 22:23
FSL_TICS_ZJJ 发表于 2014-11-13 09:40
对的,需要两块的FRDM板子做I2C通信的。
另外板上有个加速度传感器8451,但是它作为从机,地址不是0X50。
...

I2C_MasterPoll_demo这个例程在一个FRDM板子上运行得到的数据如下
-System Log BEGINS--


Familly ID = 0x0, Sub-family ID = 0x2, Revision ID = 0x0, Pin ID = 0x7
Pin Reset

--System Log ENDS--


Running the I2C_MasterPoll_demo project.
Read data from I2C slave:
0xA1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
Read data from I2C slave:
0xA1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
我的理解是这些数据是从I2C从设备读出来的,请问这个从设备的地址 是哪里呢,谢谢
ayaqby
3楼-- · 2020-02-22 02:57
网络延时么,回一次贴怎么会出现两个呢
FSL_TICS_ZJJ
4楼-- · 2020-02-22 07:04
本帖最后由 FSL_TICS_ZJJ 于 2014-11-13 10:00 编辑
ayaqby 发表于 2014-11-13 09:49
I2C_MasterPoll_demo这个例程在一个FRDM板子上运行得到的数据如下
-System Log BEGINS--


楼主,是另一块板子呢。
其实在KEXX_DRIVERS_V1.2.1_DEVDkexx_drv_libsrcprojectsKE02I2C_MasterPoll_demo
这个路径下面有个readme.txt.里面讲的很清楚,如何使用。


@par Example description
     ===================
This example provides a template for I2C master with poll mode.
it cycle to transfer a frame data(64 bytes) and show it on terminal.
it also provide a template for how to initialize I2C module.

@par Code configuration
     ===================
Make sure the following macros are defined in ke02_config.h:
   USE_FEE and
   EXT_CLK_FREQ_KHZ macro is defined to 10000.

@par Directory contents
     ==================
- platforms/ke02_config.h               library and board Configuration file
- projects/ke02/isr.h                   Interrupt handler installation
- projects/ke02/I2C_MasterPoll_demo.c   Main program

@par Hardware environment
     ====================
- Board: freedom FRDM-KE02Z, revA
         - Requirement for demo:
                 1. populate R47,R39
                2. connect two boards with J2 18-18(SDA),20-20(SCL), 14-14(GND)        
       
  
@par How to use it
     =============
In order to make the program work, you must do the following :
- Rebuild all project files and load demo code into the device
- Connect J6 USB port to the computer that will find serial terminal port
- Open the serial terminal
- Configure the serial terminal to protocol: 8-N-1, 115200bps, and flow control: none
- Run the example
FSL_TICS_ZJJ
5楼-- · 2020-02-22 08:58
 精彩回答 2  元偷偷看……
ayaqby
6楼-- · 2020-02-22 10:46
FSL_TICS_ZJJ 发表于 2014-11-13 09:58
楼主,是另一块板子呢。
其实在KEXX_DRIVERS_V1.2.1_DEVDkexx_drv_libsrcprojectsKE02I2C_MasterPol ...

没看readme是我的错,只买了一块板子啊

一周热门 更多>