1
\$\begingroup\$

I've flashed the following code to my shiny new STM32F0DISCOVERY board. The comments explain what I thought it would do.

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
    // Place PIN 4 (DAC out) into analog mode
GPIOA->MODER=0b11<<8;

RCC_AHBPeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
// Default DAC settings are fine.
DAC->CR = 0;
DAC->CR = 1;

Unfortunately after flashing this code openocd can no longer talk to the board or recognize that it is an stm32f0 (but it can still connect to the onboard ST/LINK if the reset button is held down). I thought I might be able to hold BOOT0 high and boot from the internal serial bootloader, but that doesn't seem to allow SWD flashing either. The rest of the short program just uses GPIO B and C and the timer.

Should I expect that code to brick the chip or did I just get unlucky?

\$\endgroup\$
2
  • \$\begingroup\$ From a few minutes looking at the datasheet schematic, it looks like PA4 (DAC_OUT) might be shared with JTAG? Alternative hypothesis: that pin is shorted to ground, and the DAC starts up shorted out preventing a clean normal boot. \$\endgroup\$
    – pjc50
    Oct 11, 2013 at 13:33
  • \$\begingroup\$ Note the RCC_AHBPeriphClockCmd() used incorrectly to try to enable an APB1 peripheral. \$\endgroup\$
    – joeforker
    Oct 28, 2013 at 20:25

2 Answers 2

3
\$\begingroup\$

For whatever reason openocd was no longer able to talk to the device after flashing the code. Thankfully the official Windows ST/LINK tool was able to erase the chip with the "connect under reset" option.

\$\endgroup\$
1
  • \$\begingroup\$ Since this time, I've also had success holding the reset button while programming the part or until just after starting openocd, but usually if the chip is not too confused none of that is necessary. \$\endgroup\$
    – joeforker
    Jun 11, 2015 at 20:13
1
\$\begingroup\$

Just for other readers who don't have a STM32F*DISCOVERY board: All STM32 have bootloaders which can be used to program the chip as well. You will have to set the BOOT pin(s) accordingly to boot from "System Memory" and connect the appropriate serial peripheral (See: "AN2606 STM32 microcontroller system memory boot mode" http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf). The bootloader will work even when the JTAG or SWD pins are overwritten in software or the clock has ben misconfigured preventing normal boot up. One such tool for flashing that runs on linux would be http://code.google.com/p/stm32flash.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.