Page 1 of 1

Timer Reading Value?

Posted: Mon Apr 26, 2021 9:12 am
by seokgi
Good morning.
I use the PIC18F47Q10.
I would like to use a 16 bit timer in my program.
So I use Timer5.
It reads the values in milliseconds or Second comes a different value.

If there is an example, can I see it?

Thank you.

Re: Timer Reading Value?

Posted: Mon Apr 26, 2021 10:57 am
by BenR
Hello,

I've added an example here for you which should show the basics of the timer component.

https://www.flowcode.co.uk/wiki/index.p ... )#Examples

Re: Timer Reading Value?

Posted: Wed Apr 28, 2021 1:12 pm
by seokgi
Thank you for the example program.
After the timer stops, the value is read.
I want to read the value before the timer stops and use that value to stop the timer and use the read value. is it possible? Or is there a way to use that value after a certain amount of time has passed?
For example, a 500ms timer and a 1 second timer.

please answer me.
Thank you.

Re: Timer Reading Value?

Posted: Wed Apr 28, 2021 2:22 pm
by alanwms
Possibly use an interrupt for the timer, and increment a variable inside the interrupt. Then outside of the interrupt, simply test the variable for the value you are wishing to stop at.

Re: Timer Reading Value?

Posted: Wed Apr 28, 2021 2:33 pm
by seokgi
Thank you for answer.
But I don't understand it very well.
Sorry, but could you post a simple example.

Thank you.

Re: Timer Reading Value?

Posted: Wed May 05, 2021 6:10 pm
by alanwms
Just insert an interrupt icon into the beginning of the program. The timer you use will dictate how often the interrupt happens.

When the interrupt happens, the macro (of your choice) will be run. In that macro, you simply add +1 to a variable That's it.

That accomplishes nothing except incrementing a variable - But in your regular program, you can now test the variable for compliance with your requirements.

The timer speed will be set when you insert the interrupt. That number will dictate how many times per minute that the interrupt will run.

Simply calculate how many times it will run to determine your variable test number for one second or millisecond.