AnsweredAssumed Answered

STM32F4 USART PROBLEM

Question asked by CodeFarmer on Aug 9, 2013
Latest reply on Aug 12, 2013 by CodeFarmer
Hello, everyone.

 I am currently playing around with the USART without standard peripheral lib provided by ST (using CMSIS only) and my code strangely works in one MDK project and does not work in another MDK project (Same code!) 

So if you are interested, please have a look at these:

int main(void)
{
    USART2->BRR=0x330;
    
    RCC->AHB1ENR|=RCC_AHB1ENR_GPIOAEN;
    RCC->APB1ENR|=RCC_APB1ENR_USART2EN;
 
    GPIOA->MODER|=(
                                GPIO_MODER_MODER2_1|
                                GPIO_MODER_MODER4_1);
        GPIOA->PUPDR|=(
                                GPIO_PUPDR_PUPDR2_0|
                                GPIO_PUPDR_PUPDR4_0);
    GPIOA->AFR[0]|=0x00077777;

    
    USART2->CR1|=USART_CR1_TE;
    USART2->CR1|=USART_CR1_UE;
    USART2->SR&=~(USART_SR_TC);
    USART2->DR=0x0000;
    
}


Any comment or idea will be appreciated!



Outcomes