Change the speed of GPIO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-06 3:41 AM
Hi there,
I want to change the speed of GPIO for STM32f4 discovery board. The maximun speed I can get on specified pin is 6 MHz and I want to get 20 Mhz. we know that the discovery board has external clock circuit to operate at high speed. I do not know what to do to get higher speed. By the way I am using Keil (uvision) software. Thanks for any help- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-06 5:02 AM
The way you've framed the question I'm going to assume you are trying to toggle the pin manually. Apparently poorly in C, in assembler I'm pretty sure we can push 84 MHz.
BUT, don't do that, if you want to drive pins at high frequencies, don't use interrupts, but use TIM peripherals. Higher frequencies might still be a problem as they must be integer multiples of the source clock, so you might need to alter the CPU speed to suit, or use other PLLs.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-06 5:23 AM
Thanks for replay.
What I can understand that I can't change the speed of the GPIO lines of port a, b, c, or f !- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-06 5:35 AM
> What I can understand that I can't change the speed of the GPIO lines of port a, b, c, or f !
What do you mean by ''change speed of gpio''? Please explain. JW- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-06 6:39 AM
Let’s take example to illustrate what I mean from my question. Suppose I am configuring port A to be an output and then I set and reset the specified pin of port a high and low. The maximum frequency I got is 6MHz
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 ; // we want to configure pin 1&2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; // we want these to be outputs
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // pushpull
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; // clock speed
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // these configure without pullup or down resistor connection
GPIO_Init(GPIOA, &GPIO_InitStructure);
// Generate pattren to measure the frequency at pin 2 of port a
GPIO_SetBits(GPIOA, GPIO_Pin_2);
GPIO_ResetBits(GPIOA, GPIO_Pin_2);
GPIO_SetBits(GPIOA, GPIO_Pin_2);
GPIO_ResetBits(GPIOA, GPIO_Pin_2);
The below link shows the output frequency due set and reset command from the above code- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-06 6:43 AM
1. Avoid the ''library functions''. Write directly to the registers. For example:
GPIOA->BSRRL = 1 << 2; GPIOA->BSRRH = 1 << 2; 2. Re-read Clive's answer very carefully. JW- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-07 1:52 AM
Thanks for your help. It works and I am able to get 40 MHz which is the required.
