Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VNC2 and I2C

Status
Not open for further replies.

willycat

Newbie level 6
Newbie level 6
Joined
Aug 22, 2011
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,430
Hi,

i would like to use an RTC chip with the VNC2 using an I2C interface. There is an I2C driver supplied with the Vinculum2 toolchain, but there is no documentation nor example on how to use it.

I use a vnc2-32L1B chip for my project. I decided to use for the I2C interface the pin 14 for the data signal and the pin15 for the clock signal. 4K pull up resistors are connected to these pins and for that moment, nothing else is connected to these pins except my scope.

I don't know if it is necessary to configure the port, but i do this at the main initialization:

C:
// Configure direction of port B
vos_gpio_set_port_mode(GPIO_PORT_B, 0xc0);
  
// For the data signal
vos_iomux_define_bidi(14, IOMUX_IN_GPIO_PORT_B_2,    IOMUX_OUT_GPIO_PORT_B_6);
  
// For the clock signal
vos_iomux_define_bidi(15, IOMUX_IN_GPIO_PORT_B_3,    IOMUX_OUT_GPIO_PORT_B_7);

Here is the code to initialise the I2C driver:

C:
#define VOS_DEV_I2C 5

VOS_HANDLE hI2C;

// IOCTL request block
i2c_ioctl_cb_t i2c_iocb;
// Structure for defining ports
i2c_port_t i2c_port;

// For testing
unsigned char buf[32];
unsigned int red;

// Define the I2C pins
i2c_port.clkPort = I2C_PORT_B;
i2c_port.clkPortNo = 14; // For pin 15
i2c_port.dataPort = I2C_PORT_B;
i2c_port.dataPortNo = 13; //For pin 14
i2c_device_init(VOS_DEV_I2C, &i2c_port);

// Open I2C Interface
hI2C = vos_dev_open(VOS_DEV_I2C);

// Set i2c options
i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_OPTIONS;
i2c_iocb.data = I2C_OPTIONS_READ_ADDRESS;
vos_dev_ioctl(hI2C, &i2c_iocb);

// Set rtc address
i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_DEVICE_ADDRESS;
i2c_iocb.data = 0x68;
vos_dev_ioctl(hI2C, &i2c_iocb);

// Set the address to read from
i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_RDWR_ADDRESS;
i2c_iocb.data = 0x10;
vos_dev_ioctl(hI2C, &i2c_iocb);

To read four bytes from the RTC Chip, i use this:


C:
vos_dev_read(hI2C, buf, 4, &red);

But nothing happen on my scope, signals are at 0v.

Where can be the problem ? Does someone has an example on how to use this I2C driver ?


Thanks,

Willy.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top