[libmaple] Black F407VET6

Limited support for STM32F4 Discovery, Nucleo and custom F4 boards
stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: [libmaple] Black F407VET6

Post by stevestrong » Wed Feb 14, 2018 5:00 pm

Can you do a PR?

PA15 is reserved for SPI3 NSS.
Timer 2 ch 1 is not mapped to PA5 to allow to be used as SPI1 SCK.
In the same context, PB10 and PB11 are reserved for (SPI2_SCK or I2C2_SCL or UASRT3_TX) and (I2C2_SDA or USART3_RX), respectively.

So Timer 2 was given lower prio versus I2C2/USART3, because there are plenty of other timers available on other pins.
Same applies for other pins you mentioned, in favor of SPI, I2C and USART.
Take a look into generic_f407v.h for reserved pins and what are they reserved for.

To activate TIMER2_CH1 on PA15, PA15 must be mapped to the respective alternate function AF1, which is not done in the current version of the repo.
You can use the function gpio_set_af_mode() using my repo.

Code: Select all

gpio_set_af_mode(PA15, GPIO_AFMODE_TIM1_2);

Wolfie
Posts: 14
Joined: Wed Jan 24, 2018 8:57 am

Re: [libmaple] Black F407VET6

Post by Wolfie » Thu Feb 15, 2018 8:39 am

Thanks for the explanation Steve.

I wasn't expecting you to change anything, I just wanted to explain what to do in order to get all 32 PWM channels working for anyone that wanted to know, because I have a project that plans to use them all.

As an aside, my W5500 modules arrived yesterday and, late last night, I got a 407VE connected to the LAN, so thanks again for your work.

acronis
Posts: 161
Joined: Thu Mar 02, 2017 12:32 pm

Re: [libmaple] Black F407VET6

Post by acronis » Sun Feb 18, 2018 12:27 pm

Steve

Please tell me how to do calibration of ADC ?

Code: Select all

  int channel = PIN_MAP[analogInPin].adc_channel;
  adc_set_sample_rate(&ADC1, ADC_SMPR_1_5); 
  adc_set_reg_seqlen(&ADC1, 1);
  (&ADC1)->regs->SQR3 = channel;
  (&ADC1)->regs->CR1 |= 0x70000; 
  (&ADC1)->regs->CR2 |= ADC_CR2_CONT | ADC_CR2_SWSTART;

stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: [libmaple] Black F407VET6

Post by stevestrong » Sun Feb 18, 2018 12:43 pm

You must not and cannot calibrate the ADC of F4.

acronis
Posts: 161
Joined: Thu Mar 02, 2017 12:32 pm

Re: [libmaple] Black F407VET6

Post by acronis » Sun Feb 18, 2018 12:52 pm

OK. thanks.

stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: [libmaple] Black F407VET6

Post by stevestrong » Sun Feb 18, 2018 9:08 pm

I needed a simple wave generator so I thought why not use the DAC of my F4 board.

The result is a sketch which generates either a sine wave (using a lookup table) or a triangle wave (using the internal wave generator of the F4 chip).
Configurable with some defines in the beginning of the sketch.

As usual, my repo gives the necessary utility functions.
Attachments
STM32F4_DAC.ino
(4.17 KiB) Downloaded 7 times

User avatar
Pito
Posts: 1739
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [libmaple] Black F407VET6

Post by Pito » Mon Feb 19, 2018 12:28 am

Any example for a simultaneous regular ADC sampling (2 ADCs sample a channel at the same exact time, no channel's scan - scan disabled)?
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: [libmaple] Black F407VET6

Post by stevestrong » Mon Feb 19, 2018 7:54 am

Yes, ADC is the next on the agenda, now that i have a reference signal from the DAC to sample ;)

stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: [libmaple] Black F407VET6

Post by stevestrong » Tue Feb 20, 2018 7:54 pm

This is another wave form generation example using DMA now.
This example allows to configure the output frequency (and amplitude in case internal triangle wave generator).
The example sine wave has 210 samples and 8 bit resolution, with 3.3Vpp.
The generated 20 kHz frequency is quite precise and the signal has a nice shape ;)

Now the next step is ADC.
Attachments
STM32F4_DAC_DMA.ino
(5.49 KiB) Downloaded 5 times

vitor_boss
Posts: 65
Joined: Wed Apr 19, 2017 9:50 am

Re: [libmaple] Black F407VET6

Post by vitor_boss » Fri Feb 23, 2018 1:01 am

stevestrong wrote:
Tue Feb 20, 2018 7:54 pm
This is another wave form generation example using DMA now.
This example allows to configure the output frequency (and amplitude in case internal triangle wave generator).
The example sine wave has 210 samples and 8 bit resolution, with 3.3Vpp.
The generated 20 kHz frequency is quite precise and the signal has a nice shape ;)

Now the next step is ADC.
Very nice code, I'm not a skilled programmer like you guys but I have an idea to reduce #ifdefs

Code: Select all

#elif GEN_WAVE==TRIANGLE
  #if   WAVE_AMP==3
	const int WAVE_RES   = 8192;
  #elif WAVE_AMP==2
	const int WAVE_RES   = 4096;
  #elif WAVE_AMP==1
	const int WAVE_RES   = 2048;
  #endif
#endif
to

Code: Select all

#elif GEN_WAVE==TRIANGLE
  const int WAVE_RES = 1024 << WAVE_AMP;
#endif

Post Reply