Equivalent of millis() in Atmel studio











up vote
1
down vote

favorite












I want to translate my arduino code to Atmel studio. I need help.
What is the equivalent of this code in Atmel studio. I think, timers are necessary (?).
Thanks



starttime = millis();
endtime = starttime;

while ((endtime - starttime)<=5000) // do this loop for up to 5000mS
{
endtime = millis();

action();
}









share|improve this question









New contributor




alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    cross post stackoverflow.com/questions/53780848/…
    – Juraj
    12 hours ago















up vote
1
down vote

favorite












I want to translate my arduino code to Atmel studio. I need help.
What is the equivalent of this code in Atmel studio. I think, timers are necessary (?).
Thanks



starttime = millis();
endtime = starttime;

while ((endtime - starttime)<=5000) // do this loop for up to 5000mS
{
endtime = millis();

action();
}









share|improve this question









New contributor




alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    cross post stackoverflow.com/questions/53780848/…
    – Juraj
    12 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I want to translate my arduino code to Atmel studio. I need help.
What is the equivalent of this code in Atmel studio. I think, timers are necessary (?).
Thanks



starttime = millis();
endtime = starttime;

while ((endtime - starttime)<=5000) // do this loop for up to 5000mS
{
endtime = millis();

action();
}









share|improve this question









New contributor




alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I want to translate my arduino code to Atmel studio. I need help.
What is the equivalent of this code in Atmel studio. I think, timers are necessary (?).
Thanks



starttime = millis();
endtime = starttime;

while ((endtime - starttime)<=5000) // do this loop for up to 5000mS
{
endtime = millis();

action();
}






arduino-uno arduino-ide atmel-studio






share|improve this question









New contributor




alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 12 hours ago









Michel Keijzers

6,27841737




6,27841737






New contributor




alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 12 hours ago









alex jla

61




61




New contributor




alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






alex jla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    cross post stackoverflow.com/questions/53780848/…
    – Juraj
    12 hours ago














  • 2




    cross post stackoverflow.com/questions/53780848/…
    – Juraj
    12 hours ago








2




2




cross post stackoverflow.com/questions/53780848/…
– Juraj
12 hours ago




cross post stackoverflow.com/questions/53780848/…
– Juraj
12 hours ago










1 Answer
1






active

oldest

votes

















up vote
4
down vote













The millis() function is defined in the Arduino Core for AVR architecture, specifically the wiring.c file.



You can see that timer0 is setup with various parameters for prescaling and interrupt triggering and handling of timer0 overflow such that a variable called timer0_millis contains the number of milliseconds since the sketch started.



The millis() function basically returns that timer0_millis value.



If you wish to make use of the function in AVR Studio, then you would need to include the same kind of timer0 setup and interrupt/overflow handling that the Arduino core does.






share|improve this answer





















  • I have found example code,but isn't same.Can you write equivalent of code in above?for being example and my learning.Of course,If is this possible?Thanks.
    – alex jla
    12 hours ago










  • I will not write it for you. It's already written in wiring.c
    – jose can u c
    12 hours ago










  • oh sorry,I hadn't seen wiring.c file.I have added to my project.But I am not using timer0_millis.Error: 'timer0_millis' undeclared (first use in this function). What can I add wiring.c to my project?
    – alex jla
    12 hours ago








  • 3




    You will need to read all of wiring.c, understand it, and then implement it in your own project. Arduino makes very simple the things which are complex on "pain" AVR programming. What is the reason you choose to use AVR Studio?
    – jose can u c
    11 hours ago










  • Because I am learning atmel studio.But now,I need to this function.No need to make it so difficult.Just,I want to counter like millis() which has forward direction.I need solution.
    – alex jla
    9 hours ago











Your Answer






StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "540"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






alex jla is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f58757%2fequivalent-of-millis-in-atmel-studio%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
4
down vote













