cancel
Showing results for 
Search instead for 
Did you mean: 

Two bugs found in 91x_gpio.c and uip_webserver project (IAR EWARM demo)

mark9
Associate II
Posted on March 06, 2007 at 21:24

Two bugs found in 91x_gpio.c and uip_webserver project (IAR EWARM demo)

4 REPLIES 4
mark9
Associate II
Posted on May 17, 2011 at 09:39

I found two bugs in the uip_webserver project (IAR EWARM demo) that accidentally cancel each other out. This was causing me many hours of grief.

The first bug is that the SCU_GPIOINPUT registers for the MII should be set to 0 (default), but the example code sets them to 1 (GPIO_InputAlt1). see STR912_enet.c, GPIO_InitStructure() et al.

The second bug is that there is a bug in 91x_gpio.c that affects GPIO8 and GPIO9. When the example code configures the LCD driver, it accidentally clobbers the SCU_GPIOINPUT register for *GPIO0*, setting to zero, because 8 wraps around to 0 if you have only 3 bits.

If you have both bugs in your code, the Ethernet RX accidentally works; otherwise it doesn't work. My ethernet code stopped working when I disabled the LCD!

cf The other discussion topic: ''A bug in 91x_gpio.c''

amira1
Associate II
Posted on May 17, 2011 at 09:39

Hi lakata,

Concerning GPIO(the second bug)you are right, there is a bug in gpio.c as you mentioned and it will be corrected in the next library release.

And about the second one, you are talking about P1 and P5 configuration?They are working as output alternate function so as I see the SCU_GPIOINPUT register keep its default value 0.

:-W

Regards

mirou

mark9
Associate II
Posted on May 17, 2011 at 09:39

P0 and P1 are incorrectly set to Alternate input function instead of the default input. The MII is the default pin function, so SCU_GPIOIN should be zero for both P0 and P1. I believe that P1 is not that important to getting the demo to work (it is for collision detection, carrier sense, and receive error); it works whether the SCU_GPIOIN1 is either 0x00 or 0xFF. But SCU_GPIOIN0 must be zero.

When I stepped through the example, I saw SCCU_GPIOIN0 first be set to 0xFF, then set to 0x00 when the LCD was initialized.

mark9
Associate II
Posted on May 17, 2011 at 09:39

I forgot to mention, the STR912 library is confusing. The Alt1 input function is not set via the GPIO_Alternate field for the structure, but set by the GPIO_IPConnected field.

This fixes the demo code:

// GPIO0 All pins Default Input function

GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

GPIO_InitStructure.GPIO_IPConnected = 0; // was GPIO_IPConnected_Enable;

GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_Init(GPIO0, &GPIO_InitStructure);

and same for GPIO1.