Prob. ECIO40P16 and timer larger timer 1 in macros [Solved]

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Prob. ECIO40P16 and timer larger timer 1 in macros [Solved]

Post by tiny »

I use for my circuit an ECIO40P16, control and display of the periphery via a Nextion display and additionally print buttons for port on / off. Nextion and buttons are controlled by interrupt.

Timer 1 accepts the cyclic tasks (polling the ports, switching date and time, etc.)

If an override is to be controlled via the print button, an IOC port interrupt is triggered and the routine remains in the loop until the button is acknowledged. So that it does not become an endless loop, I activate a timer (Timer 5) and after approximately 2.5 minutes the loop is terminated.

This routine ran smoothly with the PIC18F26K22, with the ECIO40P16 the timer can not be started.

Stop and restart of the timer 1 runs without problems, but not any other timer in the button polling routine.

In the simulation it runs, on chip no reaction.

Here is a short section of my program with the basic functions to show my timer problem.

Can someone give me a tip, how I can activate the timer?

Thanks
Christina
Flowcode1.fcfx
(61.29 KiB) Downloaded 271 times
Last edited by tiny on Sun Mar 19, 2017 10:26 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by Benj »

Hi Christina,

I'll have a play and see if I can find the issue for you.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by Benj »

Hi Christina,

I've put together a really basic program using timer 5 and this is working well for me on the hardware. I've also attached my C file so you can compile the project to C and compare with my file to see if there is a difference.
FC_Tst.fcfx
(5.76 KiB) Downloaded 260 times
FC_Tst.c
(2.99 KiB) Downloaded 269 times

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by tiny »

Thank you Benj for the work.
With the timer interrupts in the main program I have no problem, which runs without problems.
The example that I have sent shows that a button is interrogated in the Chk_Switch macro (via Interrupt IOC port) and whenever the button is pressed, the status of port 1 is changed and the button quit is confirmed. So far so good.

At the same time, Timer 5 is started, so that after a certain time the loop is interrupted during the probe interrogation, you should forget to press the Quit button.
And there is the problem! Timer 5 (and no other timer) can not be activated. Timer 1 is the only timer that works, but this I need for the main functions of the circuit.

Christina

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by Benj »

Hi Christina,

Sorry for the delay.

This is now working really well for me and will hopefully help in your application.

I use an IOC interrupt on the high byte of Port B to trigger timer 5 to be enabled.

When timer 5 interrupts I increment a counter and then disable timer 5 again.

The counter is then show on the low byte of Port B.

I use a bit of C code when enabling the timer to reset the count register and also to clear the interrupt flag just in case it has been set. This seems to help achieve reliable operation.
Attachments
FC_Tst.fcfx
(7.74 KiB) Downloaded 265 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by Benj »

Here is a slightly modified FCD which includes the timer flag and counter reset as part of the enable code so you don't have to manually add it using a C icon.

Simply copy this to your "Flowcode 7/FCD/PIC16" folder before starting Flowcode and hopefully this should allow your program to function as expected.
ECIO40P16.fcdx
(44 KiB) Downloaded 261 times
Let me know how you get on.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by jgu1 »

Hi Ben!

Your FCDX file, is this a bug correction or is custom for Christina.

Thanks in advance

Jorgen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by Benj »

Hi Jorgen,

The FCD file now has the following changes.

Timer enable resets the timer register to 0 and clears the interrupt flag in case there was an interrupt pending. Avoids the timer interrupt instantly firing which is what I was seeing here.

Timer disable switches off the timer peripheral as well as the interrupt. This should stop the timer interrupt flag being set and should also save a little bit of power.

I've rolled out this change to the family of devices (xxxEPxxxxGUxxx and xxxEPxxxxMUxxx), the dsPIC MIAC, the Formula AllCode and the EB091 and the change will likely stay going forward. I am yet undecided on whether to roll it out to all 16-bit PIC devices or not.

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by petesmart »

Hi Ben,

Any chance you could post the dspic MIAC fed file when it's cooked? Working with MIAC now using interrupts for frequency counter.... This would be helpful.

Best

Pete
sorry about that Chief!

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by LeighM »

Hi Pete,
Ben's updates attached.
Regards,
Leigh
Attachments
MIAC (dsPIC) System.fcdx
(57.57 KiB) Downloaded 191 times
MIAC (dsPIC).fcdx
(57.46 KiB) Downloaded 186 times

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by petesmart »

Brilliant...thank you...
sorry about that Chief!

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Problem with ECIO40P16 and timer larger timer 1 in macro

Post by tiny »

Thank you Ben for the many work, but the timer 5 works now!
But my program still needs to be considered.
In the function Chk_Switch, I activate the timer 5 and then I go to the keystroke. If the routine immediately enters the keystroke, the timer is not activated. If I disable the keystroke then it works. Here I have to think about how I can continue to work with the time delay or to activate the keystroke only when the timer 5 is activated.
Until now, I'm still hanging around on this problem, otherwise everything works!

Thanks again!
Christina

Post Reply