AnsweredAssumed Answered

STM32F103RB receiving data from USART

Question asked by acampora.antonio on May 6, 2012
Latest reply on May 8, 2012 by acampora.antonio
Hi i stay try to send a character from Hyperterminal on the usart without any control on flow of usart(HW control or Xon/Xoff control)

this is my code

#define RCC_APB2ENR          *(long*)     0x40021018
#define GPIOA_ODR          *(long*)     0x4001080C
#define GPIOB_ODR          *(long*)     0x40010C0C
#define GPIOA_CRH          *(long*)     0x40010804
#define GPIOB_CRH          *(long*)     0x40010C04

// Define for USART_RS232

#define USART1_SR     *(long*)     0x40013800
#define USART1_BRR     *(long*)     0x40013808
#define     USART1_DR     *(long*)     0x40013804
#define     USART1_CR1     *(long*)     0x4001380C
#define     USART1_CR2     *(long*)     0x40013810
#define     USART1_CR3     *(long*)     0x40013814
#define USART1_GTPR     *(long*)     0x40013818

int main (void)
     RCC_APB2ENR=0x400C;          //Set USART1 GPIOB GPIOA
     GPIOA_CRH=0x4B0;               //PA9 Altenate OUTPUT   PA10 Floating INPUT
     GPIOB_CRH=0x22222222;          //Out led at 2 MHz
     USART1_BRR=0x0340;               //Baud Rate a 9600
     USART1_CR1=0x0000200C;          // UE, TE, RE
     USART1_CR2=0x00000801;          // Clock Enabled e indirizzo 0001

          while((USART1_SR&&0x00000020)==0x00000020)      //Control RNXE flag
          {USART1_DR=0x43;                    //character control
               {GPIOB_ODR=0x005500;          //If receive A ODR on portB is 5500
          if(USART1_DR==0x42)                     //If receive B ODR  on portB is AA00

...i not Know how read correctly from USART_DR or i not set properly for take data from the shift register