cancel
Showing results for 
Search instead for 
Did you mean: 

synchronous mode of usart

mahtabmodaber
Associate II
Posted on June 28, 2014 at 11:52

hello

I want to use synchronous mode Usart. but i dont know how to set clock pin to for example 10 MHZ.

please help me.

thanks

#stm32 #synchronous #usart
6 REPLIES 6
Posted on June 28, 2014 at 14:29

10 MHz might be a challenge. You'd get there by setting the baud rate, and enabling the synchronous clocking mode.

You'd probably need to use OVER8 mode, and run the CPU/BUS at a multiple of 80 MHz

STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\USART\Synchronous
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mahtabmodaber
Associate II
Posted on June 28, 2014 at 17:08

From: clive1

Posted: Saturday, June 28, 2014 2:29 PM

Subject: synchronous mode of usart

10 MHz might be a challenge. You'd get there by setting the baud rate, and enabling the synchronous clocking mode.

You'd probably need to use OVER8 mode, and run the CPU/BUS at a multiple of 80 MHz

STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\USART\Synchronous

Thanks for your Quick answer.

I need 10 MHZ clock, because i want to communicate with a ccd sensor that its clock works in 10 MHZ. The clock of the USART2 (PCLK1) is 36 MHZ . Is it possible that i set PCLK1 to 10MHZ ?
Posted on June 29, 2014 at 16:27

Are you sure the data format/framing are compatible? Wouldn't SPI (Slave clocked at 10 MHz) perhaps be a better choice?

Other STM32 family members have a DCMI interface for camera type applications.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mahtabmodaber
Associate II
Posted on July 06, 2014 at 08:11

''Are you sure the data format/framing are compatible? Wouldn't SPI (Slave clocked at 10 MHz) perhaps be a better choice?

Other STM32 family members have a DCMI interface for camera type applications.''

Yes I'm sure, because that data comes from the sensor is in usart protocol that have 10 bits , 8 bits data with 1 stop bit and 1 start bit. i think spi cant help me because its frame has 8 bits .

BUT i set PCLK1(Clock of APB1) to 9MHZ with prescalers but PA4 pin (USART2_CK) was not 9MHZ in oscilloscope? why?

i changed a line in system_stm32f10x.c

static void SetSysClockTo72(void)

{

  __IO uint32_t StartUpCounter = 0, HSEStatus = 0;

 

  /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/    

  /* Enable HSE */    

  RCC->CR |= ((uint32_t)RCC_CR_HSEON);

 

  /* Wait till HSE is ready and if Time out is reached exit */

  do

  {

    HSEStatus = RCC->CR & RCC_CR_HSERDY;

    StartUpCounter++;  

  } while((HSEStatus == 0) && (StartUpCounter != HSEStartUp_TimeOut));

  if ((RCC->CR & RCC_CR_HSERDY) != RESET)

  {

    HSEStatus = (uint32_t)0x01;

  }

  else

  {

    HSEStatus = (uint32_t)0x00;

  }  

  if (HSEStatus == (uint32_t)0x01)

  {

    /* Enable Prefetch Buffer */

    FLASH->ACR |= FLASH_ACR_PRFTBE;

    /* Flash 2 wait state */

    FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);

    FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2;    

 

    /* HCLK = SYSCLK */

    RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;

      

    /* PCLK2 = HCLK */

    RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;

    

    /* PCLK1 = HCLK */

   

RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV8;   //72MHZ/8 = 9MHZ

.

.

.

}

Posted on July 06, 2014 at 13:52

So what clock DO you see? And how have you configured the USART?

I'd guess 4.5 MHz, why run APB1 at 9 MHz, wouldn't a higher multiple work better? Review the USART block diagram in the manual, and the GTPR register.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mahtabmodaber
Associate II
Posted on July 07, 2014 at 09:22

The usart2_ck pin was about 2.4 MHZ in oscilloscope. I need 10 MHZ

clock to joint to my sensor clock and 9 MHZ APB1 clock is reachable by prescalers.but i found maybe usart clock pin does not correspond to APB1 clock. Am i right? so 10 MHZ for usart clock pin is unreachable?!!?

Its my configuration code :

GPIO_InitTypeDef GPIO_InitStructure;                    

    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO ,ENABLE);

    RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2 , ENABLE );                                                        

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;                 

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;               

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;           

      GPIO_Init(GPIOA, &GPIO_InitStructure);                       

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//GPIO_Mode_IPU;                           

      GPIO_Init(GPIOA, &GPIO_InitStructure);

    

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;                 

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;               

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;           

      GPIO_Init(GPIOA, &GPIO_InitStructure);   

USART_InitTypeDef USART_InitStructure;

        

    USART_ClockInitTypeDef USART_ClkInitStructure;                          

    USART_InitStructure.USART_BaudRate            =BaudRate ;                  

    USART_InitStructure.USART_WordLength          = USART_WordLength_8b;     

    USART_InitStructure.USART_StopBits            = USART_StopBits_1;         

    USART_InitStructure.USART_Parity              = USART_Parity_No ;         

    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

    USART_InitStructure.USART_Mode                = USART_Mode_Rx | USART_Mode_Tx;

    USART_Init(USART2, &USART_InitStructure);                                

    USART_ITConfig(USART2,USART_IT_RXNE,ENABLE);                            

    __nop(); __nop();

    USART_ClkInitStructure.USART_Clock=USART_Clock_Enable;

    USART_ClkInitStructure.USART_CPOL=USART_CPOL_Low;

    USART_ClkInitStructure.USART_CPHA=USART_CPHA_2Edge;

    USART_ClkInitStructure.USART_LastBit=USART_LastBit_Enable;

    USART_ClockInit(USART2, &USART_ClkInitStructure);

     

       USART_Cmd(USART2, ENABLE);