L series: pull_up() = pull_down() plus set_port_inv() ?

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
User avatar
mjcross
Member++
Posts: 16
Joined: Wed Jun 29, 2011 5:39 pm

L series: pull_up() = pull_down() plus set_port_inv() ?

Post by mjcross »

In process of porting my I2C driver from XC-1A (G series device) to XK-1A (L series device).

Soon found that the 'L' series devices throw an exception on set_port_pull_up(). Doh.

Member 'jai' refers to this in their post "RE: unused ports" on 22 Jul 2011:
PS: XS1-L series does not have PullUps, they have only PullDowns
Incidentally, kudos to anyone who can point me to the correct place in the XMOS specs that confirms this..

The lack of pull_up() is a nuisance, because on the I2C bus devices need to drive the bus low and tristate for logic '1'. So using pull_up() mode on a one-bit XS-1 port is great, because you can define the port as a output (hence benefiting from serialisation etc.), and still read the replies back from other peripherals using peek() without having to reconfigure the port as an input.

Hence my question: if I combine set_port_pull_down() with set_port_inv(), can I re-produce the effect of set_port_pull_up() ?

Furthermore, what's the effect of the above on peek() - is it reversed by set_port_inv() ?

I guess I can test this with a simple enough circuit, but in case anyone knows already I thought I would ask...

MARTIN


User avatar
mjcross
Member++
Posts: 16
Joined: Wed Jun 29, 2011 5:39 pm

Post by mjcross »

Actually, on reflection I think that pull_down() mode is what I need anyway for the I2C application; I misunderstood the terminology. I'm still interested in the question though :)
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

On I2C, you only ever pull the bus low: the pullup is external.

The easiest way to handle that is to drive the port low when you want the
bus to go low, and switch the port to input when you want it to float high.
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Post by paul »

mjcross wrote: Hence my question: if I combine set_port_pull_down() with set_port_inv(), can I re-produce the effect of set_port_pull_up() ?
No- the port inverse is to do with the inversion of the data values coming out of it.
mjcross wrote: Furthermore, what's the effect of the above on peek() - is it reversed by set_port_inv() ?
No. Peek is a separate path as it bypasses much of the port logic.
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
MaxFlashrom
Experienced Member
Posts: 82
Joined: Fri Nov 05, 2010 2:59 pm

Post by MaxFlashrom »

mjcross wrote: Member 'jai' refers to this in their post "RE: unused ports" on 22 Jul 2011:
PS: XS1-L series does not have PullUps, they have only PullDowns
Incidentally, kudos to anyone who can point me to the correct place in the XMOS specs that confirms this..
MARTIN
The XS1-L01A-TQ128 Datasheet in the table in section 3 shows port pins as labelled with PDs(switchable pull-down). The datasheet says these have a resistance of 35KOhm. I imagine this means they can be enabled on inputs and be overridden by an external high logic level without upsetting the hardware. This may be useful to stop them floating when used on a tristate bus that is not driven by some master all the time or if they are left unconnected in a hardware design. As you found, code run on an L series throws an exception if you try to set pull-up. It is not recommended that you enable the pull-downs to attempt to pull-down an external weak logic high as they are weak, too. Drive the pin logic low output for wire-or operation to pull down an external weak pull-up(as in I2C) . This pull-up/down behaviour difference between G and L series parts is not well documented. There are useful notes in the xs1.h header file:

Code: Select all

/**
 * Enables a port's internal pull-up resistor. When nothing is driving a pin the
 * pull-up resistor ensures that the value sampled by the port is 1. The pull-up
 * is not strong enough to guarantee a defined external value. On XS1-G devices
 * calling set_port_pull_up() has the side effect of configuring the port in
 * drive low mode. On XS1-L devices no pull-up resistors are available and an
 * exception will be raised if set_port_pull_up() is called.
 * \param p The port to configure.
 * \sa set_port_pull_down
 * \sa set_port_pull_none
 * \sa set_port_drive_low
 */
void set_port_pull_up(void port p);

/**
 * Enables a port's internal pull-down resistor. When nothing is driving a pin
 * the pull-down resistor ensures that the value sampled by the port is 0. The
 * pull-down is not strong enough to guarantee a defined external value. On
 * XS1-G devices no pull-down resistors are available and an exception will be
 * raised if set_port_pull_down() is called. On XS1-L devices calling
 * set_port_pull_down() has the side effect of configuring the port in drive low
 * mode.
 * \param p The port to configure.
 * \sa set_port_pull_up
 * \sa set_port_pull_none
 * \sa set_port_drive_low
 */
void set_port_pull_down(void port p);
Max.