This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am trying to configure GPIO 31 of the TMS320F280041 MCU by access the control registers directly.
I am on step one in the technical reference manual:
I am pretty sure that GPIO 31 belongs to Port A, so that would mean I need to access the GPAMUX and the GPAGMUX.
Here are my questions:
What does the "1/2" mean in GPAMUX 1/2?
What specific GPAMUX register/bit do I need to write to in order to control GPIO31?
Hi Michael,
See TRM chapter 8.7.2.:
As you can see MUX1 is for GPIO0 to GPIO15, and MUX2 for GPIO16 to GPIO31.
Each register is described in detail, so you can check which bits you have to set.
May I ask: why not use driverlib functions? It is much easier this way.
Regards,
Andy
Hi Andy,
I am just trying to learn this from the ground up.
I will eventually transition to using the driverlib functions once I have a good understanding of how everything works.
Okay so from that table I will need to access the GPAMUX2 and GPAGMUX2 registers.
Looking at the GPAMUX2 register, it looks like bits 30 and 31 control GPIO31.
So I have to write a 0 to bits 30 and 31 of the GPAMUX2 register, is that correct?
I am not sure what that would look like in the Code Composer Studio.
[Name of register] |= 0x00 //is that correct??
I would strongly recommend using driverlib, as this is efficient end easy to use.
For example, setting GPIO31 in GPIO mode is made with this simple call:
GPIO_setPinConfig(GPIO_31_GPIO31);
You can check the source code of GPIO_setPinConfig() function in the C2000Ware.
I don't know which MUX option you want to set; setting GMUX and MUX bits to 0 sets the pin in GPIO mode, but this is default after reset.
When setting the register manually you need to enclose the register change with EALLOW/EDIS macros, as these registers are protected.
[Name of register] |= 0x00 //is that correct??
OR'ing with 0x00 makes no effect. For example to set bit0 use
[REG] |= 0x01
To clear bit0 use:
[REG] &= ~0x01
Regards,
Andy
Okay Andy, you have convinced me.
Following the configuration steps listed in the TRM, which driverlib functions would I need to call to initialize GPIO31 as a GPIO?
Use these functions (example setup):
GPIO_setPinConfig(GPIO_31_GPIO31);
GPIO_setDirectionMode(31, GPIO_DIR_MODE_IN);
GPIO_setQualificationMode(31, GPIO_QUAL_6SAMPLE);
GPIO_setPadConfig(31, GPIO_PIN_TYPE_PULLUP);
Regards,
Andy
So does the setPadConfig(); function only apply when we are setting the pin as GPIO?
For example, if I configure GPIO31 as the SPIB_SOMI, setPadConfig(); would not be used or need to be used, right?
The answer is on this picture from TRM:
As you can see, the pull-up is at the very pin output, so it works in all MUX settings.
Regards,
Andy
I understand that it exists for all MUX settings, but I don't necessarily need to call it for all MUX settings (for example in the case that the pin is being used as SPI SOMI). Is that correct?
All pullups are disabled by default after reset. So yes, if you are using SPI SOMI, the setPadConfig() call is not needed.
Andy