treating the pins of a 4pin port as 4 1pin ports?

Technical discussions around xCORE processors (e.g. General Purpose (L/G), xCORE-USB, xCORE-Analog, xCORE-XA).
sanandak
New User
Posts: 2
Joined: Thu Nov 25, 2010 3:45 am

treating the pins of a 4pin port as 4 1pin ports?

Postby sanandak » Tue Dec 21, 2010 11:17 pm

Hi, is it possible to create one's own 1bit port at an arbitrary pin - for example, pin X0D14 is bit 0 for PORT_4C and X0D15 is bit 1 of that port. Can I create MYPORT_P1C0, for example, that connects to X0D14 and MYPORT_P1C1 that talks to X0D15?

Alternatively, how would I use those two physical lines independently in port PORT_4C?

Any suggestions?

Thanks!
Sridhar
User avatar
lilltroll
XCore Expert
Posts: 955
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Postby lilltroll » Wed Dec 22, 2010 2:10 am

You can use the AND, OR & XOR

An example if it's an output port, and you want to change the state of 3:rd pin, set 4:th pin to 1 and 1:st pin to 0, but keep the state of the 2:nd pin.


unsigned portState=0;
....
portState^=0b0100;
portState|=0b1000;
portState&=0b1110;
p<:portState;


Input port example:
unsigned temp;

p:> temp;
Inpin1=temp&0b0001;
Inpin2=(temp&0b0010) >0;
Inpin3=(temp&0b0100) >0;
Inpin4=temp>>4;
Probably not the most confused programmer anymore on the XCORE forum.

Who is online

Users browsing this forum: No registered users and 5 guests