Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

OMAPL138 LCDK DSP GPIO

$
0
0

I have written some simple code for ARM (all my code runs) and now I want to do the same things on the DSP.

Now I have written something (Some Codesnippets are from the examples from TI) but It don't work right.


The programm should write on the console a 0 when the Userbutton is pressed else it should stand a 1.

I can compile and run the code, but i dont hav e a 0/1 i always have 15730432...(On the Console at the Desktop - Putty)

later I want the LED also to be On/Off if the button is On/Off (Also in the code but at the moment // or /**/)

I have CSS 5.4, OMAPL138 LCDK and the code is NOT for SYSBIOS

Here is the source of it:

/**
 * \file  timerCounter.c
 *
 * \brief Sample application for timer.
 */
/* 		S2        GPIO2[4]	Button	S2
 *		S3        GPIO2[5]	Button	S3
 *		D3        GPIO1[6]	LED 	D3
 *		D4        GPIO1[7]	LED 	D4
 *
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
* .................................
*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "gpio.h"
#include "psc.h"

//For UART output
#include "uart.h"
#include "string.h"
#include "uartStdio.h"
#include "lcdkOMAPL138.h"
/* HW Macros */
#include "hw_types.h"
/* System Defines */
#include "lcdkOMAPL138.h"
#include "soc_OMAPL138.h"
#include "hw_syscfg0_OMAPL138.h"
/****************************************************************************/
/*                      GLOBAL VARIABLES                                    */
/****************************************************************************/
static volatile unsigned int pinValue = 0;

void PrintFError ( const char * format, ... )
{
  char buffer[256];
  va_list args;
  memset( buffer,0, sizeof(buffer));
  va_start (args, format);
  vsprintf (buffer,format, args);
  UARTPuts(buffer, -1);
  va_end (args);

}
void sys_debug( const char *const fmt, ... )
{
	PrintFError(fmt);
}
/*****************************************************************************
**                       PIN MULTIPLEXING
*****************************************************************************/
///* Pin Multiplexing of pin 4 of GPIO Bank 2.*/
void GPIOBank2Pin4PinMuxSetup(void)
{
     unsigned int savePinmux = 0;

     /* /brief
	 ** - SYSCFG0 SOC_SYSCFG_0_REGS  --> Memory-mapped registers for system confic module 0 (SYSCFG0) Fot Pinmultiplexing always use 0.
	 ** - PINMUX6 PINMUX(6)  --> Pin Multiplexing 6 Register - which register and for Pin xyz can be find in the datasheet on page 244.
	 ** - PINMUX6_15_12 PINMUX6_15_12_GPIO2_4 --> ...6_15_12 6 is The PINMUX register and 15_12 is the Corresponding 4bit field in the PINMUXn register
	 **   the 4 Bit field depends on the GPIO pin you can find the bit field in the datasheet on page 244.
     */

     /*
     ** Clearing the bit in context and retaining the other bit values
     ** in PINMUX6 register.
     */
     savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(6)) &
                  ~(SYSCFG_PINMUX6_PINMUX6_15_12));
     /* Setting the pins corresponding to GPIO2[4] in PINMUX6 register.*/
     HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(6)) = ( (SYSCFG_PINMUX6_PINMUX6_15_12_GPIO2_4  << SYSCFG_PINMUX6_PINMUX6_15_12_SHIFT) | savePinmux);
}
// Pin Multiplexing for the LED
void GPIOBank1Pin6PinMuxSetup(void)
{
    unsigned int savePinmux = 0;
    /*/brief
     * for details show "void GPIOBank2Pin4PinMuxSetup(void)"
    */
    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(0)) &
                 ~(SYSCFG_PINMUX0_PINMUX0_27_24));

    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(0)) = ( (SYSCFG_PINMUX0_PINMUX0_27_24_GPIO0_9  << SYSCFG_PINMUX0_PINMUX0_27_24_SHIFT) | savePinmux);

}

/*****************************************************************************
**                       			MAIN
*****************************************************************************/

int main(void)
{

	//for UART output
    UARTStdioInit();

	//...PSC is Power Sleep Controller
	PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,   PSC_MDCTL_NEXT_ENABLE);

	  /* Pin Multiplexing of pin 4 of GPIO Bank 2.*/
	  GPIOBank2Pin4PinMuxSetup();
	  /* Pin Multiplexing of pin 6 of GPIO Bank 1.*/
	  //GPIOBank1Pin6PinMuxSetup();

	  /* Sets the pin 37(GP2[4]) as input.*/
	  GPIODirModeSet(SOC_GPIO_0_REGS, 37, GPIO_DIR_INPUT); //SOC_GPIO_0_REGS, 37 --> 37 is the pin - can be find in the datashees at page 900
	  /* Sets the pin 23 (GP1[6]) as output.*/
	  //GPIODirModeSet(SOC_GPIO_0_REGS, 10, GPIO_DIR_OUTPUT);

	  while( 1 )
	  {
		  pinValue = GPIOPinRead(SOC_GPIO_0_REGS, 37); //SOC_GPIO_0_REGS, 37 --> 37 is the pin to read. pin can be find in the datashees at page 900
		  sys_debug( "Pin high(1) or low(0): %i \n", pinValue); // UART Output
		  //GPIOPinWrite(SOC_GPIO_0_REGS, 10, pinValue); //Write pin Value (LOW or HIGH) to LED
	  }

	return 0;
}

