2022-03-28 06:29 AM
Hello,
Can you help me to use the DMAMUX in the STM32G474 microcontroller?
How can I program the uC to make TIM2_CH1 sends a DMA request when CC. I have found this in the reference manual but I can't undesrtand which channel of the DMA is involved. Thanks for the clarification
Solved! Go to Solution.
2022-05-10 07:20 AM
@Community member
Honestly this is out from my little understanding of microcontroller but I am more than happy to try to understand.
What I did in my code is creating a buffer (to be transferred with SPI) of uint16t with the math.h header and the sin function. Maybe this is not suitable for a microcontroller...
I do not receive any error after building, but I see this message in the window in the right side after clicking debug
#include "math.h"
int main(void)
{
/* USER CODE BEGIN 1 */
double seno[n];
double coseno[n];
uint16_t DACin_Sin[n];
uint16_t DACin_Cos[n];
uint16_t i=0;
while (i<n)
{
seno[i]= sin(i*2*3.1416/n+theta*3.14/180)+1;
coseno[i]= cos(i*2*3.1416/n)+1;
DACin_Sin[i]= seno[i]*(pow (2,N))/(2*k);
DACin_Cos[i]=coseno[i]*(pow (2,N))/(2*k);
i++;
}
2022-05-10 09:38 AM
> Honestly this is out from my little understanding of microcontroller
This is more a general C/programming issue than specifically microcontroller-related.
For DMA buffers, use arrays defined as global variables, i.e. outside any function (usually at the beginning of given source .c file).
As it is defined now it will work, as main() is the higher-most function and will never exited, but it's a not good practice for various reasons I am not going to detail at the moment.
JW