AnsweredAssumed Answered

Failing to set up USART DMA TX

Question asked by klimavicius.laur.001 on May 22, 2015
Latest reply on May 25, 2015 by klimavicius.laur.001
Hello,

Can anyone help in pinpointing where and what I'm doing wrong when seting up USART DMA TX transmission. Working with STM32L152RB (STM32L discovery) and trying to setup USART1_TX over DMA1_Channel4, USART2_TX over DMA1_Channel7 and USART3_TX over DMA1_Channel2 - acording to UM it should be like that. Below is how I'm setting it up (only USART1 others are same just peripherals and DMA channels differ and in init function I already wrote data which I'm passing, what I can see when debugging):
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
    USART_Init(0x40013800, {    115200,
                                USART_WordLength_8b,
                                USART_StopBits_1,
                                USART_Parity_No,
                                (USART_Mode_Rx | USART_Mode_Tx),
                                USART_HardwareFlowControl_None});
    USART_Cmd(0x40013800, ENABLE);
    DMA_ITConfig(DMA1_Channel4, DMA_IT_TC, ENABLE);
    NVIC_Init({ NVIC_IRQChannel = DMA1_Channel4_IRQn,
                NVIC_IRQChannelPreemptionPriority = 0x0F,
                NVIC_IRQChannelSubPriority = 0x0F,
                NVIC_IRQChannelCmd = ENABLE});
    GPIO_Init(GPIOA, {  GPIO_Pin = (uint16_t)(1 << GPIO_PinSource10),
                        GPIO_Mode = GPIO_Mode_AF,
                        GPIO_Speed = GPIO_Speed_40MHz,
                        GPIO_OType = GPIO_OType_PP,
                        GPIO_PuPd = GPIO_PuPd_NOPULL});
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
    GPIO_Init(GPIOA, {  GPIO_Pin = (uint16_t)(1 << GPIO_PinSource9),
                        GPIO_Mode = GPIO_Mode_AF,
                        GPIO_Speed = GPIO_Speed_40MHz,
                        GPIO_OType = GPIO_OType_PP,
                        GPIO_PuPd = GPIO_PuPd_NOPULL});
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
<<buffer setup>>
    DMA_DeInit(DMA1_Channel4);
    DMA_Init(DMA1_Channel4, {   DMA_PeripheralBaseAddr = 0x40013804,
                                DMA_MemoryBaseAddr = 0x20001344,
                                DMA_DIR = DMA_DIR_PeripheralDST,
                                DMA_BufferSize = 12,
                                DMA_PeripheralInc = DMA_PeripheralInc_Disable,
                                DMA_MemoryInc = DMA_MemoryInc_Enable,
                                DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
                                DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
                                DMA_Mode = DMA_Mode_Normal,
                                DMA_Priority = DMA_Priority_Low,
                                DMA_M2M = DMA_M2M_Disable});
    USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);
    USART_ClearFlag(USART1, USART_FLAG_TC);
    DMA_Cmd(DMA1_Channel4, ENABLE);
all initialization passes without errors, but I am not getting anything on uart lines and DMA1_Channel4_IRQn never fires.

Outcomes