Good evening all.
I appear to have encountered a strange problem with the PIC16F690. I wrote some simple code for this device a couple of years ago while using Flowcode v5. This code utilises the PWM output and changes the frequency based on some inputs. The code has always worked well both in simulation and when uploaded to a PIC via PICkit2.
I now run Flowcode v6 and recently went to make a quick change to the code but when I uploaded it, the device did nothing. I went back to the original code and keeping all aspects identical, including configuration options, I could still not successfully upload it to the device.
I do not believe that this is due to compiler settings as I am able to successfully program other device such as the PIC16F88. Is there perhaps some difference in the implementation of the PWM aspect between v5 and v6?
The code is attached.
Regards,
Dick Miller
PIC16F690 issues
Moderator: Benj
-
- Posts: 13
- Joined: Thu Mar 15, 2012 12:14 pm
- Has thanked: 2 times
- Been thanked: 4 times
- Contact:
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PIC16F690 issues
Hi Dick,
The watchdog timer within configuration settings is set to enabled.
Can you set it to disabled.
Also have you got pin4 (MCLR) conneted to a pull-up resistor or +5V line.
If no then you have to set MCLR within configuration settings is set to disabled.
You don't want to keep triggering INT constantly.
Place INT at the very start so only accessed once.
There are other issues with flowchart, but ran out of time.
Will post about it a bit later.
Martin
The watchdog timer within configuration settings is set to enabled.
Can you set it to disabled.
Also have you got pin4 (MCLR) conneted to a pull-up resistor or +5V line.
If no then you have to set MCLR within configuration settings is set to disabled.
You don't want to keep triggering INT constantly.
Place INT at the very start so only accessed once.
There are other issues with flowchart, but ran out of time.
Will post about it a bit later.
Martin
Martin
-
- Posts: 13
- Joined: Thu Mar 15, 2012 12:14 pm
- Has thanked: 2 times
- Been thanked: 4 times
- Contact:
Re: PIC16F690 issues
Hi Martin,
Thanks for the reply.
Yes, I can confirm that MCLR is pulled high, so that shouldn't be the issue. I will have a go in the morning re disabling the watchdog timer and moving the INT call.
However, The thing that is still really confusing me is that this code (despite its faults) worked well when compiled and uploaded from Flowcode v5, but won't do so from Flowcode v6. Note, that I don't get any error messages from compilation or programming, but the finished PIC simply sits there and does nothing...
I still have the hex file I generated from v5 and can continue to use that, but I can't make any changes to the program.
Cheers, Dick.
Thanks for the reply.
Yes, I can confirm that MCLR is pulled high, so that shouldn't be the issue. I will have a go in the morning re disabling the watchdog timer and moving the INT call.
However, The thing that is still really confusing me is that this code (despite its faults) worked well when compiled and uploaded from Flowcode v5, but won't do so from Flowcode v6. Note, that I don't get any error messages from compilation or programming, but the finished PIC simply sits there and does nothing...
I still have the hex file I generated from v5 and can continue to use that, but I can't make any changes to the program.
Cheers, Dick.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PIC16F690 issues
Hi Dick,
There is a PWM bug and the fix can be found here
You will need that fix to get PWM to work.
I have made some changes to your program
Martin
There is a PWM bug and the fix can be found here
You will need that fix to get PWM to work.
I have made some changes to your program
Martin
- Attachments
-
- Relay Unit v2-1b_21kHz_v6.fcfx
- (12.35 KiB) Downloaded 290 times
Martin
-
- Posts: 13
- Joined: Thu Mar 15, 2012 12:14 pm
- Has thanked: 2 times
- Been thanked: 4 times
- Contact:
Re: PIC16F690 issues
Good morning Martin,
Thank you for the link on the PWM bug. That may well be my main issue.
Also, massive thanks for the changes to my code. I'm fascinated by the way you have removed the INT routine and used the "if input = previous input" to constantly monitor the line and achieve the same result. I also like the way that you don't regularly enable and disable the PWM, but instead simply change the duty cycle from 0 to the required value. Really clever!
I guess hardware engineers like myself just haven't got the right mindset to write code!
I will try everything later today and let you know how I get on.
Regards, Dick
Thank you for the link on the PWM bug. That may well be my main issue.
Also, massive thanks for the changes to my code. I'm fascinated by the way you have removed the INT routine and used the "if input = previous input" to constantly monitor the line and achieve the same result. I also like the way that you don't regularly enable and disable the PWM, but instead simply change the duty cycle from 0 to the required value. Really clever!
I guess hardware engineers like myself just haven't got the right mindset to write code!
I will try everything later today and let you know how I get on.
Regards, Dick
-
- Posts: 13
- Joined: Thu Mar 15, 2012 12:14 pm
- Has thanked: 2 times
- Been thanked: 4 times
- Contact:
Re: PIC16F690 issues
Hello again Martin.
Everything is now perfect! Thank you so much for your help. It really is appreciated.
Best regards, Dick
Everything is now perfect! Thank you so much for your help. It really is appreciated.
Best regards, Dick
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PIC16F690 issues
Hi Dick,
Your welcome.
I have made some more changes so not only can you use Pin A2 interrupt, but I have also added 50ms switch debouncing using a timer interrupt (Relay Unit v2-1c_21kHz_v6.fcfx), and a more efficient version using only ReadState (Relay Unit v2-1d_21kHz_v6.fcfx).
Note Debounce in the latter is set by the switch properties.
I have also changed the way you select the duty and period from start up.
I have created the flowcharts for you to either use for hardware or educational purposes.
If it was me I would use Relay Unit v2-1d_21kHz_v6.fcfx
Martin
Your welcome.
I have made some more changes so not only can you use Pin A2 interrupt, but I have also added 50ms switch debouncing using a timer interrupt (Relay Unit v2-1c_21kHz_v6.fcfx), and a more efficient version using only ReadState (Relay Unit v2-1d_21kHz_v6.fcfx).
Note Debounce in the latter is set by the switch properties.
I have also changed the way you select the duty and period from start up.
I have created the flowcharts for you to either use for hardware or educational purposes.
If it was me I would use Relay Unit v2-1d_21kHz_v6.fcfx
Martin
- Attachments
-
- Relay Unit v2-1d_21kHz_v6.fcfx
- (12.16 KiB) Downloaded 273 times
-
- Relay Unit v2-1c_21kHz_v6.fcfx
- (13.93 KiB) Downloaded 288 times
Martin
-
- Posts: 13
- Joined: Thu Mar 15, 2012 12:14 pm
- Has thanked: 2 times
- Been thanked: 4 times
- Contact:
Re: PIC16F690 issues
Hi Martin,
Educational purposes is right; you seem to have taught me more in a couple of example codes than I've learned in a couple of years of occasional playing around with Flowcode. The timer interrupt is something I was just about to start utilising for another project, so your example gives me a good head start on that as well.
Regards,
Dick
Educational purposes is right; you seem to have taught me more in a couple of example codes than I've learned in a couple of years of occasional playing around with Flowcode. The timer interrupt is something I was just about to start utilising for another project, so your example gives me a good head start on that as well.
Regards,
Dick
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact: