cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
3,921 Views
Registered: ‎10-27-2013

LED blink wrong read value

Hi

I am using ML605 Board

ISE,EDK version 14.5

My OS is windows 7.

I have created a small mirocblaze project with LEDs attached. My primary aim was to toggle the 8 LEDs of ML605.

 

I used a sample code available in the Xilinx SDK directory. The code was as follows

 

#include "xparameters.h"
#include "xgpio_l.h"

/************************** Constant Definitions *****************************/

#define LED 0x01 /* Assumes bit 0 of GPIO is connected to an LED */

/*
 * The following constant maps to the Base address  of the hardware
 * instances that was created in the EDK XPS system.
 */
#define GPIO_REG_BASEADDR    0x40020000//XPAR_LEDS_POSITIONS_BASEADDR ///modified by me

/*
 * The following constant is used to wait after an LED is turned on to make
 * sure that it is visible to the human eye.  This constant might need to be
 * tuned for faster or slower processor speeds.
 */
#define LED_DELAY     1000000

/*
 * The following constant is used to determine which channel of the GPIO is
 * used for the LED if there are 2 channels supported.
 */
#define LED_CHANNEL    1

/**************************** Type Definitions *******************************/

 

while (1) {
        /*
         * Read the state of the data so that only the LED state can be
         * modified
         */
        Data = XGpio_ReadReg(GPIO_REG_BASEADDR,
             ((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
                  XGPIO_DATA_OFFSET);


        /* Set the LED to the opposite state such that it blinks */

       if (Data & LED)
      {

            XGpio_WriteReg((GPIO_REG_BASEADDR),
                ((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
                XGPIO_DATA_OFFSET, LED);

       }
       else
      {

            XGpio_WriteReg((GPIO_REG_BASEADDR),
            ((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
                XGPIO_DATA_OFFSET, Data | LED);
        }

        /* Wait a small amount of time so that the LED is visible */

        for (Delay = 0; Delay < LED_DELAY; Delay++);

}

    return 0;
}

 

-----------------------------------------------------End of code-------------------------------------

Here my major problem is I am not able to read the GPIO values. always it returns '0' .

 

  Data = XGpio_ReadReg(GPIO_REG_BASEADDR,
             ((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
                  XGPIO_DATA_OFFSET);

 

XGpio_ReadReg alwas return value 0 to Data;

 

when i try using XGpio_WriteReg I am able to toggle the individual bits. So I presume that call works. but what ever may be the status of LED whether high or low read function returns zero.

 

I have forced Base address the GPIO_REG_BASEADDR as /XPAR_LEDS_POSITIONS_BASEADDR could not be identified....

 

along with this executing

for (Delay = 0; Delay < LED_DELAY; Delay++); processor never returns from this function. I have selected the functioning clock as 66Mhz.

 

 

Please help me sort the issue.

 

Thanks and regards

Rakesh M.

 

 

 

 

0 Kudos
Reply
4 Replies
Highlighted
Xilinx Employee
Xilinx Employee
3,900 Views
Registered: ‎08-02-2007

Hi,

 

Can you try using XMD and write into the registers directly(0x40020000)?

 

 Go to XPS -> Project -> Launch EDK shell

  1. Go to the location where they have the download.bit
  2. Type xmd at the EDK shell prompt.
  3. Type the command “fpga –f download.bit” at the XMD console.
  4. Type at the XMD prompt (connect mb mdm)
  5. Type the command “mwr 0x40020000 0x10 0xdeadbeef” in the XMD console
  6. Type the command “mrd 0x40020000 0x10” in the XMD console.

 

Since this is ML605, there is already a pre-built design that you can try.

 

Refer to this link and search for ML605 Built-In Self Test Applications Design Files

 

--Hem

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Reply
Highlighted
Visitor
Visitor
3,795 Views
Registered: ‎06-10-2014

Hello,

 

i have the same Problem. Writing a Register works, but the return value of a reading operation gives allways 0

 

How can I fix it? What is the Problem here?

 

thanks

0 Kudos
Reply
Highlighted
Visitor
Visitor
3,792 Views
Registered: ‎06-10-2014

Hello!

 

I fixed the Problem! You have always to define I/O  GPIOs (not only O)  in your IP-Designer/Inserter from which you export the Hardware to SDK. Then you can read the Values from the Register!

 

 

0 Kudos
Reply
Highlighted
Observer
Observer
2,959 Views
Registered: ‎11-11-2013

Hello!

I got the same problem. And I did as you said. But here is my question.

Have  you configured the GPIO Three-State Register ? Why we needn't to set the direction (input or output ) of GPIOs before we use readl or writel to the data registers?  Why it didn't work when I use the GPIO Three-State Register

 

phys = 0x40020000; // baseaddress is 0x40020000
virt =(unsigned )ioremap(phys, 0x10000);
GPBDAT = (unsigned *)(virt + 0x0);
GPBCON = (unsigned *)(virt + 0x04);

 

 

 

 

Following is one part of my codes:

 

writel(0xFF,GPBCON);//11111111b
mdelay(10);
tmp=readl(GPBDAT);//
printk("tmp_before=%d\n",tmp);//Why the number I got is always all 1 (0xFF) ?
writel(0x00,GPBCON);//00000000b        
if(cmd==0) //
{
tmp &= (~(1<<arg));
}
else //
{
tmp |= (1<<arg); 
}

writel(tmp,GPBDAT);//
mdelay(10);
printk("tmp_GPBDAT=%d\n",tmp);

0 Kudos
Reply