fix l4 to run at 48Mhz and with a clock

This commit is contained in:
Karl Palsson 2016-03-14 21:34:18 +00:00
parent 39467f34cb
commit 9b371b5189
3 changed files with 14 additions and 2 deletions

View file

@ -4,9 +4,10 @@ source [find target/stm32l4x.cfg]
# serial of my f072 disco board.
hla_serial "066DFF495351885087171826"
#tpiu config internal swodump.stm32l4-disco.log uart off 168000000
tpiu config internal swodump.stm32l4-disco.log uart off 48000000
# Uncomment to reset on connect, for grabbing under WFI et al
#reset_config srst_only srst_nogate
reset_config srst_only srst_nogate connect_assert_srst
#reset_config srst_only srst_nogate connect_assert_srst
reset_config none

View file

@ -66,6 +66,7 @@ void adc_power_init(void)
/* same same but different */
rcc_periph_clock_enable(RCC_ADC1);
ADC_CR(ADC1) &= ~ADC_CR_DEEPPWD;
RCC_CCIPR |= 3 << 28; // system clock as adc clock. (with CKMODE == 0)
adc_enable_regulator(ADC1);
#else

View file

@ -7,7 +7,9 @@
#include <stdio.h>
#include <unistd.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/flash.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/pwr.h>
#include <libopencm3/stm32/rcc.h>
#include "trace.h"
@ -18,6 +20,12 @@
#define LED_DISCO_GREEN_PORT GPIOE
#define LED_DISCO_GREEN_PIN GPIO8
int hack(void) {
pwr_set_vos_scale(PWR_SCALE1);
flash_set_ws(FLASH_ACR_LATENCY_2WS);
rcc_set_msi_range(RCC_CR_MSIRANGE_48MHZ);
return 0;
}
int main(void)
{
@ -27,6 +35,8 @@ int main(void)
rcc_periph_clock_enable(RCC_GPIOE); // led
rcc_periph_clock_enable(RCC_GPIOA); // adcs
rcc_periph_clock_enable(RCC_GPIOC); // adcs
rcc_periph_clock_enable(RCC_PWR);
hack();
printf("hi guys!\n");
/* green led for ticking */
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,