Jump to content
43oh

SOLVED :Code issues: automated setting of GPADIR for GPIOpins >15 problematic


Recommended Posts

Hi all,

 

I am developing a simple codelibrary that should make setting the pins for input/output of the C2k launchpad easier. I am using definitions for the pins that correspond to the physical pinnumbers on J1/J2 and J5/6. So a user can set pin J2_2 as output without a need to think if this pin is a real GPIO or an ADCpin.

 

I am running however into problems with the piece of code below:

 

if (pinmode==GPIO_Direction_Output)
{ GpioCtrlRegs.GPADIR.all |= (1<<pinNumber); // set the pin to output, set bit=1
}
else

{ GpioCtrlRegs.GPADIR.all &= ~(1<<pinNumber); // set the pin to input, set bit=0
}

pinNumber corresponds to the normal GPIOnumber of any pin, pinmode simply represets 0=input or 1=output.

 

When I call this code with pinNumber=17 and pinmode=1, GPIO1 gets set for output instead of GPIO17. I first had pinNumber declared as an uint16_t variable, changed that into uint32_t variable but the problem remained the same ...

 

Anybody with a clue as to why I am running into this limitation ?

For GPIO0 -GPIO15 the code works as planned ...

 

regards

Cor

Link to post
Share on other sites

Hi,

 

Ive allread updated the code - see other message in this forum - using your original suggestion. Sometimes you can do a lot of searching for things that arent obvious ! Now we can easily set any of the connectorpins high/low etc without the need to know if the pin is GPIO or ADC and without the need to know which GPIO/ADC is connected to which pin. Now you just state OutputPin(J2_10) and pin 10 on connector 2 will be prepared for output.

 

cheers

 

Cor

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...