Here is the .CMD

/****************************************************************************/
/*  OMAPL138.cmd                                                            */
/*  Copyright (c) 2010 Texas Instruments Incorporated                       */
/*  Author: Rafael de Souza                                                 */
/*                                                                          */
/*    Description: This file is a sample linker command file that can be    */
/*                 used for linking programs built with the C compiler and  */
/*                 running the resulting .out file on an OMAPL138           */
/*                 device.  Use it as a guideline.  You will want to        */
/*                 change the memory layout to match your specific          */
/*                 target system.  You may want to change the allocation    */
/*                 scheme according to the size of your program.            */
/*                                                                          */
/*    Usage:       The map below contains the local memory for each core    */
/*                 Use the linker option --define=DSP_CORE=n                */
/*                 Where n defines the core used: DSP (n=1) or ARM (n=0)    */
/*                                                                          */
/****************************************************************************/

MEMORY
{
#ifdef DSP_CORE      /* DSP exclusive memory regions */

    DSPL2ROM     o = 0x00700000  l = 0x00100000  /* 1MB L2 DSP local ROM */
    DSPL2RAM     o = 0x00800000  l = 0x00040000  /* 256kB L2 DSP local RAM */
    DSPL1PRAM    o = 0x00E00000  l = 0x00008000  /* 32kB L1 DSP local Program RAM */
    DSPL1DRAM    o = 0x00F00000  l = 0x00008000  /* 32kB L1 DSP local Data RAM */

#endif

    SHDSPL2ROM   o = 0x11700000  l = 0x00100000  /* 1MB L2 Shared Internal ROM */
    SHDSPL2RAM   o = 0x11800000  l = 0x00040000  /* 256kB L2 Shared Internal RAM */
    SHDSPL1PRAM  o = 0x11E00000  l = 0x00008000  /* 32kB L1 Shared Internal Program RAM */
    SHDSPL1DRAM  o = 0x11F00000  l = 0x00008000  /* 32kB L1 Shared Internal Data RAM */
    EMIFACS0     o = 0x40000000  l = 0x20000000  /* 512MB SDRAM Data (CS0) */
    EMIFACS2     o = 0x60000000  l = 0x02000000  /* 32MB Async Data (CS2) */
    EMIFACS3     o = 0x62000000  l = 0x02000000  /* 32MB Async Data (CS3) */
    EMIFACS4     o = 0x64000000  l = 0x02000000  /* 32MB Async Data (CS4) */
    EMIFACS5     o = 0x66000000  l = 0x02000000  /* 32MB Async Data (CS5) */
    SHRAM        o = 0x80000000  l = 0x00020000  /* 128kB Shared RAM */
    DDR2         o = 0xC0000000  l = 0x20000000  /* 512MB DDR2 Data */

#ifndef DSP_CORE     /* ARM exclusive memory regions */

    ARMROM       o = 0xFFFD0000  l = 0x00010000  /* 64kB ARM local ROM */
    ARMRAM       o = 0xFFFF0000  l = 0x00002000  /* 8kB ARM local RAM */

#endif
}

SECTIONS
{
    .text          >  SHRAM
    .stack         >  SHRAM
    .bss           >  SHRAM
    .cio           >  SHRAM
    .const         >  SHRAM
    .data          >  SHRAM
    .switch        >  SHRAM
    .sysmem        >  SHRAM
    .far           >  SHRAM
    .args          >  SHRAM
    .ppinfo        >  SHRAM
    .ppdata        >  SHRAM
    
    /* TI-ABI or COFF sections */
    .pinit         >  SHRAM
    .cinit         >  SHRAM
    
    /* EABI sections */
    .binit         >  SHRAM
    .init_array    >  SHRAM
    .neardata      >  SHRAM
    .fardata       >  SHRAM
    .rodata        >  SHRAM
    .c6xabi.exidx  >  SHRAM
    .c6xabi.extab  >  SHRAM
}

 Hope Someone can  me help.


Sorry for my bad english...


Greetz Fernando


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>