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.

AM3359 ICE GPIO config

Other Parts Discussed in Thread: AM3359

Hi all.

I want to configure an AM3359 pin as GPIO input on ICE dev board. The pin is GPIO1.8. 

Thihs is the configuration code:

	// GPIO.0 POWER ENABLE
	HWREG( SOC_PRCM_REGS + 0x408 )  			   |= 0x2;
	// GPIO.1 POWER ENABLE
	HWREG( SOC_PRCM_REGS + 0x0AC )  			   |= 0x2;


	// PINMUX SETUP
	HWREG( 0x44E10948) = 7 | 0;	//	gpio0[0]	mdio_data -> LED 6a
	HWREG( 0x44E1094C) = 7 | 0;	//	gpio0[1]	mdio_clk  -> LED 6b
	HWREG( 0x44E10954) = 7 | 0;	//	gpio0[3]	spi0_d0  -> output
	HWREG( 0x44E10968) = 7 | 0;	//	gpio1[8]	uart0_ctsn  -> input

	GPIODirModeSet(SOC_GPIO_0_REGS,0,GPIO_DIR_OUTPUT);
	GPIODirModeSet(SOC_GPIO_0_REGS,1,GPIO_DIR_OUTPUT);
	GPIODirModeSet(SOC_GPIO_0_REGS,3,GPIO_DIR_OUTPUT);
	GPIODirModeSet(SOC_GPIO_1_REGS,8,GPIO_DIR_INPUT);


Then a simple loop procedure get the pin state and toggles accordingly a led in ICE board and a GPIO pin:

		if (GPIOPinRead(SOC_GPIO_1_REGS,8))
		{
			GPIOPinWrite(SOC_GPIO_0_REGS, 3,GPIO_PIN_HIGH);
			GPIOPinWrite(SOC_GPIO_0_REGS, 0,GPIO_PIN_HIGH);
		}
		else
		{
			GPIOPinWrite(SOC_GPIO_0_REGS, 3,GPIO_PIN_LOW);
			GPIOPinWrite(SOC_GPIO_0_REGS, 0,GPIO_PIN_LOW);
		}

The GPIOPinWrite() is working, but the GPIOPinRead() always returns FALSE, so nothing lits up.

Suggestions?

  • Hello Eugenio,

    Firstly, apologize for the late reply.

    The code snippets that you have provided in your post are quite clear.

    However, I see that the Pin Multiplexing code is incomplete. It  is assumed that you are referring to the Pad Control Register to perform Pin Multiplexing. This register description is present in the Control Module chapter of the AM335x TRM. Please find the register description snapshot attached.

    The Pin multiplexing details for GPIO1[8] is given below.

    Bit 6 : SLEWCTRL : Fast – 0

    Bit 5:  RXACTIVE :  Receiver Enabled :  1 (Since GPIO1[8] shall be used an Input pin)

    Bit 4:  PULLTYPESEL :  Pullup selected : 1

    Bit 3: PULLUDEN : Pullup/pulldown enabled – 0

    Bits 2:0 : MUXMODE : 7

    Therefore the pin multiplexing code for GPIO1[8] is:

    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_UART_CTSN(0)) = (0x20 | 0x10| 0x7)

     

    Similar procedure for Pin Multiplexing has to be followed for all the other pins in context.

     

    Thanks and Regards.

    Gurudutt.

  • Hi eugenio,

    These are the basic steps to toggle the GPIO line

    Pinmux:-

    Do pinmux configurations accordingly

    GPIO:- Set gpio3 pin to high

    Set GPIO value:

    gpio_reg_val = 0x00000008; /* for GPIO3 */
    writel(gpio_reg_val, GPIO0_BASE + 0x194);

    Set GPIO direction:

    gpio_reg_val = readl(GPIO0_BASE + 0x134);
    gpio_reg_val &= ~(0x00000008);
    writel(gpio_reg_val, GPIO0_BASE + 0x134);

    Note: Make sure that same pinmux registers are not configured for different purpose

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Hi 

    i have question regarding  MYD-AM335X Development Board ,how to find the GPIO pin usage  how to access  individual pins from the board ,i have referred AM335x TRM but i cant find relevant information  please help me .

     

    Regards

    Prasad.m