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.

TMDSIDK437X: Pinmux settings for GPIOs

Part Number: TMDSIDK437X
Other Parts Discussed in Thread: SYSCONFIG

Tool/software: Starterware

Hello,

I have got the IDK-AM437x development kit and try to use the SPI on the J16 connector with some GPIO's.

As base I use the PDK Project "MCSPI_BasicExample_idkAM437xarmTestProject".

I want to enable some GPIO's on the J16 connector and use them for extendet SPI functions. SO i added the following to the following files:

To check if anything is working I added the pinmux for the two rgb leds on the board.

File: "SPI_idkAM437x_board.c"

#include <ti/drv/gpio/GPIO.h>

#include <ti/drv/gpio/soc/GPIO_v1.h>

#include <stdio.h>

 

/* Port and pin number mask for GPIO Load pin.

Bits 7-0: Pin number and Bits 15-8: (Port number + 1) */

#define AM437X_IDK_GPIO_LD_PIN (0x0401)

 

/* LED 0 */

#define GPIO_LED0_RED_PIN_NUM (0x18) //P2.24 A22

#define GPIO_LED0_RED_PORT_NUM (0x02) //P2.24 A22

#define GPIO_LED0_GREEN_PIN_NUM (0x19) //P2.25 A24

#define GPIO_LED0_GREEN_PORT_NUM (0x02) //P2.25 A24

#define GPIO_LED0_YELLOW_PIN_NUM (0x16) //P2.22 B23

#define GPIO_LED0_YELLOW_PORT_NUM (0x02) //P2.22 B23

/* LED 1 */

#define GPIO_LED1_RED_PIN_NUM (0x17) //P2.23 A23

#define GPIO_LED1_RED_PORT_NUM (0x02) //P2.23 A23

#define GPIO_LED1_GREEN_PIN_NUM (0x0D) //P4.13 AB25

#define GPIO_LED1_GREEN_PORT_NUM (0x04) //P4.13 AB25

#define GPIO_LED1_YELLOW_PIN_NUM (0x10) //P4.16 AD21

#define GPIO_LED1_YELLOW_PORT_NUM (0x04) //P4.16 AD21

 

#define GPIO_USER_1_PIN_NUM (0x11) //P4.17 AE21

#define GPIO_USER_1_PORT_NUM (0x04) //P4.17 AE21

#define GPIO_USER_2_PIN_NUM (0x13) //P4.19 AE23

#define GPIO_USER_2_PORT_NUM (0x04) //P4.19 AE23

#define GPIO_USER_3_PIN_NUM (0x15) //P4.21 AE24

#define GPIO_USER_3_PORT_NUM (0x04) //P4.21 AE24

 

/* GPIO Driver board specific pin configuration structure */

