POrts of Startkit Topic is solved

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

POrts of Startkit

Postby cschopges » Mon Jul 25, 2016 2:12 pm

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

Postby Gothmag » Mon Jul 25, 2016 4:44 pm

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: 1679
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Mon Jul 25, 2016 5:02 pm

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

Postby cschopges » Tue Jul 26, 2016 9:17 am

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

Who is online

Users browsing this forum: No registered users and 1 guest