POrts of Startkit Topic is solved

All technical discussions and projects around startKIT
Post Reply
cschopges
Member++
Posts: 28
Joined: Mon Jul 25, 2016 2:03 pm

POrts of Startkit

Post by cschopges »

Hello everyone,

I may have a stupid question, but after looking for without finding an answer, I thought that you guys might help me.
I want to use the button on the startkit. To do so, I define a port. The only problem is I don't know which port to use. In the datasheet, the button corresponds to 32A0.
Thus by defining:
port p_button = XS1_PORT_32A;
I get the button on one bit but I have the other 31 bits I don't want.

What should I write instead of XS1_PORT_32A to get the button on ist own?

Thank you :)


View Solution
Gothmag
XCore Addict
Posts: 129
Joined: Wed May 11, 2016 3:50 pm

Post by Gothmag »

The way it works... You don't. That's a 32 bit port and it always will be for the button. What you want is to either use the startkit support libraries so you can use leds and button, or write your own GPIO handler to control bits of 32 bit port individually. Its fairly easy to mask them, and AND NOT a bit, and then OR a bit for setting it. Just check out the startkit support library if you want to see examples of that.

If you define the other ports that are also used for the 32 I don't think the compiler takes issue but you have to make sure you pull the value, twiddle bits you need, and write it back or youll get weird issues inadvertently changing port values, and you probably shouldn't spread them out over a bunch of threads or you may.run into access issues. What I've usually done is just written my own handler for leds and button and had it all run as 1 thread.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

cschopges
Member++
Posts: 28
Joined: Mon Jul 25, 2016 2:03 pm

Post by cschopges »

Thank you for your answers.
I'll try to make my own handler then. :-)
Post Reply