The clocks each command takes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-27 10:51 AM
Hi.
I wanted to know that for example how many clocks a while loop takes.
Do you have any ideas or any articles on this matter?
Note: this post was migrated and contained many threaded conversations, some content may be missing.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-28 03:44 PM
If you set the TIM to clock at 1 MHz you can observe intervals with 1us granularity by looking at the CNT value. You can interrupt at such rates.
start = TIM->CNT;
while((TIM->CNT - start) < 100); // Wait 100us
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
‎2018-05-04 04:45 AM
void delay_us(unsigned int d)
{TIM2_Cmd(ENABLE);while( ((TIM2->CNTRL)|((TIM2->CNTRL)<<8))<=d);TIM2_Cmd(DISABLE);TIM2->CNTRL=0;TIM2->CNTRH=0;}void delay_ms(unsigned int d)
{while(d){d--;delay_us(1000);}}I've written this code for my delay functions but they do not work.
The timer CNT counts each 1 us.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-04 04:58 AM
Run your led update function through a timer isr so it is not blocked by the 1wire routines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-04 10:33 AM
I didn't understand what you mean.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-04 10:44 AM
I'm not advocating the repeated resetting and enabling/disabling the timer. I'm saying to let it free run and delta the current and start points.
If dealing with 8-bit values is most effective on the STM8 (not using, don't plan too), then perhaps decompose the delays into 200us or 100us pieces so the code is tighter and the opportunity for jitter reduced.
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
‎2018-05-04 11:00 AM
You mean with these 8-bit MCUs I cant get a 1 us delay using the timer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-04 01:29 PM
take some classes in embedded programming.
you are going down a path that can only hurt your learning in the long run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-04 02:25 PM
If I had the possibility I would do that.But these classes will not be free and as a student, I can't afford the expenses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-04 02:34 PM
There are some classes available for free. Look at edX and similar initiatives:
https://www.edx.org/course/embedded-systems-shape-the-world-microcontroller-inputoutput
also books are good way of learning and verifying the knowledge in practice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-04 03:43 PM
'
I can't afford the expenses.'
it is a tough spot to be in, unfortunately.
with that said, you may want to focus a little bit on the basics before tackling issues outside of your skill set.
slowing down now often allows you to run faster later.