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
Interrupt and PWM PIC12F615
Interrupt and PWM PIC12F615
- Attachments
-
- Datasheet-12f615.pdf
- (75.5 KiB) Downloaded 491 times
-
- 12F615_PWM.fcf
- (9 KiB) Downloaded 573 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Interrupt and PWM PIC12F615
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
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
- Attachments
-
- 12F615_PWM1.fcf
- (9.5 KiB) Downloaded 553 times
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Interrupt and PWM PIC12F615
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
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
- Attachments
-
- 12F615_PWM1.fcf
- (13.5 KiB) Downloaded 521 times
Martin
Re: Interrupt and PWM PIC12F615
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Interrupt and PWM PIC12F615
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.
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: It will still work on hardware.
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:
For GP5 and GP2 for example use:
Martin
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.
No, interrupts are not used that way.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?
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: It will still work on hardware.
No it's not stretching FC3 at all!oookey wrote:may be I'm stretching too far for FC3 using this chip.
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;
Code: Select all
ioc=0b10010;
Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Interrupt and PWM PIC12F615
I have got a fix for 12F615 IOC.
The fix will enable you to select individual IOC pins: Also this fix will enable you to select timer1 interrupt when required.
The C code 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
The fix will enable you to select individual IOC pins: Also this fix will enable you to select timer1 interrupt when required.
The C code
Code: Select all
ioc=2;
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
- Attachments
-
- 12F615.fcd
- (6.61 KiB) Downloaded 524 times
-
- 12F615_IOC.fcf
- (13.5 KiB) Downloaded 494 times
Martin
Re: Interrupt and PWM PIC12F615
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
thanks,
jamesf10