Page 1 of 1

POrts of Startkit

Posted: Mon Jul 25, 2016 2:12 pm
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 :)

Re: POrts of Startkit

Posted: Mon Jul 25, 2016 4:44 pm
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.

Re: POrts of Startkit

Posted: Mon Jul 25, 2016 5:02 pm
by mon2

Re: POrts of Startkit

Posted: Tue Jul 26, 2016 9:17 am
by cschopges
Thank you for your answers.
I'll try to make my own handler then. :-)