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.

CCS/OMAP-L138: [OMAP-L138 LCDK] Can't use enable GPIO pin for simple test

Part Number: OMAP-L138
Other Parts Discussed in Thread: OMAPL138

Tool/software: Code Composer Studio

Hi,

I am using the OMAP-L138 LCDK, and I am trying to toggle the SPI0_CLK pin as a GPIO since it is muxed with GP1[8].

My code is:

#include "soc_OMAPL138.h"
#include "hw_syscfg0_OMAPL138.h"
#include "hw_types.h"

int main(){

unsigned int savePinmux = 0;
	savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) &
	         ~(SYSCFG_PINMUX3_PINMUX3_3_0_SPI0_CLK));
	HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) =
		  (PINMUX3_SPIO_CLK_ENABLE | savePinmux);
	
	GPIODirModeSet(SOC_GPIO_0_REGS, 25, GPIO_DIR_OUTPUT);
	GPIOPinWrite(SOC_GPIO_0_REGS, 25, GPIO_PIN_HIGH);

}

What am I doing wrong?

  • Hi Robert,

    First of all can you add a debug print, which reads the value written to Pin Multiplexing Control 3 Register [3:0] PINMUX3_3_0, so that you are sure you write 4h: Selects Function GP1[8], which means you're muxing GP1[8] on the device pads?

    Second, are you enabling the GPIO module? Take a reference from the GPIO examples in the MCSDK located in ~/ti/pdk_OMAPL138_1_01_00_02/packages/ti/csl/example/omapl138-lcdk/gpio/src/Gpio_example.c.

    Best Regards,
    Yordan
  • Hi Yordan,

    I'm trying to write SPI0_CLK to high, toggling it as a GPIO pin. I can enable the psc module, and I confirmed that I am writing the correct value to the Pinmux3 register:

    The TRM says that I need to toggle the SPIPx registers to correctly configure it as an output and output a logic level of 1.

    Questions:

    What do I write to SPIC3 to control the output value for a logic level of 1?
    How do I write to SPIPC4 and SPIPC5 to change the data out value?
    How do I write and what do I write to SPIPC2 to configure it as an output vs an input?


    My main goal with all of this is to give myself some more GPIO pins to work with on the LCDK. The only GPIO pins available with breakouts currently are 8-10 and 8-12 on J15. If you have another suggestion for a set of pins I should use to enable more GPIO functionality, then please let me know. I've been trying to find how GPIODirSet() and GPIOWrite() are defined, but I have not been able to find a way to understand what those functions are doing so that I may work backwards.

    Code:

    	//SPI Version
    	PSCModuleControl(SOC_SPI_0_REGS, HW_PSC_SPI0, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
    
    	unsigned int savePinmux = 0;
    	savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) & ~(SYSCFG_PINMUX3_PINMUX3_3_0_SPI0_CLK));
    
    	HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) = (PINMUX3_SPIO_CLK_ENABLE | savePinmux);
    
    


    Sorry for such a long post...thanks,

    Robert

  • Hi Robert,

    I am not that well familiar with the RTOS (my main focus is linux kernel) and cannot be of much help here.
    I've asked the RTOS team to elaborate. Their feedback will be posted here.

    Best Regards,
    Yordan
  • Thanks Yordan! Any word from the RTOS team?


    Thanks,

    Robert

  • Hi Robert,

    I've escalated this internally.

    Best Regards,
    Yordan
  • Robert,

    SOrry for the delayed reply on this one. I am not understanding why you are setting the pinmux on the device to SPI_CLK if you want to use the pin as an GPIO. Wouldn`t it be better to setup the PINMUX3[3:0] =4 as that sets the Pin to GP1[8] and then toggle the pin as a GPIO pin.

    The GPIODirModeSet and GPIOPinWrite are meant to be used when the pin is configured as GPIO and not for controlling the pin using SPICx registers. The APIs, you are using write to the pin using GPIO_CLR_DATA or GPIO_SET_DATA registers. for the code to work as you want you need write to the pin using SPIPinControl that writes to the SPIPCx registers in the SPI module. Check the spi.c file in starterware for this function.

    Hope this helps.

    Regards,
    Rahul
  • Hi,

    Sorry for the delay in my response. We found a workaround, so this is not an urgent issue anymore, but I am still personally curious.

    I tried setting it up as a GPIO initially like a GPIO with no success. The code below is based off of a lot of the Starterware code, but it does not work as designed (I only read the pin voltage as low).

       unsigned int savePinmux = 0;
               savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) & ~(SYSCFG_PINMUX3_PINMUX3_3_0));
               HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) = ((SYSCFG_PINMUX3_PINMUX3_3_0_GPIO1_8 << \
                       SYSCFG_PINMUX3_PINMUX3_3_0_SHIFT) | savePinmux);
    
               GPIODirModeSet(SOC_GPIO_0_REGS, 25, GPIO_DIR_OUTPUT);
    
    
        while(1)
        {
            GPIOPinWrite(SOC_GPIO_0_REGS, 25, GPIO_PIN_HIGH);
            Delay(5000000);
            GPIOPinWrite(SOC_GPIO_0_REGS, 25, GPIO_PIN_LOW);
        }

    Thanks again for the help!

    Robert