Vbat stops device running - STM32F207

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Vbat stops device running - STM32F207

Post by Tabulous »

I have a coin cell connected to Vbat, this for keeping RTC running and also backing up the BKPSRAM.

When running via debug on chibistudio all works ok.

If i stop the debug session and run the board in standalone mode, i.e remove debugger and cycle the power, the board does not run.......

Now if i remove the coin cell so Vbat is not powered, the board runs......

Why would Vbat be stopping the MCU running ?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Vbat stops device running - STM32F207

Post by Giovanni »

Does enabling/disabling the RTC driver make any difference?

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: Vbat stops device running - STM32F207

Post by Tabulous »

Giovanni wrote:Does enabling/disabling the RTC driver make any difference?

Giovanni


Disabling the driver makes no difference.

But if pull the nRST to ground and then release it, the MCU starts to run. So i dont believe it is anything to do with the RTC driver.
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: Vbat stops device running - STM32F207

Post by Tabulous »

some more feedback on this issue......

I now believe this is a Chibios issue.

To prove this i've written a small program and all it does is toggle a LED, there is no Chibios used in this program.

The MCU starts up fine even when VBat is connected, so based on this i can only assume that there is something in chibios.

So i went back to chibistudio and to the original program, if i remove the mac / ethernet, everything works voila...

So for some reason, the mac init is getting stuck in a while loop......
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Vbat stops device running - STM32F207

Post by Giovanni »

That while loop waits for an HW event that does not happen. Hardly a driver issue IMO, I could skip that loop but then the MAC driver would not work.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: Vbat stops device running - STM32F207

Post by Tabulous »

the issue is in this function

Code: Select all

uint32_t mii_read(MACDriver *macp, uint32_t reg) {

  ETH->MACMIIAR = macp->phyaddr | (reg << 6) | MACMIIDR_CR | ETH_MACMIIAR_MB;
  while ((ETH->MACMIIAR & ETH_MACMIIAR_MB) != 0)
    ;
  return ETH->MACMIIDR;
}


This is called by mii_find_phy, it gets stuck in the while loop
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Vbat stops device running - STM32F207

Post by Giovanni »

Apparently the MAC is unable to read the PHY register.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: Vbat stops device running - STM32F207

Post by Tabulous »

Giovanni wrote:Apparently the MAC is unable to read the PHY register.

Giovanni



Because the this works when micro is under control of the debugger, i.e. power is on all psu line are stable

Do you think the MCU is trying to access the phy chip before it is ready from a cold start ?

One other thing to say is, i do have the physical reset line of the phy connected to a GPIO, did this so i could have a hard reset of the phy.

But maybe when the GPIO is configured by the pal driver, the time from the rst line been set high to the mac driver trying to access is not long enough
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Vbat stops device running - STM32F207

Post by Giovanni »

The MCU does that after it is out of the reset, you may try adding delays before halInit() and see if this makes a difference (note, you cannot use kernel functions there).

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: Vbat stops device running - STM32F207

Post by Tabulous »

Giovanni wrote:The MCU does that after it is out of the reset, you may try adding delays before halInit() and see if this makes a difference (note, you cannot use kernel functions there).

Giovanni


Adding a delay at the start of C main before halInit is called works, everything starts up ok, but its a nasty hack lol
Post Reply