The code looks sound. For how long is the input data valid after the rising edge of nTime ? The attached pin interrupts have fairly long latency.
Since you are using a blocking loop waiting for the notTime flag from the ISR, you might as well wait for the nTime pin to go high and cut out the ...
Search found 94 matches
- Mon Nov 23, 2020 9:18 pm
- Forum: General discussion
- Topic: Bluepill need help with interrupt
- Replies: 7
- Views: 8886
- Mon Nov 23, 2020 4:14 pm
- Forum: Projects
- Topic: FFT Quadrature detector
- Replies: 4
- Views: 6557
Re: FFT Quadrature detector
How many samples do you propose to process at a time, and what sample frequency do you want ?
Seriously, using example code and adapting it to your own project is a good way to learn coding and to get a project up and running, but unless you plan to follow the instructables to the letter, you must ...
Seriously, using example code and adapting it to your own project is a good way to learn coding and to get a project up and running, but unless you plan to follow the instructables to the letter, you must ...
- Sat Nov 21, 2020 5:11 pm
- Forum: Projects
- Topic: DMA problem solved
- Replies: 26
- Views: 22941
Re: DMA problem solved
Still overcomplicated, no val arrays or sin and cosines are needed
for (i = 0; i < SAMPLES; i++)
{
if ( i < SAMPLES/2)
{
digitalWrite(PB8, HIGH);
}
else
{
digitalWrite(PB8, LOW);
}
int j = i+PHASE;
/* adjust j by a SAMPLES period to be between 0 and SAMPLES-1 */
if (j>=SAMPLES) j ...
for (i = 0; i < SAMPLES; i++)
{
if ( i < SAMPLES/2)
{
digitalWrite(PB8, HIGH);
}
else
{
digitalWrite(PB8, LOW);
}
int j = i+PHASE;
/* adjust j by a SAMPLES period to be between 0 and SAMPLES-1 */
if (j>=SAMPLES) j ...
- Sat Nov 21, 2020 4:17 pm
- Forum: Projects
- Topic: DMA problem solved
- Replies: 26
- Views: 22941
Re: DMA problem
Probably because you generate them one after the other, try to write to both pins inside the same loop
for (i = 0; i < SAMPLES; i++)
{
//if ( val1[i] > 40)
if ( val1[i] < 38)
{
digitalWrite(PB8, HIGH);
}
else
{
digitalWrite(PB8, LOW);
}
//if ( val1[i] > 40)
if ( val1[i] > 38 ...
for (i = 0; i < SAMPLES; i++)
{
//if ( val1[i] > 40)
if ( val1[i] < 38)
{
digitalWrite(PB8, HIGH);
}
else
{
digitalWrite(PB8, LOW);
}
//if ( val1[i] > 40)
if ( val1[i] > 38 ...
- Sat Nov 21, 2020 11:42 am
- Forum: Projects
- Topic: DMA problem solved
- Replies: 26
- Views: 22941
Re: DMA problem
The signal output on the PWM pin is a square wave. The digital pins can only output 0 or 1, that is 0V or 3.3V for the STM32 processors. This signal becomes an analog signal only after low pass filtering.
- Fri Nov 20, 2020 3:00 pm
- Forum: Projects
- Topic: DMA problem solved
- Replies: 26
- Views: 22941
Re: DMA problem
You have declared both dma_cfg and dma_cfg2. In dma_conf() you only use dma_cfg, and sets the values for both channels to the same config structure overwriting the first value, then you call
ret = dma_tube_cfg(DMA1, DMA_CH4, &dma_cfg);
ret = dma_tube_cfg(DMA1, DMA_CH3, &dma_cfg);
with the same ...
ret = dma_tube_cfg(DMA1, DMA_CH4, &dma_cfg);
ret = dma_tube_cfg(DMA1, DMA_CH3, &dma_cfg);
with the same ...
- Fri Nov 20, 2020 1:15 pm
- Forum: Projects
- Topic: DMA problem solved
- Replies: 26
- Views: 22941
Re: DMA problem
It was more a hint than a question really, your code has
I think that should be
Code: Select all
timer_dev *dev1 = PIN_MAP[out2].timer_device;
timer_dev *dev2 = PIN_MAP[out2].timer_device;
Code: Select all
timer_dev *dev1 = PIN_MAP[out1].timer_device;
timer_dev *dev2 = PIN_MAP[out2].timer_device;
- Fri Nov 20, 2020 7:38 am
- Forum: Projects
- Topic: DMA problem solved
- Replies: 26
- Views: 22941
Re: DMA problem
In your code, what pins are timer_dev *dev1 and dev2 connected to ?
- Wed Nov 18, 2020 5:47 pm
- Forum: General discussion
- Topic: Code doesn't seem to run Nucleo-F401RE
- Replies: 11
- Views: 27658
Re: Code doesn't seem to run Nucleo-F401RE
Since the external 8MHz signal from the STLink has been replaced by an 8MHz crystal, the internal oscillator must be active and not bypassed. Therefore I think you must replace the line:
with
Code: Select all
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
Code: Select all
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
- Wed Nov 18, 2020 4:04 pm
- Forum: General discussion
- Topic: Code doesn't seem to run Nucleo-F401RE
- Replies: 11
- Views: 27658
Re: Code doesn't seem to run Nucleo-F401RE
The photo looks like an X3 crystal has been added, in that case the clock configuration must be changed in SystemClock_Config(void) defined in variant.cpp