Page 1 of 1

Timer Interrupt in Makro

Posted: Fri Dec 26, 2014 11:12 am
by DirkB
Hello, merry christmas at first ;o)

Timer interrupt in makro doesn't works. I am using 12F1840.
In simulation it works well but it doesn't work on chip.
Is it possible to use timer interrupt in makro?

thanks

Dirk

Re: Timer Interrupt in Makro

Posted: Fri Dec 26, 2014 11:45 am
by medelec35
Hi Dirk,
DirkB wrote: merry christmas at first ;o)
Thanks Dirk and the same to you :)
DirkB wrote:In simulation it works well but it doesn't work on chip.
This can occur if in the interrupt properties the clock source select are left on the default

Code: Select all

Transistion on T0CKI
instead of changing to:

Code: Select all

 Internal clock (CLKO)
if timer0 for example:
timer int.png
(26.57 KiB) Downloaded 6338 times
If that's not it then can you post your flowchart so we can take a look at what could bo going on.

Martin

Re: Timer Interrupt in Makro

Posted: Fri Dec 26, 2014 12:21 pm
by DirkB
Hi Martin,

clock source is configured to internal clock. A simple flowchart (only lights LED)
doesn't works in makro, only in main flowchart. is this (maybe) a bug?

http://www.flowcode.co.uk/mmforums/viewt ... upt#p60278

thanks

Dirk

Re: Timer Interrupt in Makro

Posted: Fri Dec 26, 2014 12:39 pm
by medelec35
So the timer interrupt works, but not the port bits.
If you post your flowchart (or PM if confidential or commercially sensitive) I will see if I can sort it out for you.
I assumed you have tried a c code block with

Code: Select all

clear_bit(t1con,T1OSCEN);
as explained in the link you posted?

Re: Timer Interrupt in Makro

Posted: Tue Jan 20, 2015 1:51 pm
by DirkB
Hi Martin,

you are right. Interrupt works, but port bits doesn't work. The problem is, port bit works fine without
ADC in flowchart. If activated component ADC in flowchart port bits doesn't works !??
Same problem in Fc5 and FC6! Any idea?

thanks

Dirk

Re: Timer Interrupt in Makro

Posted: Tue Jan 20, 2015 8:10 pm
by medelec35
Hi Dirk,
I believe the issue is with your flowchart rather than a Flwocode bug.
I have just put together a very crude flowchart to show that pot and RA5 works just fine together.

Martin

Re: Timer Interrupt in Makro

Posted: Tue Jan 20, 2015 10:20 pm
by DirkB
Hello Martin,

do you have seen attached flowcharts? Problem is that timer works and flashing LED,
only adding adc in flowchart adc works fine, but timer doesn't works. Deactivating adc
and timer works again. Is it (maybe) a bug in 12F1840 file?

thanks

Dirk

Re: Timer Interrupt in Makro

Posted: Tue Jan 20, 2015 10:28 pm
by medelec35
Hi Dirk,
The attached flowchart on my above post uses both timer 0 interrupt and ADC & works on hardware.
AN1 just alters the speed of the flashing LED connected to RA5.
It looks like issue is with the way you have created your flowchart, And value for ADC just affects the timing by a very short amount you cant see LED Flash duration change.

If you let be know what you want hardware to do, I can see if i can modify your flowchart to suit.

Martin

Re: Timer Interrupt in Makro

Posted: Tue Jan 20, 2015 10:33 pm
by DirkB
Hi martin,

my flowchart only is for testing. Tomorrow I will try another PIC
and see what happen and will inform you.


Dirk

Re: Timer Interrupt in Makro

Posted: Tue Jan 20, 2015 10:39 pm
by medelec35
No problem,
I tried my flowchart on the 12F1840.


Martin

Re: Timer Interrupt in Makro

Posted: Wed Jan 21, 2015 11:53 am
by DirkB
Hi Martin,

it seems problem is, i need timer in loop for continuous count.
Or is it possible to count in other way?


(Update)

The continuous reading of ADC decreases clock. This maybe the problem. ADC generates interrupt.

Code: Select all

16.1.5 INTERRUPTS
The ADC module allows for the ability to generate an interrupt upon completion of an Analog-to-Digital conversion. The ADC Interrupt Flag is the ADIF bit in the PIR1 register. The ADC Interrupt Enable is the ADIE bit in the PIE1 register. The ADIF bit must be cleared in software.
This interrupt can be generated while the device is operating or while in Sleep. If the device is in Sleep, the interrupt will wake-up the device. Upon waking from Sleep, the next instruction following the SLEEP instruc- tion is always executed. If the user is attempting to wake-up from Sleep and resume in-line code execu- tion, the GIE and PEIE bits of the INTCON register must be disabled. If the GIE and PEIE bits of the INTCON register are enabled, execution will switch to the Interrupt Service Routine.
How to work with it, and will that resolve my problem?


Dirk

Re: Timer Interrupt in Makro

Posted: Wed Jan 21, 2015 4:08 pm
by Benj
Hello Dirk,

The custom interrupts allow for this type of functionality.

Use the device datasheet and the info from this wiki page to create your custom interrupt.

http://www.flowcode.co.uk/wiki/index.php ... -_PICmicro

If you get stuck then post what you have so far and we will try to help.

Re: Timer Interrupt in Makro

Posted: Thu Jan 22, 2015 6:05 pm
by DirkB
Hello,

found my problem in decision. Entry was (var = xxx?) and need a little bit too much
precision. this precision was missing with ADC in flowchart.
changing entry to (var >= xxx? or var <= xxx?). now all works fine.

thanks

Dirk

Re: Timer Interrupt in Makro

Posted: Sat Jan 31, 2015 8:51 am
by DirkB
Hello,

and i have learned must enable timer only one time outside flowchart! :mrgreen:

thanks

Dirk