The millis() function is defined in the Arduino Core for AVR architecture, specifically the wiring.c file.



You can see that timer0 is setup with various parameters for prescaling and interrupt triggering and handling of timer0 overflow such that a variable called timer0_millis contains the number of milliseconds since the sketch started.



The millis() function basically returns that timer0_millis value.



If you wish to make use of the function in AVR Studio, then you would need to include the same kind of timer0 setup and interrupt/overflow handling that the Arduino core does.






share|improve this answer





















  • I have found example code,but isn't same.Can you write equivalent of code in above?for being example and my learning.Of course,If is this possible?Thanks.
    – alex jla
    12 hours ago










  • I will not write it for you. It's already written in wiring.c
    – jose can u c
    12 hours ago










  • oh sorry,I hadn't seen wiring.c file.I have added to my project.But I am not using timer0_millis.Error: 'timer0_millis' undeclared (first use in this function). What can I add wiring.c to my project?
    – alex jla
    12 hours ago








  • 3




    You will need to read all of wiring.c, understand it, and then implement it in your own project. Arduino makes very simple the things which are complex on "pain" AVR programming. What is the reason you choose to use AVR Studio?
    – jose can u c
    11 hours ago










  • Because I am learning atmel studio.But now,I need to this function.No need to make it so difficult.Just,I want to counter like millis() which has forward direction.I need solution.
    – alex jla
    9 hours ago















up vote
4
down vote













The millis() function is defined in the Arduino Core for AVR architecture, specifically the wiring.c file.



You can see that timer0 is setup with various parameters for prescaling and interrupt triggering and handling of timer0 overflow such that a variable called timer0_millis contains the number of milliseconds since the sketch started.



The millis() function basically returns that timer0_millis value.



If you wish to make use of the function in AVR Studio, then you would need to include the same kind of timer0 setup and interrupt/overflow handling that the Arduino core does.






share|improve this answer





















  • I have found example code,but isn't same.Can you write equivalent of code in above?for being example and my learning.Of course,If is this possible?Thanks.
    – alex jla
    12 hours ago










  • I will not write it for you. It's already written in wiring.c
    – jose can u c
    12 hours ago










  • oh sorry,I hadn't seen wiring.c file.I have added to my project.But I am not using timer0_millis.Error: 'timer0_millis' undeclared (first use in this function). What can I add wiring.c to my project?
    – alex jla
    12 hours ago








  • 3




    You will need to read all of wiring.c, understand it, and then implement it in your own project. Arduino makes very simple the things which are complex on "pain" AVR programming. What is the reason you choose to use AVR Studio?
    – jose can u c
    11 hours ago










  • Because I am learning atmel studio.But now,I need to this function.No need to make it so difficult.Just,I want to counter like millis() which has forward direction.I need solution.
    – alex jla
    9 hours ago













up vote
4
down vote










up vote
4
down vote









The millis() function is defined in the Arduino Core for AVR architecture, specifically the wiring.c file.



You can see that timer0 is setup with various parameters for prescaling and interrupt triggering and handling of timer0 overflow such that a variable called timer0_millis contains the number of milliseconds since the sketch started.



The millis() function basically returns that timer0_millis value.



If you wish to make use of the function in AVR Studio, then you would need to include the same kind of timer0 setup and interrupt/overflow handling that the Arduino core does.






share|improve this answer












The millis() function is defined in the Arduino Core for AVR architecture, specifically the wiring.c file.



You can see that timer0 is setup with various parameters for prescaling and interrupt triggering and handling of timer0 overflow such that a variable called timer0_millis contains the number of milliseconds since the sketch started.



The millis() function basically returns that timer0_millis value.



If you wish to make use of the function in AVR Studio, then you would need to include the same kind of timer0 setup and interrupt/overflow handling that the Arduino core does.







share|improve this answer












share|improve this answer



share|improve this answer










answered 12 hours ago









jose can u c

5,5022724




