GPIO Toggling issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-08 6:55 AM
Hi,
Now I'm currently working with GPIO control.
And I have an issue to control GPIO,
I came across there's not toggling when I use delay()
For example,
# GPIO toggling not working case
void delay(void){ volatile int i; for(i=0; i<10000000; i++);}while (1) { GPIOG->BSRRL = GPIO_Pin_14; delay(); GPIOG->BSRRH = GPIO_Pin_14; delay();GPIOG->BSRRL = GPIO_Pin_15;
GPIOG->BSRRH = GPIO_Pin_15;GPIO_SetBits(GPIOG, GPIO_Pin_15);
GPIO_ResetBits(GPIOG, GPIO_Pin_15);}
# GPIO toggling working good case
void delay(void){ volatile int i; for(i=0; i<10000000; i++);}while (1){GPIOG->BSRRL = GPIO_Pin_14;GPIOG->BSRRH = GPIO_Pin_14;GPIOG->BSRRL = GPIO_Pin_15;
GPIOG->BSRRH = GPIO_Pin_15;GPIO_SetBits(GPIOG, GPIO_Pin_15);
GPIO_ResetBits(GPIOG, GPIO_Pin_15);}
Could you please let me know what does difference between them?
Why doesn't it toggling whithin delay() ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-08 8:55 AM
If you are single stepping it might take a while. The delay might need to be tuned depending on how fast things are running, I chose a million to make sure the on/off would be human perceivable a dozens of MHz. Banging the lines up/down at a MHz is going to be imperceivable to the human eye.
Consider keeping your adventure in one thread, there's no value to having dozens of threads about materially the same evolution of what you're doing.
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
‎2017-09-08 9:12 AM
Hi!
The '# GPIO toggling working good case' not includes any delay.
Which way you use to observe the toggling? Do you have an oscilloscope?
Try to give a delay 10 times bigger and use this code.
while (1)
{ GPIOG->BSRRL = GPIO_Pin_14; delay(); GPIOG->BSRRH = GPIO_Pin_14; delay();}
supposed that GPIOG pin 14 is initialized in pushpull output mode.(additionaly in your posted cases in maximum speed.)
Regards
vf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-08 11:13 AM
I can't understand what you are saying. Could you please let me know more clarify?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-08 11:16 AM
Yes, I've observed it in oscilloscope.
and I've tested with 10times.
while (1)
{GPIOG->BSRRL = GPIO_Pin_14;delay();GPIOG->BSRRH = GPIO_Pin_14;delay();}
GPIOG->BSRRL = GPIO_Pin_15; GPIOG->BSRRH = GPIO_Pin_15;GPIO_SetBits(GPIOG, GPIO_Pin_15);
GPIO_ResetBits(GPIOG, GPIO_Pin_15);That's working as my expectation, it still does not work with delay().
But If I remove delay() in there, then that's working as good, I can check with oscilloscope..
What kind of things should I have to consider to use GPIO toggling in maximum frequency (speed)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-08 11:52 AM
Did you ever measured this delay? Is it too big? put a very small delay and observe in your oscilloscope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-08 12:06 PM
Let me check to figure out with small delay.
BTW, I can't understand this, why does delay() affect to another gpio function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-08 1:19 PM
The delay slows it down so you can physically see it blink. Oscilloscope not going to be helpful at 0.1 Hz
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
‎2017-09-08 1:23 PM
Don't know, you're not very good at explaining the context clearly. Slow signals will be visible to the eye, but difficult to see/sync on a scope.
Make the delay loop smaller, I pulled a million out of the air, try 100 or 1000
In the UK or South/North Korea?
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
‎2017-09-09 12:16 AM
I found it from oscilloscope that toggling signal.
