industrialNETworXnetx

ihd

ihd

| 18.12.2008 | 10:30 | 3 replies

LED blink with GPIO driver of rcX

hi,
i tried to write a little blink example for the "NetStick 50", using the GPIO driver to toggle the output LEDs, which i suppose to be connected to the GPIO's 4-7, am i right?

but i still don't manage it to work. could you pls give me a hint?

my task:

static CONST FAR RX_STATIC_TASK_T FAR atrXStaticTasks[] = {
  {"SimpleExample",                         /* Set Identification             */
   TSK_PRIO_25, TSK_TOK_25,                 /* Set Priority,and Token ID      */
   0,                                       /* Set Instance to 0              */
   &auTskStack_SimpleExample[0],            /* Pointer to Stack               */
   TSK_STACK_SIZE_SIMPLEEXAMPLE,            /* Size of Task Stack             */
   0,                                       /* Threshold to maximum possible value */
   RX_TASK_AUTO_START,                      /* Start task automatically       */
   (void(FAR*)(void FAR*))SimpleTaskEnter,  /* Task function to schedule      */
   (void(FAR*)(void FAR*))SimpleTaskLeave,  /* Function called when Task will be deleted */
   NULL,                                    /* Startup Parameter              */
   {0,0,0,0,0,0,0,0}                        /* Reserved Region                */
  }
};

this is the configuration of the GPIO 4:

STATIC CONST FAR RX_GPIO_SET_T atrXGpio[] =
  {
  {{"GPIOOUT",RX_PERIPHERAL_TYPE_GPIO,0},
   4,                                        /* GPIO Number */
   RX_GPIO_TYPE_OUTPUT,                       /* GPIO Type */
   RX_GPIO_POLARITY_NORMAL,                   /* GPIO Polarity */
   RX_GPIO_OUTPUTMODE_STANDARD_0,             /* GPIO Mode */
   RX_GPIO_COUNTER_NONE,                      /* Counter Reference, needed when edges or levels shall be counted */
   FALSE,                                     /* Enables/Disables IRQ in the case a counter is referenced */
   0,                                         /* Threshold / Capture value in PWM mode */
  }
}

the driver configuration:

STATIC CONST FAR RX_DRIVER_PERIPHERAL_CONFIG_T atrXDrvCfgPost[] = { 
  {DrvGpioInit,  RX_PERIPHERAL_TYPE_GPIO,     atrXGpio,  MAX_CNT(atrXGpio)}
};

i left the MMIO config unchanged, snippet of GPIO's:

 {16, MMIO_CONFIG_PIO4,                0, 0},
  {17, MMIO_CONFIG_PIO5,                0, 0},
  {18, MMIO_CONFIG_PIO6,                0, 0},
  {19, MMIO_CONFIG_PIO7,                0, 0},

in the task, i try to "blink" with the following lines:

 long erXRes=0;
 RX_HANDLE hGpio; /* GPIO Handle */

erXRes = rX_MemAllocateMemory(&hGpio,DRV_GPIO_SIZE); /* Get memory */
erXRes = Drv_GpioIdentifyGpio("GPIOOUT",0,&hGpio);
erXRes = Drv_GpioInitializeGpio(hGpio);

rX_SysSetTaskInitialized(0); /* Signals the end of the Task initialization */

while(1)
{
erXRes = Drv_GpioSetOutput(hGpio);
rX_SysSleepTask(1000);

erXRes = Drv_GpioClearOutput(hGpio);
rX_SysSleepTask(1000);
}

the tasks runs, the "erXRes" says always =0x00 while debugging, so i think that there is no error. but the LED is still dark.

thank you for your information and/or hints.

greetings, harry

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 18.12.2008 | 10:37

Hi ihd,

when you use the GPIO driver and the according functions, you should also change the MMIO configuration part to GPIO.

Quote:
{17, MMIO_CONFIG_PIO5,                0, 0},
  {18, MMIO_CONFIG_PIO6,                0, 0},
  {19, MMIO_CONFIG_PIO7,                0, 0},

{17, MMIO_CONFIG_GPIO5,                0, 0},
  {18, MMIO_CONFIG_GPIO6,                0, 0},
  {19, MMIO_CONFIG_GPIO7,                0, 0},

ihd

ihd

| 18.12.2008 | 10:54

wow, thank you for the fast response -> it worked fine!

i didn't dare to change the MMIO_config because it says at severals points that a change is not recommended and could result in a damaging of the netStick.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 18.12.2008 | 10:57

Hello,

good news.

You are absolutely right. By using of a wrong configuration you can damage the processor. It is better to ask at first.

Login