Simple I/O problem

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

Simple I/O problem

Post by babazaroni »

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;

    for(;;)
    {
        p_scl :> v1;
        p_sda :> v2;
    }

    return 0;
}


User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am
Contact:

Post by segher »

Hi,

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
marker.
babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Post by babazaroni »

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

Post by mon2 »

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:

http://www.xcore.com/projects/basic-i2c ... 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 :)
Post Reply