I am trying to establish I2c protocol between the FPGA board and an external device(a TI board) in which the FPGA board acts as master and sends the data.
I created the Zynq processing IP and enabled I2C1 for the corresponding pins. I exported the .xsa file to XIlinx Vitis and coded by referring the example given in the examples directory for i2c_master_polled_example.c.
The code is as follows.
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************//*
* helloworld.c: simple test application
*
* This application configures UART 16550 to baud rate 9600.
* PS7 UART (Zynq) is not initialized by this application, since
* bootrom/bsp configures it to baud rate 115200
*
* ------------------------------------------------
* | UART TYPE BAUD RATE |
* ------------------------------------------------
* uartns550 9600
* uartlite Configurable only in HW design
* ps7_uart 115200 (configured by bootrom/bsp)
*/#include"xparameters.h"#include"xiicps.h"#include"xil_printf.h"#define IIC_DEVICE_ID XPAR_XIICPS_0_DEVICE_ID
#define IIC_SLAVE_ADDR 0x55#define IIC_SCLK_RATE 100000XIicPsIicPsInstance;/* Instance of the IIC Device */staticvoid i2c_init();staticvoid datasend();staticvoid i2c_init(){XIicPs_Config*Config;/*
* Initialize the IIC driver so that it's ready to use
* Look up the configuration in the config table, then initialize it.
*/Config=XIicPs_LookupConfig(IIC_DEVICE_ID);XIicPs_CfgInitialize(&IicPsInstance,Config,Config->BaseAddress);/*
* Perform a self-test.
*/XIicPs_SelfTest(&IicPsInstance);XIicPs_SetSClk(&IicPsInstance, IIC_SCLK_RATE);}staticvoid datasend(){unsignedchar sendbuffer[3]={0xA,0xB,0xC};//uint8_t myReadBuffer[3] = {};//xil_printf("the value at receive buffer before datasend is %X\n",rcvbuffer[0]);XIicPs_MasterSendPolled(&IicPsInstance,sendbuffer,3, IIC_SLAVE_ADDR );
xil_printf("Transferred successfully\n");}int main(){
i2c_init();
datasend();return0;}
I am unable to receive the data in the slave.. what am I missing?
Question
Niranjana
Hi ,
I am trying to establish I2c protocol between the FPGA board and an external device(a TI board) in which the FPGA board acts as master and sends the data.
I created the Zynq processing IP and enabled I2C1 for the corresponding pins. I exported the .xsa file to XIlinx Vitis and coded by referring the example given in the examples directory for i2c_master_polled_example.c.
The code is as follows.
I am unable to receive the data in the slave.. what am I missing?
Link to comment
Share on other sites
0 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now