cancel
Showing results for 
Search instead for 
Did you mean: 

Apply low pulse TTL on a gpio i order to reset an ETH chip

yassin
Associate II
Posted on January 13, 2015 at 10:48

I have two sample based on STM32f107 and TLK105,

the TLK software reset does not work properly therefore I connected the TLK RESET pin with GPIOC PIN6 (PC6) in order to force a hardware reset,

The code portion I have made work on one sample and not the second, can any one notice an error ?

void

phy_hardware_reset()

{

    GPIO_InitTypeDef GPIO_InitStructure ;

    uint8_t count;

    count = 0;

    /*

     * Apply low voltage on PC6 connected to reset pin of the chip :

     * TLK105/106 Industrial Temp, Single Port 10/100Mbs Ethernet

     * Physical Layer Transceiver/page 32

     */

    GPIO_ResetBits(GPIOC,GPIO_Pin_6);

    //Initialize GPIO PIN and set it as alternate function PP

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

    GPIO_Init(GPIOC, &GPIO_InitStructure);

    //Blocking the process, for more then 1MicroSecond

    while(count++<250);

    

    //Set the PC6

    GPIO_SetBits(GPIOC,GPIO_Pin_6);

}

The TLK datasheet says that:

Asserting this pin low for at least 1?s will force a reset process to occur.

I invested a lot of time at this bug and I do not know where I should debug any more.

#!bug #stm32_eth #tlk105 #stm32f107
7 REPLIES 7
AvaTar
Lead
Posted on January 13, 2015 at 12:32

    //Blocking the process, for more then 1MicroSecond

 

    while(count++<250);

 

Are you sure this is 1 microseconds ?

Beside from the fact that such busy-loops are generally bad ideas, your compiler might have optimized it out at all.

But more important: have you considered to use a scope to check the reset pulse in both duration and level ?

Posted on January 13, 2015 at 12:45

>    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

Why?

And why amidst the pulse?

JW

yassin
Associate II
Posted on January 13, 2015 at 14:31

Yeah, I am sure 250 is more than 1 microsec. Too bad have no scope, but I am thinking of borrowing one, might save me alot of time.

And why amidst the pulse? I dont get it ?

AvaTar
Lead
Posted on January 13, 2015 at 16:29

And why amidst the pulse? I dont get it ?

 

Normal practice is to initialise such IOs as early as possible, and set to a defined level.

But you are initialising the GPIO after you had set it to low. I assum there is other, undisclosed code, but that can't work.

Yeah, I am sure 250 is more than 1 microsec.

 

You are just guessing, or else it would work.

Such simple busy-loops are inaccurate and error-prone even with slight optimisations.

You should at least declare your counter variable as 'volatile'.

Too bad have no scope, but I am thinking of borrowing one, might save me alot of time.

 

Exactly. A logic analyser might do in your case, but a scope is better.

And compare the results with the reset pulse specification of the TLK 10x chip.

yassin
Associate II
Posted on January 16, 2015 at 14:12

So I discovered something ... my PA2 pin is connected to the MDIO pin which as documented in the datasheet needs a Pullup resistor of 2.2 Kohm, but i forgot this in my PCB design and it is hard now to solder it ... Do you know any work around ? I think GPIOA pins has internet pull up resistor that can be activated, ?

Any Help ?

Posted on January 16, 2015 at 17:09

And why amidst the pulse? I don't get it ?

 

 

Normal practice is to initialize such IOs as early as possible, and set to a defined level.

 

But you are initializing the GPIO after you had set it to low. I assume there is other, undisclosed code, but that can't work.

And more specifically as an AF (Alternate Function - Peripheral Controlled) one rather than a GPIO (User Controlled). Don't dicker around with the pin while you're trying to generate the pulse, and confirm with suitable measurement equipment the duty of the pulse being generated. Then you'd know what's going on rather than guessing why it's broken. The compiler could optimize the loop out completely.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yassin
Associate II
Posted on January 19, 2015 at 10:45

Yeah checked and the pulse is generated correctly.

Discovered a contradiction between stm32 datasheet and the Ethernet TLK105 datasheet.

There is a pin in the TLK named MDIO described as IO pin and mentioned that it should have a pull up resistor with a value of 2.2KOhm ... on the other side the STM32 reference manual says the PA2 should be connected to the MDIO pin of the Ethernet chip and should be configured as Output Alternate function which means no need for pull up resistor theoretically.

Plus I missed to add this PU resistor in the design, and now before making any changes I want to be sure that this might be the reason why I am having random strange behavior.

Any clue ?