Commit e48fba3a authored by Zach Fredin's avatar Zach Fredin

added ringtest

parent d21990f3
......@@ -2,8 +2,8 @@
This is the smallest-possible example program using libopencm3.
It's intended for the ST Nucleo-F411RE eval board. It should blink
the GREEN LED on the board.
It's intended for the ST Nucleo-F412ZG eval board. It should blink
the BLUE LED on the board.
## Board connections
......
##
## This file is part of the libopencm3 project.
##
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
##
## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this library. If not, see <http://www.gnu.org/licenses/>.
##
BINARY = ringtest
LDSCRIPT = ../../stm32f412xExG.ld
include ../Makefile.include
# Ring Test
This ring test uses PD5 and PD6. It's best to solder a loop of bare wire between the two pads, as they're next to each other on the Nucleo board and a loop allows easy hookup of an oscilloscope probe. I set the system clock to high-speed internal (HSI) running at 84 MHz, and used libopencm3's `gpio_get`, `gpio_set`, `and gpio_clear` to run the test:
![ringtest](ringtest.png)
1.97 MHz is good; I believe this could improve to 2.35 MHz if the HSI ran at the full rated STM32F412 speed of 100 MHz. libopencm3 doesn't have a built-in configuration function for this clock speed so this will take more investigation.
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
* Copyright (c) 2015 Chuck McManis <cmcmanis@mcmanis.com>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/* RING TEST
This ring test uses PD5 as an output and PD6 as an input. Don't forget to bridge them together.
*/
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
static void clock_setup(void){
//no built-in libopencm3 support for a 100 MHz clock
rcc_clock_setup_pll(&rcc_hsi_configs[RCC_CLOCK_3V3_84MHZ]);
}
static void gpio_setup(void)
{
rcc_periph_clock_enable(RCC_GPIOD);
gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO5);
gpio_mode_setup(GPIOD, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO6);
}
int main(void)
{
clock_setup();
gpio_setup();
while (1) {
//using these functions yields a 1.97 MHz ring test:
if (gpio_get(GPIOD, GPIO6)) {
gpio_clear(GPIOD, GPIO5);
}
else {
gpio_set(GPIOD, GPIO5);
}
}
return 0;
}
ringtest.o: ringtest.c ../../libopencm3//include/libopencm3/stm32/rcc.h \
../../libopencm3//include/libopencm3/cm3/common.h \
/usr/lib/gcc/arm-none-eabi/7.3.1/include/stdint.h \
/usr/arm-none-eabi/include/stdint.h \
/usr/arm-none-eabi/include/machine/_default_types.h \
/usr/arm-none-eabi/include/sys/features.h \
/usr/arm-none-eabi/include/_newlib_version.h \
/usr/arm-none-eabi/include/sys/_intsup.h \
/usr/arm-none-eabi/include/sys/_stdint.h \
/usr/lib/gcc/arm-none-eabi/7.3.1/include/stdbool.h \
../../libopencm3//include/libopencm3/stm32/memorymap.h \
../../libopencm3//include/libopencm3/stm32/f4/memorymap.h \
../../libopencm3//include/libopencm3/cm3/memorymap.h \
../../libopencm3//include/libopencm3/stm32/f4/rcc.h \
../../libopencm3//include/libopencm3/stm32/pwr.h \
../../libopencm3//include/libopencm3/stm32/f4/pwr.h \
../../libopencm3//include/libopencm3/stm32/common/pwr_common_v1.h \
../../libopencm3//include/libopencm3/stm32/common/rcc_common_all.h \
../../libopencm3//include/libopencm3/stm32/gpio.h \
../../libopencm3//include/libopencm3/stm32/f4/gpio.h \
../../libopencm3//include/libopencm3/stm32/common/gpio_common_f24.h \
../../libopencm3//include/libopencm3/stm32/common/gpio_common_f234.h \
../../libopencm3//include/libopencm3/stm32/common/gpio_common_all.h
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment