STM32G441 SPI1 transmit with DMA1 and DMAMUX cannot get it to transmit
I am trying to send some bytes over an SPI via DMA on bare metal STM32G441. But there is nothing being sent and I cant find why. I only used DMA on ST32F devices that do not have the DMAMUX. Please note that SCK and MISO are not used here. I looked at a generated code from CubeIDE which does not seem to do anything else. I expected the SPI to send 1000 bytes.
Here is my code. The comment shows what is happening in each line as I am not using CMSIS. The bit definitions are corresponding to the bits: bit5 = (1<<5) for example.
volatile uint8_t buf[1000] = {0b11001000};
// initialize
RCC->AHB1ENR |= bit0|bit2; // enable DMA1 and DMAMUX clocks
RCC->AHB2ENR |= bit0; // enable GPIOA clock
RCC->APB2ENR |= bit12; // enable SPI1 clock
GPIOA->MODER &= ~(0b11<<14);
GPIOA->MODER |= (0b10<<14); // PA7 alternate function
GPIOA->AFRL |= (5<<28); // PA7 SPI1 MOSI
GPIOA->OSPEEDR |= (0b11<<14); // MOSI speed high
DMA1_Channel1->CCR = 0; // disable DMA
DMA1_Channel1->CPAR = (uint32_t)&SPI1->DR; // peripheral SPI1
DMA1_Channel1->CMAR = (uint32_t)&buf; // memory array
DMA1_Channel1->CCR |= (bit4|bit7|(0b11<<12)); // memory to peripheral, memory increment, very high priority
DMAMUX1_Channel0->CCR = 11; // DMAMUX SPI1TX
SPI1->CR1 |= (bit2|(0b100<<3)|bit8|bit9|bit14); // SPI1 master, f/32, SSI, SSM, bidirectional mode
SPI1->CR2 |= bit1; // SPITX DMA enable
// send bytes
SPI1->CR1 &= ~bit6; // SPI1 disable
DMA1_Channel1->CCR &= ~bit0; // disable DMA
DMA1_Channel1->CNDTR = 1000; // reload amount
DMA1_Channel1->CCR |= bit0; // DMA1 enable
SPI1->CR1 |= bit6; // SPI1 enable
How can I trigger the DMA? The SPI on its own works fine. Am thankfull for any tip.
