Simple I/O problem

All technical discussions and projects around startKIT
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Simple I/O problem

Postby babazaroni » Mon Sep 01, 2014 10:33 pm

On startkit, I'm using J7 (24 pin connector) to connect to some external device.

As a test, I tried to read the first two pin on J7, which are pulled high. The problem is, they read as low.

Why can't I read the true state of these pins?

Here is the code:

Code: Select all

#include <xs1.h>

in port p_scl = XS1_PORT_1H;
in port p_sda = XS1_PORT_1F;

int main(void) {

    int v1,v2;

        p_scl :> v1;
        p_sda :> v2;

    return 0;
User avatar
XCore Expert
Posts: 843
Joined: Sun Jul 11, 2010 1:31 am

Postby segher » Mon Sep 01, 2014 11:18 pm


How do you read the values of v1,v2? Your code does not
actually use those values so the compiler can well have
decided not to store them at all (it does have to do the
actual I/O though), so looking at it with the debugger might
not be as enlightening as you hope for.

Are you sure you have the right pins? Pin 1 has the square
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Postby babazaroni » Tue Sep 02, 2014 12:04 am

It's mysteriously working now, after a few jtag unplugs and debugger restarts. Baffling.
User avatar
XCore Legend
Posts: 1880
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Tue Sep 02, 2014 12:37 am

You noted that you are connecting to an external device. Any chance that device is pulling the I2C lines low ? As a test, remove the external devices from the J2 connector and leave the pull-ups still there (which will be required for I2C interfacing) - now can you read high values ?

For I2C, both SDA and SCL lines need pull-ups.

Also the same pins are shared with the PCIe connector. Any slicecard seated inside of the PCIe connector ? If yes, remove the slicecard and test again.

There are many stable I2C code postings that work well but here is the one we used on the XK-1A board with success: ... ng-adt7410

Verified with an external I2C device & Total Phase's Beagle tool.

As a suggestion, you should stabilize this quirk before working with I2C which expands the level of fun :)

Who is online

Users browsing this forum: No registered users and 0 guests