GPIO_PinConfig gpioPinConfigs[] = {

/* Output pin : AM437X_IDK_LD_PIN */

AM437X_IDK_GPIO_LD_PIN | GPIO_CFG_OUTPUT ,

/* Output pin LED0 RED P2.24*/

GPIO_DEVICE_CONFIG( (GPIO_LED0_RED_PORT_NUM + 1), GPIO_LED0_RED_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin LED0 Green P2.25*/

GPIO_DEVICE_CONFIG( (GPIO_LED0_GREEN_PORT_NUM + 1), GPIO_LED0_GREEN_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin LED0 Yellow P2.22*/

GPIO_DEVICE_CONFIG( (GPIO_LED0_YELLOW_PORT_NUM + 1), GPIO_LED0_YELLOW_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin LED1 RED P2.23*/

GPIO_DEVICE_CONFIG( (GPIO_LED1_RED_PORT_NUM + 1), GPIO_LED1_RED_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin LED1 Green P4.13*/

GPIO_DEVICE_CONFIG( (GPIO_LED1_GREEN_PORT_NUM + 1), GPIO_LED1_GREEN_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin LED1 Yellow P4.16*/

GPIO_DEVICE_CONFIG( (GPIO_LED1_YELLOW_PORT_NUM + 1), GPIO_LED1_YELLOW_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin USER 1 P4.17*/

GPIO_DEVICE_CONFIG( (GPIO_USER_1_PORT_NUM + 1), GPIO_USER_1_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin USER 2 P4.19*/

GPIO_DEVICE_CONFIG( (GPIO_USER_2_PORT_NUM + 1), GPIO_USER_2_PIN_NUM) | GPIO_CFG_OUTPUT,

/* Output pin USER 3 P4.21*/

GPIO_DEVICE_CONFIG( (GPIO_USER_3_PORT_NUM + 1), GPIO_USER_3_PIN_NUM) | GPIO_CFG_OUTPUT

};

in the "main.cpp":

/* ON Board LED pins which are connected to GPIO pins. */

typedef enum GPIO_PIN {

GPIO_PIN_LD_PIN = 0U,

GPIO_PIN_LED0_RED,

GPIO_PIN_LED0_GREEN,

GPIO_PIN_LED0_YELLOW,

GPIO_PIN_LED1_RED,

GPIO_PIN_LED1_GREEN,

GPIO_PIN_LED1_YELLOW,

GPIO_PIN_USER1,

GPIO_PIN_USER2,

GPIO_PIN_USER3,

GPIO_PIN_COUNT

}GPIO_PIN;

 

to use the gpios (also leds):

GPIO_init();

GPIO_write(GPIO_PIN_LED0_RED, GPIO_PIN_VAL_LOW);

GPIO_write(GPIO_PIN_LED0_GREEN, GPIO_PIN_VAL_LOW);

GPIO_write(GPIO_PIN_LED0_YELLOW, GPIO_PIN_VAL_LOW);

//Turn all LED's off - LED 1

GPIO_write(GPIO_PIN_LED1_RED, GPIO_PIN_VAL_LOW);

GPIO_write(GPIO_PIN_LED1_GREEN, GPIO_PIN_VAL_LOW);

GPIO_write(GPIO_PIN_LED1_YELLOW, GPIO_PIN_VAL_LOW);

GPIO_write(GPIO_PIN_USER1, GPIO_PIN_VAL_HIGH);

GPIO_write(GPIO_PIN_USER2, GPIO_PIN_VAL_HIGH);

GPIO_write(GPIO_PIN_USER3, GPIO_PIN_VAL_HIGH);


The Led's are working really fine only the other 3 GPIO's (User 1,2,3) are not doing anything.

Do I have to Change the pinmux on an other file too?

 

Kind regard
Fkaiser

  • Hi Florian,

    Could you use CCS to dump the BOOTCFG registers to see if the configuration of the GPIOs are configured properly?

    Lali
  • Hello Lali,

    Thanks for the quick reply. I can't find the bootcfg Register in the debugger and datasheet:
    www.ti.com/.../spruhl7f.pdf
    Could you tell me where do I find this register?
    Here is the configuration of GPIO4:

    R GPIO4_GPIO_REVISION 0x0000000B 0x50601801
    R GPIO4_GPIO_SYSCONFIG 0x0000000B 0x00000000
    R GPIO4_GPIO_EOI 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_RAW_0 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_RAW_1 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_0 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_1 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_SET_0 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_SET_1 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_CLR_0 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQSTS_CLR_1 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQWAKEN_0 0x0000000B 0x00000000
    R GPIO4_GPIO_IRQWAKEN_1 0x0000000B 0x00000000
    R GPIO4_GPIO_SYSSTS 0x0000000B 0x00000000
    R GPIO4_GPIO_CTRL 0x0000000B 0x00000002
    R GPIO4_GPIO_OE 0x0000000B 0xFFD4DFFF
    R GPIO4_GPIO_DATAIN 0x0000000B 0x0001000C
    R GPIO4_GPIO_DATAOUT 0x0000000B 0x002B0000
    R GPIO4_GPIO_LEVELDETECT0 0x0000000B 0x00000000
    R GPIO4_GPIO_LEVELDETECT1 0x0000000B 0x00000000
    R GPIO4_GPIO_RISINGDETECT 0x0000000B 0x00000000
    R GPIO4_GPIO_FALLINGDETECT 0x0000000B 0x00000000
    R GPIO4_GPIO_DEBOUNCEN 0x0000000B 0x00000000
    R GPIO4_GPIO_DEBOUNCINGTIME 0x0000000B 0x00000000
    R GPIO4_GPIO_CLRDATAOUT 0x0000000B 0x002B0000
    R GPIO4_GPIO_SETDATAOUT 0x0000000B 0x002B0000
  • Florian,

    Do you an example project that you can pass me so that I can try and reproduce this?
    I'm sure you already are, but are you connected to the correct pins on the header?

    Lali
  • Hello Lali,

    sorry for the Long time waiting. You'll find a small example Project in the attachment.

    The app just sends some data over spi0 and toggle the all six led's on the idk board.

    I want to enable the  3 user Pins:

    GPIO_PIN_USER1 + 2 +3

    On the AM437_idk board:

    User 1 AE21: J16 Pin9

    User 2 AE23: J16 Pin23

    User 3 AE24: J16 Pin21

    MCSPI_TestApp.zip

     

  • Hi Florian,

    Quick question.

    Isn't AE23 =  Pin 19 and NOT pin 23 on J16 on the AM437xIDK? I assume your board is a Rev 1.3A.

    schematic: processors.wiki.ti.com/.../AM437X_INDUSTRIAL_EVM_3K0008_schematic_REV1_3A.pdf

    I'm taking a look at the others, and will post back here once I have an update.

    Lali

  • Hello Lali,

    here is the full filled gpio table, I didn't add the J16 connector Pins.

    //Definition: Value Gpio Pkg. Connector

    //Definition:				     Value   Gpio	Pkg.        Connector
    #define GPIO_USER_1_PIN_NUM    	(0x11) //P4.17	AE21	J16.9
    #define GPIO_USER_1_PORT_NUM   	(0x04) //P4.17	AE21	J16.9
    #define GPIO_USER_2_PIN_NUM    	(0x13) //P4.19	AE23	J16.19
    #define GPIO_USER_2_PORT_NUM   	(0x04) //P4.19	AE23	J16.19
    #define GPIO_USER_3_PIN_NUM    	(0x15) //P4.21	AE24	J16.21
    #define GPIO_USER_3_PORT_NUM   	(0x04) //P4.21	AE24	J16.21
    
    #define GPIO_USER_4_PIN_NUM    	(0x04) //P5.4	P25		J16.6
    #define GPIO_USER_4_PORT_NUM   	(0x05) //P5.4	P25		J16.6
    #define GPIO_USER_5_PIN_NUM    	(0x0A) //P4.10	AC23	J16.4
    #define GPIO_USER_5_PORT_NUM   	(0x04) //P4.10	AC23	J16.4
    #define GPIO_USER_6_PIN_NUM    	(0x0B) //P4.12	AC25	J16.12
    #define GPIO_USER_6_PORT_NUM   	(0x04) //P4.12	AC25	J16.12

    Ok the strange thing is, with the GPIO_USER_4 to 6 it's working. I can use them as Output Pins, but still not as Input Pins?

    Is there any lock register or something I Need to set before? Can this be caused by the bootloader? The bootloader (the SPL) is Setting up the DDR and some other Interfaces, so if the the booloader is set up those Pins and "lock" them, I can't change anything. Does this make sanse?

    thanks for your help.

    Kind regards

    Florian Kaiser

  • Hi Florian,

    I took your test program MCSPI_BasicExample_idkAM437x_armTestProject.out and was able to run it on the AM437xIDK and also saw the LEDs blinking as intended. To answer your question on setting the pins as input, here is an experiment to try.

    Once you have loaded your code and have it running, halt the core and look at the CCS memory window specifically at addresses 0x48320134 and 0x48322134 (GPIO4_GPIO_OE and GPIO5_GPIO_OE(offset 0x134)).

    Are you able to double-click poke this value and change it in the CCS memory window? 

    I was able to do it as you can see it from the screenshot below. So, I don't think the GPIO direction register is not getting "locked".

    This is the address of register GPIO4_GPIO_OE and GPIO5_GPIO_OE(offset 0x134) which indicates the direction (input or output) of configuration of that particular pin.

    pg 3731 of http://www.ti.com/lit/ug/spruhl7f/spruhl7f.pdf has a description of this register a 1 bit for input and 0 for output. Of course the base address of the register changes depending on which GPIO module you are looking at. In your case its GPIO4 and GPIO5.

    Please let me know how it goes.

    Lali

  • Hi Florian,

    Hope my last response resolved your issues.
    Please close this thread if so. Thanks.

    Lali
  • Hello Lali,

    I was in hollidays last week. Okay I tested your experiment on my board. I connected an Oszilloskop on J16.6 which is "GPIO_PIN_USER4" and  J16.4  which is the "GPIO_PIN_USER5".

    USER4 is still working, I can write an Output value and read the coresponding Input value back. If I Change the "GPIO4_GPIO_OE" Register to 0x00000000 the Output should be disabled, right? I set the value to zero and the ouput is still working. CCS is showing me the value I set before (zero).

    On USER5 Ican set an ouput value but I can't read it back. Still the same behavior with the "GPIO5_GPIO_OE" as the "GPIO4_GPIO_OE"

    Maybe a lock?

    Kind regards

    FKaiser

     

  • Hi Florian,

    I'm a bit confused by your reply.

    USER4 is still working, I can write an Output value and read the coresponding Input value back. If I Change the "GPIO4_GPIO_OE" Register to 0x00000000 the Output should be disabled, right? I set the value to zero and the ouput is still working. CCS is showing me the value I set before (zero).

    The GPIO4_GPIO_OE register doesn't disable the pin, it just changes the direction to either Input or Output.

    "CCS is showing me the value I set before (zero)". Do you mean the value for GPIO4_GPIO_OE? A value of zero sets it as an output.

    Lali

  • Hello,

    thanks for the quick reply. You was right, I just used the wrong value. With 0xFFFFFFFF instead of 0x00 the GPIO_USER5 is not working as expected.

    So this is my test code:

    		//----------------------------------------------
    		GPIO_toggle(GPIO_PIN_USER1);
    		resGpio = GPIO_read(GPIO_PIN_USER1);
    		SPI_log(" 1= %X ",(resGpio != 0) ? 1 : 0 );
    		//----------------------------------------------
    		GPIO_toggle(GPIO_PIN_USER2);
    		resGpio = GPIO_read(GPIO_PIN_USER2);
    		SPI_log(" 2= %X ",(resGpio != 0) ? 1 : 0 );
    		//----------------------------------------------
    		GPIO_toggle(GPIO_PIN_USER3);
    		resGpio = GPIO_read(GPIO_PIN_USER3);
    		SPI_log(" 3= %X ",(resGpio != 0) ? 1 : 0 );
    		//----------------------------------------------
    		GPIO_toggle(GPIO_PIN_USER4);
    		resGpio = GPIO_read(GPIO_PIN_USER4);
    		SPI_log(" 4= %X ",(resGpio != 0) ? 1 : 0 );
    		//----------------------------------------------
    		GPIO_toggle(GPIO_PIN_USER5);
    		resGpio = GPIO_read(GPIO_PIN_USER5);
    		SPI_log(" 5= %X ",(resGpio != 0) ? 1 : 0 );
    		//----------------------------------------------
    		GPIO_toggle(GPIO_PIN_USER6);
    		resGpio = GPIO_read(GPIO_PIN_USER6);
    		SPI_log(" 6= %X ",(resGpio != 0) ? 1 : 0 );
    

    I toggle an GPIO and read the output back. This is done in a loop, so all outputs toggle in a fixed frequency.

    The output in the console Looks like this:

    <\r>Num= 18 state= 1  tx= a0 a1 a2 a3 a4 a5 a6 a7 a8 a9  Rx= 55 55  1= 0  2= 0  3= 0  4= 1  5= 0  6= 0  J1= 0 <\r><\n>
    <\r>Num= 19 state= 1  tx= a0 a1 a2 a3 a4 a5 a6 a7 a8 a9  Rx= 55 55  1= 1  2= 0  3= 0  4= 0  5= 0  6= 0  J1= 0 <\r><\n>
    <\r>Num= 20 state= 1  tx= a0 a1 a2 a3 a4 a5 a6 a7 a8 a9  Rx= 55 55  1= 0  2= 0  3= 0  4= 1  5= 0  6= 0  J1= 0 <\r><\n>
    <\r>Num= 21 state= 1  tx= a0 a1 a2 a3 a4 a5 a6 a7 a8 a9  Rx= 55 55  1= 1  2= 0  3= 0  4= 0  5= 0  6= 0  J1= 0 <\r><\n>
    <\r>Num= 22 state= 1  tx= a0 a1 a2 a3 a4 a5 a6 a7 a8 a9  Rx= 55 55  1= 0  2= 0  3= 0  4= 1  5= 0  6= 0  J1= 0 <\r><\n>
    <\r>Num= 23 state= 1  tx= a0 a1 a2 a3 a4 a5 a6 a7 a8 a9  Rx= 55 55  1= 1  2= 0  3= 0  4= 0  5= 0  6= 0  J1= 0 <\r><\n>
    <\r>Num= 24 state= 1  tx= a0 a1 a2 a3 a4 a5 a6 a7 a8 a9  Rx= 55 55  1= 0  2= 0  3= 0  4= 1  5= 0  6= 0  J1= 0 <\r><\n>

    The marked part is the output of the test above. There you can see that GPIO_USER1 is toggling and the output can be read back (pattern 1 - 0 -1 ....). The GPIO_USER4 is doing the same.

    GPIO_USER 2, 3 , 5 and 6 are not working in this way. For example we used the GPIO_USER5 before. This one is toggling but can not be read back like in the code above. The measurement is done with an Oszilloskope connected to the GPIO_USER5 Pin on the board connector J16.4

    My Problem is that I can not read back this GPIO and I don't know why.

    Your experiment now showed that the Input/output Register is not locked. I'm confused that the ouput is working well but I can not read back the Input? Do I need to enable the Input?

    I hope my explanation is better now :D

    This are the Register values when the GPIO_USER5  (P4.10 J16.4) is logic '0'

    And this in logic '1' state:

    thanks

    FKaiser

  • Hi Florian,

    Yes, its clear :)

    I know that we have discussed quite a few things on this thread and things might have been missed. So, I would like to hit the reset button a bit.

    Question:

    If I get you a working example that configures GPIOs J16.9, J16.19 and J16.21 on the AM437x IDK as INPUT, and also an example on configuring them as OUTPUT, would that help bring you closer to addressing your problem?

    I can document how to do this from the pinmux changes, to the code changes to get this going. Please let me know.

    Lali

  • Hello Lali,

    that would be awesome :D.

    I've made a little list with the GPIO data:

    //Definition:					Value	Gpio	Pkg.	Connector  Out  Read
    #define GPIO_USER_1_PIN_NUM    	(0x0B) //P4.11	AE21	J16.9		ok	ok
    #define GPIO_USER_1_PORT_NUM   	(0x04) //P4.11	AE21	J16.9		ok	ok
    #define GPIO_USER_2_PIN_NUM    	(0x13) //P4.19	AE23	J16.19		X	x
    #define GPIO_USER_2_PORT_NUM   	(0x04) //P4.19	AE23	J16.19  	X	x
    #define GPIO_USER_3_PIN_NUM    	(0x15) //P4.21	AE24	J16.21  	X	x
    #define GPIO_USER_3_PORT_NUM   	(0x04) //P4.21	AE24	J16.21  	X	x
    
    #define GPIO_USER_4_PIN_NUM    	(0x04) //P5.4	P25		J16.6		ok	ok
    #define GPIO_USER_4_PORT_NUM   	(0x05) //P5.4	P25		J16.6		ok	ok
    #define GPIO_USER_5_PIN_NUM    	(0x0A) //P4.10	AC23	J16.4		ok	X
    #define GPIO_USER_5_PORT_NUM   	(0x04) //P4.10	AC23	J16.4		ok	X
    #define GPIO_USER_6_PIN_NUM    	(0x0C) //P4.12	AC25	J16.12		X	X
    #define GPIO_USER_6_PORT_NUM   	(0x04) //P4.12	AC25	J16.12		X	X

    Working GPIOs are J16.9 and J16.6, those can be written and read back as expected.

    Most interesting Pin is J16.4 because this one have a working Output and a not working Input.

    It would be really great if you can pass me a simple Project with those Pins working as expected :D

    regards

    Florian

     

  • Florain,

    Thanks for the summary. It gives a good overall picture.
    Please give me some time to dig into this and get back to you. Appreciate your patience.

    Lali
  • Hi Florian,

    Thanks for your patience while I looked into this.

    There is a diagnostics test for the push buttons in the PDK under C:\ti\pdk_am437x_1_0_5\packages\ti\board\diag\button

    However, the test is for the GPEVM and not the IDK. You should be able to build this using gmake. Instructions are here http://processors.wiki.ti.com/index.php/Processor_SDK_RTOS_DIAG 

    The .out will be generated under C:\ti\pdk_am437x_1_0_5\packages\ti\board\bin\evmAM437x\armv7

    Ensure that you have PDK_RAW_BOOT defined as described here http://processors.wiki.ti.com/index.php/Processor_SDK_RTOS_DIAG#Running_or_debugging_on_CCS , Other wise the example may not run.

    It seems that by default in the diag example, all the GPIO4 pins are configured as input. So, you may be able to manipulate the button example to take an input from J16.4 for instance, and see if it reads as expected.

    There's also an LED blink example where U1 and U2 on the board can be toggled. I have attached a .out for that one here.

    /cfs-file/__key/communityserver-discussions-components-files/791/led_5F00_diagExample_5F00_idkAM437x_5F00_armv7.out

    Lali