Prob. ECIO40P16 and timer larger timer 1 in macros [Solved]
Moderator: Benj
- 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]
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
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
Last edited by tiny on Sun Mar 19, 2017 10:26 pm, edited 1 time in total.
- 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
Hi Christina,
I'll have a play and see if I can find the issue for you.
I'll have a play and see if I can find the issue for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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
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
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
- 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
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.
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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
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.
Let me know how you get on.
Simply copy this to your "Flowcode 7/FCD/PIC16" folder before starting Flowcode and hopefully this should allow your program to function as expected.
Let me know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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
Hi Ben!
Your FCDX file, is this a bug correction or is custom for Christina.
Thanks in advance
Jorgen
Your FCDX file, is this a bug correction or is custom for Christina.
Thanks in advance
Jorgen
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- petesmart
- 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
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
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!
- 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
Hi Pete,
Ben's updates attached.
Regards,
Leigh
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
- petesmart
- 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
Brilliant...thank you...
sorry about that Chief!
- 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
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
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