i want read tmr0 value

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
oben
Posts: 2
Joined: Sun Apr 27, 2014 2:35 am

i want read tmr0 value

Post by oben »

hi sir
i am new to flowcode ....i want read TMR0 value and store it in Variable....i tried FCV_COUNT=tmr0; but it didnt work

i am using pic 16f84a......any help please
Attachments
TMR0.fcf
(7.5 KiB) Downloaded 377 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: i want read tmr0 value

Post by medelec35 »

Hi oben,
Welcome to the forums.

There is one or possibly two issues with your Flowchart.

1. You have got:

Code: Select all

FCV_COUNT=tmro;
It's not a letter at the very end but the number 0:
FCV_COUNT=tmr0;
Since you have got the zero on your initial post and within heading, I can only assume it's a typo within your flowchart?

2. The default setting for timer interrupts that can be triggered by internal clock or externally (Transition in the interrupt pin).
The latter is fine if you are indeed using an external signal connected to pin 3 (T0CKI).
If not then you will need to change the setting by double clicking on the interrupt component and selecting properties.
Click on the down arrow of the 'Clock source select' & change from 'Transition on T0CKI pin' to 'Internal clock CLKO'

Martin
Martin

oben
Posts: 2
Joined: Sun Apr 27, 2014 2:35 am

Re: i want read tmr0 value

Post by oben »

thanks medelec35 ....it works now fine

miggarcbs
Posts: 20
Joined: Fri Dec 04, 2015 1:14 pm
Location: Portugal
Been thanked: 2 times

Re: i want read tmr0 value

Post by miggarcbs »

Hi

I'm using Flowcode 6

Reading timer registers into a flowcode variable and display
it in simulation debugger window is something I never
achieved correctly.

That said, to see if this time I can accomplish this purpose,
I took you example and:

1-
I corrected the tmro to tmr0 and

2-
set timer 0 clock to internal.

3-
created a macro called "time" with a 1us delay, only to have something there
when the interrupt occurs

4-
added variable "count" to simulation debugger window


RESULT?

As ever, when I try to accomplish something like this,
I can't see any change on timer internal registers
attributed to an internal flowcode variable
(in this case "count") on simulation.

I tried Normal simulation, 50Hz simulation and even
step into simulation.


My Flowcode flowchart is attached


Question is:

What am I doing wrong?

What's the "secret" to view timer internal registers
changing, attributed to an internal flowcode variable
showed on simulation debugger?
Attachments
TMR0_v6.fcfx
(4.44 KiB) Downloaded 371 times
.
.

Thanks in advance,

---------------------------------------------

Miguel Garcia
Electronics Technician
Electronic Systems Developer

.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: i want read tmr0 value

Post by medelec35 »

Hi Miguel,
miggarcbs wrote:I can't see any change on timer internal registers
C code can't be simulated, that's why you can't see the values.
Normally you would not use C code to view interrupt register for accurate timing when an interrupt has occurred.
It would be used to read the interrupt register when checking the time of an event before interrupt has been triggered like a snapshot.
For a variable to be incremented when interrupt has been triggered:
You just place a variable initialise with 0 (which you have done) within timer interrupt call macro (also known as interrupt service routine or ISR).
Every time interrupt is triggered (75 times a second = every 1/75 = 13ms with your setting as prescaler = 1:256) then whatever is within timer interrupt macro will be accessed.
Avoid placing delays or components that contain delays e.g LCD within interrupt.
I have modified your Flowchart so it does the following:
1. Changes state of portB0 which has a LED connected to it.
2. Increments a variable
3. Measure the pulse width of B0 by using the inbuilt scope (View menu, Scope)
You just hover mouse over waveform to get duration of pulse width
interrupt demo.png
(101.07 KiB) Downloaded 7238 times
Although the value does not look correct at 106us :?

Note you can only view the interrupt value when simulator is paused or running slower then the normal speed.
Due to a bug, you can at the time of writing run simulator slower then normal and observe interrupt value changing but it takes a little while to change
So to view the current value you will have run simulation on normal speed then pause it.
You can also place a breakpoint within timer macro if you want to observe every increment.
To do that, right click on any icon e.g calculation box and select toggle breakpoint

Martin
Attachments
TMR0_v6.fcfx
(6.49 KiB) Downloaded 401 times
Martin

miggarcbs
Posts: 20
Joined: Fri Dec 04, 2015 1:14 pm
Location: Portugal
Been thanked: 2 times

Re: i want read tmr0 value

Post by miggarcbs »

Hi

Lots of thanks thanks medelec35

I will try this and let you know about my results.


Very probably it is not a very good forum policy to mix questions about different topics in the same one.
Any way, as you are a "Valued Forum Contributor ", if you know anything about the following question,
I will appreciate this very much.

My posts are taking a lot of time to be approved and effectively visible (some times many hours), which is a big wast of time.
As I said I'm a registered Flowcode 6 professional with PIC pack user.

I sent this question directly Matrix thought their contact form but, as it was on Saturday,
I'm still waiting for an answer.

Can you help by explaining me what could be happening?
Is there any way to solve this problem?
.
.

Thanks in advance,

---------------------------------------------

Miguel Garcia
Electronics Technician
Electronic Systems Developer

.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: i want read tmr0 value

Post by kersing »

miggarcbs wrote:My posts are taking a lot of time to be approved and effectively visible (some times many hours), which is a big wast of time.
Posts are approved manually, after posting one of the moderators needs to read it and approve which takes time as we do not monitor the forum 24x7. However you posts no longer need to be approved, so this should no longer be an issue.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

miggarcbs
Posts: 20
Joined: Fri Dec 04, 2015 1:14 pm
Location: Portugal
Been thanked: 2 times

Re: i want read tmr0 value

Post by miggarcbs »

ok. all understood...

Thanks for your answer and sorry to mix different aspects within the same topic.
.
.

Thanks in advance,

---------------------------------------------

Miguel Garcia
Electronics Technician
Electronic Systems Developer

.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: i want read tmr0 value

Post by medelec35 »

Just to add to kersing's post.
It's the first few posts that require approval by a moderator.
After that approval is no longer required.

Martin
Martin

Post Reply