Page 1 of 1

Interrupt and PWM PIC12F615

Posted: Fri May 04, 2012 2:24 pm
by oookey
Hi Ben,

I have got my Flowcode alive, thanks. <img class="exp_link_class" title="Generated by Expresso" alt="Generated by Expresso" style="float:none;pointer;height:19px;width:25px;" src="http://dpxv6nn9fphpz.cloudfront.net/v5/ ... ah02x3.gif">

I try to program the 12F615, but I don’t see port A nor port B, instead GP0 thru GP5, so how do I make GP1 as an input interrupt to trigger PWM signal output at GP2? I’m using FC3.

Attached my FC and portion of datasheet.

Thanks for your time.

oookey

Re: Interrupt and PWM PIC12F615

Posted: Fri May 04, 2012 10:28 pm
by medelec35
Hi oookey
I have modifed your flowchart and it works well without any alterations with FC5.
However is does not work with FC3 or FC4.

So there is probably a bug in FC3 & FC4 that has been fixed in Flowcode5.

If I get a chance I will see if I can look at why there is an issue with FC3, no promises though.

I have also move this to V3 section where it is more relevant.

Martin

Re: Interrupt and PWM PIC12F615

Posted: Fri May 04, 2012 11:24 pm
by medelec35
I found the problem.
The IOC is not being set with a value of 2, so all IOC's are disabled.
Attached flowchart has been tested on a 12F615 and works as intended.

Martin

Re: Interrupt and PWM PIC12F615

Posted: Sat May 05, 2012 5:48 am
by oookey
Hi Martin,

Thanks a lot your time. <img class="exp_link_class" title="Generated by Expresso" alt="Generated by Expresso" style="float:none;pointer;height:19px;width:25px;" src="http://dpxv6nn9fphpz.cloudfront.net/v5/ ... ah02x3.gif">

I tried running both of your attached, however it just looping itself inside the while loop, even toggle ON/OFF A1, the interrupt unable to call out the subroutine, may be I'm stretching too far for FC3 using this chip. <img class="exp_link_class" title="Generated by Expresso" alt="Generated by Expresso" style="float:none;pointer;height:19px;width:25px;" src="http://dpxv6nn9fphpz.cloudfront.net/v5/ ... /sadx3.gif">
But why is the “interrupt – enable port change” out of the while loop instead the “decision of change” is within the loop? Wouldn’t the chip work faster if only the “interrupt-enable port change” is within the while-loop, remove the “decision of change” routine out?

Thanks

oooky

Re: Interrupt and PWM PIC12F615

Posted: Sat May 05, 2012 9:48 am
by medelec35
Hi oooky,

The 1st flowchart I posted is suppose to work but it does not because of a bug in Flowcode V3 as explained.

One important thing I should have mentioned:
With 12F series the IOC will only simulate with Flowcode V5.
Since FC3 support is stopping soon (start of June) FC5 is a definitely a well worth investment.

So with Flowcode V3 and V4 if you activate the switch, nothing will happen. That's only a simulation fault.

I can guarantee 100% it does work with a real 12F615, as I have got the hardware set up on my Matrix protostation.

So If yours is not working you will need to look at the programming and hardware setup.

It looks like you have posted some images, but they are not showing up.

Just click the 'Upload attachment' tab, Click 'Choose File' browse to the image, click 'Open' then click 'Add the file'

The second flowchart I posted overcomes the bug.
oookey wrote: But why is the “interrupt – enable port change” out of the while loop instead the “decision of change” is within the loop? Wouldn’t the chip work faster if only the “interrupt-enable port change” is within the while-loop, remove the “decision of change” routine out?
No, interrupts are not used that way.

The interrupt is enabled only once. (unless you disable interrupt, then you will have to re-enable it!)
So the interrupts are only enabled at the beginning of the flowchart before the main loop.

Each time A1 changes state (either low to high, or high to low) then the interrupt macro is accessed.
There is a decision branch within the interrupt to ignore if switch has gone from high to low, otherwise count will increment twice each time switch is pressed then released.

The reason the decision branch is within main loop is because you can't place a PWM macro component in the interrupt and also within any other macro, including Main.
If you are not going to add any more PWM components then you can change your flowchart to this:
12F615.png
(109.22 KiB) Downloaded 7068 times
It will still work on hardware.
oookey wrote:may be I'm stretching too far for FC3 using this chip.
No it's not stretching FC3 at all!
However If your creating any flowcharts that involve IOC then you must use a C block with ioc=x;
Where x is the value for required GP pin.
Or if you find it eaiser use binary.
So for GP2 use:

Code: Select all

ioc=0b10;
For GP5 and GP2 for example use:

Code: Select all

ioc=0b10010;


Martin

Re: Interrupt and PWM PIC12F615

Posted: Sat May 05, 2012 1:30 pm
by medelec35
I have got a fix for 12F615 IOC.
The fix will enable you to select individual IOC pins:
12F615_IOC Fixed.png
(144.09 KiB) Downloaded 7060 times
Also this fix will enable you to select timer1 interrupt when required.
The C code

Code: Select all

ioc=2;
can now be removed.
To apply fix just find 12F615.fcd in C:\Program Files\Matrix Multimedia\Flowcode V3\fcd
If 32 bit windows
or
C:\Program Files (x86)\Matrix Multimedia\Flowcode V3\fcd\
If 64 bit windows
and replace with attached file.

The attached flowchart is the final working version, using IOC selectable function.

Note: Fix does not fix simulation!

Martn

Re: Interrupt and PWM PIC12F615

Posted: Fri May 18, 2012 12:03 pm
by jamesf10
hi, i was wondering could you send me a picture of the schematic required for this PWM code using the PIC12F615? It would be appreciated,
thanks,
jamesf10