Skip to main content
developer2
Senior
May 25, 2013
Question

digital sampling of GPIO

  • May 25, 2013
  • 2 replies
  • 569 views
Posted on May 26, 2013 at 00:35

Hi,

is it possible to sample GPIOA Bit7-0 into SRAM as byte and to have kind of ''Clk'' nonPWM output on other GPIO ,

with higher speed than 20MHz on STM32F103 72MHz ?

this gives me 10MHz clk output on PC2:

 Buffer_ptr=(uint8_t *)Buffer;

 while( 1 )

  {

    *(Buffer_ptr++)=(uint8_t)GPIOA->IDR;

    GPIOC->ODR = GPIO_Pin_2;

    if(Buffer_ptr>=(uint8_t *)(Buffer+20000))

      break;

    GPIOC->ODR = 0;

  }

Thank You for all replies
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    May 26, 2013
    Posted on May 26, 2013 at 02:00

    DMA transfer of a GPIOx->ODR, triggered by a TIM, output of same trigger pulse. Speed of the APB may be a limiting factor here. Consider a different part from the F2/F4 series.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    developer2
    Senior
    May 26, 2013
    Posted on May 26, 2013 at 09:05

    i tried this with DMA:

      Buff_PC2[0]=0;

      Buff_PC2[1]=GPIO_Pin_2;

     

      DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&GPIOC->ODR);

      DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)Buff_PC2;

      DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;

      DMA_InitStructure.DMA_BufferSize = 2;

      DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

      DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

      DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;

      DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;

      DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;

      DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;

      DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;

      DMA_Init(DMA2_Channel1 , &DMA_InitStructure);

      TIM_TimeBaseStructure.TIM_Period = 1;

      TIM_TimeBaseStructure.TIM_Prescaler = 0x00;

      TIM_TimeBaseStructure.TIM_ClockDivision = 0;

      TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

      TIM_TimeBaseInit( TIM8, &TIM_TimeBaseStructure);

      TIM_UpdateRequestConfig( TIM8, TIM_UpdateSource_Regular );

      DMA_Cmd(  DMA2_Channel1, ENABLE);

      TIM_Cmd( TIM8, ENABLE);

    this generates 600kHz,

    did i make mistake somewhere in initialization ?