5,5022724












  • I have found example code,but isn't same.Can you write equivalent of code in above?for being example and my learning.Of course,If is this possible?Thanks.
    – alex jla
    12 hours ago










  • I will not write it for you. It's already written in wiring.c
    – jose can u c
    12 hours ago










  • oh sorry,I hadn't seen wiring.c file.I have added to my project.But I am not using timer0_millis.Error: 'timer0_millis' undeclared (first use in this function). What can I add wiring.c to my project?
    – alex jla
    12 hours ago








  • 3




    You will need to read all of wiring.c, understand it, and then implement it in your own project. Arduino makes very simple the things which are complex on "pain" AVR programming. What is the reason you choose to use AVR Studio?
    – jose can u c
    11 hours ago










  • Because I am learning atmel studio.But now,I need to this function.No need to make it so difficult.Just,I want to counter like millis() which has forward direction.I need solution.
    – alex jla
    9 hours ago


















  • I have found example code,but isn't same.Can you write equivalent of code in above?for being example and my learning.Of course,If is this possible?Thanks.
    – alex jla
    12 hours ago










  • I will not write it for you. It's already written in wiring.c
    – jose can u c
    12 hours ago










  • oh sorry,I hadn't seen wiring.c file.I have added to my project.But I am not using timer0_millis.Error: 'timer0_millis' undeclared (first use in this function). What can I add wiring.c to my project?
    – alex jla
    12 hours ago








  • 3




    You will need to read all of wiring.c, understand it, and then implement it in your own project. Arduino makes very simple the things which are complex on "pain" AVR programming. What is the reason you choose to use AVR Studio?
    – jose can u c
    11 hours ago










  • Because I am learning atmel studio.But now,I need to this function.No need to make it so difficult.Just,I want to counter like millis() which has forward direction.I need solution.
    – alex jla
    9 hours ago
















I have found example code,but isn't same.Can you write equivalent of code in above?for being example and my learning.Of course,If is this possible?Thanks.
– alex jla
12 hours ago




I have found example code,but isn't same.Can you write equivalent of code in above?for being example and my learning.Of course,If is this possible?Thanks.
– alex jla
12 hours ago












I will not write it for you. It's already written in wiring.c
– jose can u c
12 hours ago




I will not write it for you. It's already written in wiring.c
– jose can u c
12 hours ago












oh sorry,I hadn't seen wiring.c file.I have added to my project.But I am not using timer0_millis.Error: 'timer0_millis' undeclared (first use in this function). What can I add wiring.c to my project?
– alex jla
12 hours ago






oh sorry,I hadn't seen wiring.c file.I have added to my project.But I am not using timer0_millis.Error: 'timer0_millis' undeclared (first use in this function). What can I add wiring.c to my project?
– alex jla
12 hours ago






3




3




You will need to read all of wiring.c, understand it, and then implement it in your own project. Arduino makes very simple the things which are complex on "pain" AVR programming. What is the reason you choose to use AVR Studio?
– jose can u c
11 hours ago




You will need to read all of wiring.c, understand it, and then implement it in your own project. Arduino makes very simple the things which are complex on "pain" AVR programming. What is the reason you choose to use AVR Studio?
– jose can u c
11 hours ago












Because I am learning atmel studio.But now,I need to this function.No need to make it so difficult.Just,I want to counter like millis() which has forward direction.I need solution.
– alex jla
9 hours ago




Because I am learning atmel studio.But now,I need to this function.No need to make it so difficult.Just,I want to counter like millis() which has forward direction.I need solution.
– alex jla
9 hours ago










alex jla is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















alex jla is a new contributor. Be nice, and check out our Code of Conduct.













alex jla is a new contributor. Be nice, and check out our Code of Conduct.












alex jla is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Arduino Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f58757%2fequivalent-of-millis-in-atmel-studio%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ellipse (mathématiques)

Quarter-circle Tiles

Mont Emei