Timer 1 for 12F675

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

bionunu
Posts: 5
Joined: Wed Feb 02, 2011 2:44 pm
Has thanked: 1 time
Contact:

Timer 1 for 12F675

Post by bionunu »

Hello,

I am have Flowcode 4. I am using pic 12F675, I am able to do flashing LED with timer 0. But Timer 1 is not there and also low voltage programming option is not there. I need a C code to blink Led with timer 1. If possible some one please edit pic 12f675.fcd file and add timer 1 and low voltage programming in it.


Thanks.
bio
Attachments
12F675.fcd
(6.22 KiB) Downloaded 653 times

User avatar
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: Timer 1 for 12F675

Post by Benj »

Hello,

Here is a FCD that will enable the timer1 interrupt. Unfortunatley this device does not have the LVP feature.
Attachments
12F675.fcd
(7.34 KiB) Downloaded 667 times

bionunu
Posts: 5
Joined: Wed Feb 02, 2011 2:44 pm
Has thanked: 1 time
Contact:

Re: Timer 1 for 12F675

Post by bionunu »

Benj wrote:Hello,

Here is a FCD that will enable the timer1 interrupt. Unfortunatley this device does not have the LVP feature.

Thanks for fast reply.

bionunu
Posts: 5
Joined: Wed Feb 02, 2011 2:44 pm
Has thanked: 1 time
Contact:

Re: Timer 1 for 12F675

Post by bionunu »

While doing simulation with timer 1 using the new FCD file like blinking LED, the program does not work. only timer 0 is working.

can anybody help me to solve this problem


Thanks

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer 1 for 12F675

Post by medelec35 »

Hi bionunu,
Unfortunately simulator does not simulate timer1 operation, this is a known issue.
Timer1 will work with real hardware.

Martin
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Hello all,
This may be a bit off the course of current topic...nevertheless...
I am also experimenting with 12F675 and found that external interrupt on pin4, which is GPIO3/MCLR, never works right. I am sure it can be done if MCLR is set to internal and so GPIO3 is available as input, it even works in simulator but never in the hardware... :cry:
Even reading from this input (A3) does not work in hardware whereas it does simulate correctly.
Could somebody suggest a workaround or post a customized code that will fix this? :roll:
Thanks in advance.
Best.
Attachments
12F675_exp2.fcf
Created with Flowcode 4.3
(6.5 KiB) Downloaded 500 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Timer 1 for 12F675

Post by dazz »

Hi
Have you tried a blinky program to make sure the hardware works, also how have you wired the switch, is it wired as follows, =5v-resistor-pin3-one side of switch-other side of switch to ground.
I can have a look later as im busy till tonight and then have to play a game of hunt the 8 pin chips as ive got some somewhere just need to find em to try your chart in hardware, looking at your chart you want 2 led's on then switched off via button presses correct ?

as i said i cant help but i wont be until later this evening
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer 1 for 12F675

Post by medelec35 »

Hi, 1Handypal
I have a few comment to make which you many or may not be aware of after looking at your flowchart.

1) LED's are connected at 'Active low'.
This means when output on Flowcode simulator is 0 then LED will light, otherwise LED would be off.
You need to bear in mind that a pin of a microcontroller will default to a high impedance state until a output is reached of your flowchart.
So when you see the LED light, the pin its connected to has gone from a a high impedance state to a 0V output state.

Your hardware must be configured in the same way. So the resistor in series with LED is not connected to the o/p pin of A5 but instead connected to +5V supply. The cathode of LED is connected to the o/p pin of A5 and not the GND.
In effect by not having any high o/p's in your flowchart, you gave got an open drain o/p.

Another thing since you have not stated what hardware your using, then if you are using EB006 you can't just connect port A up a expect to see GP3 (MCLR)
on A3 connection of programmer. This is because MCLR does not interface with any of the physical ports connected to programmer since there could be +14 present during programming of the target device. That won't do any of the 5V peripherals connected to that port any good.

If you have your own switch then you will need to use a pull-up or pull-down resistor, or use weak pull-up integrated within microcontroller.
This would ensure the input is not floating, causing undesirable behaviour when stitch is open circuit.

One last thing. The latest version of Flowcode V4 is 4.5.18.74. So your version is out of date.
You can update by using Help menu and 'Check for updates'

You should really be registered as a V4 Flowcode user.
Take a look at this link.
http://www.matrixmultimedia.com/mmforum ... =29&t=8762

Hope this has helped.

Martin
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Hello all,
@Martin:
Yes, I am not worried about hardware part, it all works correctly and wired properly 100%. What does not work and/or causing me wonders/hair loss is the software.
I am using PICKit2 to load the hex code. The hardware is tiny custom built board for my own experimentation and I am fully aware of 14V being injected as VPP during the programming cycle. This is why nothing important is connected to MCLR, except LED (cathode facing in and anode through resistor from +5V supply rail). The button is wired directly to the pin through a very small limiting resistor to the ground, so when I press the button it lights up the LED connected to pin4 (MCLR/GPIO3).
What I fail to achieve is the availability of pin4 as digital input pin also responding to the high-to-low change in a form of interrupt (as alternative). So while it works in simulation, with the exception of interrupt, it does not in hardware at all. As I mentioned previously MCLR is configured as internal, supposedly taking care of pin4 being available as input.
I am curious about Supplementary code options and any other way that could give control over configurations and modes of the particular micro.
Additionally, I hear you on the registration thing, but thanks, not for now as I am not ready yet to commit any business at this point. Please do not police me as policies do not apply here ;-). All I am trying, accepted or not, is to gain confidence in something I might invest in later if everything works as expected, which would be a fair deal to me.
Appreciate your response and support.
Best.

User avatar
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: Timer 1 for 12F675

Post by Benj »

Hello,
Additionally, I hear you on the registration thing, but thanks, not for now as I am not ready yet to commit any business at this point. Please do not police me as policies do not apply here ;-). All I am trying, accepted or not, is to gain confidence in something I might invest in later if everything works as expected, which would be a fair deal to me.
If you own a license of Flowcode then why not sign up to the forums as a v4 user. It gives us assurance that you have purchased the product rather then downloaded it from a pirate site and therefore means we can spend more time giving you dedicated support. If you sign up to the v4 section then I will do some digging into the problem for you and see if there is an answer to be found.

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

@Ben:
With all due respect, we are on different levels as of the moment. I represent a natural man, you represent a corporation, which is rewarding you for your work.
I totally respect that, we all need to support our families and survive at the end. Honestly if I listened to every salesperson out there and bought every piece of software I ever used, I'd be sure digging my way out of a huge financial hole by now. Fortunately I am not.
You are talking business, as I see. My offer is, I will create some business, in appreciation and support of the product you are offering. But, like I said, I stick to my terms and ways for now. Moreover, my activities are in no way damaging, quite the other way around, because, I think your product has great potential and value and is creating business for users, which I may become one. Right now I am trying to gain confidence and skill.
Sadly, as always, it has bugs and learning curves. So, to summarize my little essay, I am asking a bit of support here without any commitment and/or business involved.
Respectfully to all my brothers and sisters out there, without malice and/or frivolity. All rights and remedies reserved.

Best.

User avatar
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: Timer 1 for 12F675

Post by Benj »

Hello,

Ok I do see your point and will try to provide you with a bit of help.

What interrupt are you trying to trigger from pin 4 of the device?

The timer 1 external input clock pin is pin 2 of the device looking at the datasheet.

Is the problem that you cannot read the state on the input pin from within your program?

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Hello Ben,
The problem seems to be that I can read state of the input of pin4 in simulation, but not in hardware, hence using interrupt will not work either.
The flowchart works in simulation nicely, with the exception of interrupt (if modified to utilize it). I hope it is clear, otherwise please ask any particulars.
And thanks for your willingness to help and co-operate..
Best regards.

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Hello all again,
I tried in vain and reviewed my flowchart, hardware and what else. I still cannot get it to run properly as intended in hardware. Tried inserting ASM lines of code to intitialize registers and configure chip manually - did not succeed. I am clueless what the problem is.
Any experts out there willing to respond constructively?
Thanks.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Timer 1 for 12F675

Post by dazz »

what happens in hardware ? does it just briefly flash the leds or something else,
heres something to try change your Loop from 20 times to until BTN=0 then add in your decision branch underneath your output box add a calculation icon with the following BTN =1 what this will do is force the program to wait until you press the button, switch on your output . then reset the BTN variable to its previous state do this on both loops and the program will only act on your button press . whereas before it looped around and was a bit hit or miss as to when it detected a press, i cant test in hardware yet as i only have some 508's here which boost c doesnt support, and am awaiting some 675's i ordered as soon as they turn up i can test but until then i cant

hth
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer 1 for 12F675

Post by medelec35 »

Hi 1Handypal,
I have found my 12F675 and installed V4.3 and carried out some testing on hardware.

My conclusion is there is no issue with using GP3 as an input.
I used attached Flowchart that I used to test GP3
You could use that for testing your hardware.

My guess its your hardware set-up as stated in a previous post, since when I sent your flowchart to the chip, then LED's did light OK and go back out when I operating switch connected to GP3

The only issue I did find is the file Ben posted does not appear to set ioc register when using port interrupt.
I have altered 12F675.fcd file and got ioc register working. So now port IOC is now working.

You will need to replace 12f675.fcd that's in your Flowcode v4/FCD folder.



Martin
Attachments
12F675GP3 port Test.fcf
(8 KiB) Downloaded 401 times
12F675.fcd
Please use file in later post.
(7.44 KiB) Downloaded 411 times
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Hello Martin,
Great! Thanks for the perfect tip. I have to admit, there was some sort of bizarre accident, that made the SMD resistor (tied to ground from the button) to change value to the point where GP3 was not triggered because of residual voltage on the closed button. I measured and discovered this and so got rid of it all together. Now one side of the button goes straight to ground (have to be careful when programming in circuit not to press any buttons);-).
I still have a small question, if I use interrupt, how do I enable either individual or group pull-ups on port, so I will not have to use any external resistors? Datasheet says if individual pull-ups required, then global GPPU must be enabled. I think that setting pin 6 to be an output with "1" and pressing the button, connected to it and to the GND, will likely toast the output.
I believe It can be configured in ASM box statement, just not sure of proper syntax and format. Could you enlighten me, please?
Best.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer 1 for 12F675

Post by medelec35 »

No problem, at least you found the cause of the issue which is all that matters. Thanks for letting us know.
Re WPU on GP1 (pin 6). Your correct you don't want to short a pin if o/p is accidentally set high. the chip will probably be fried.

Looking at the data sheet you will need the two following commands in a cblock at the start of main:
clear_bit (option_reg, 7); (Data sheet shows a bar above GPPU for OPTION _REG bit 7 = reset to enable weak pull-ups)

wpu=2; (change number so there is a 1 to enalbe WPU for respective pin. E.g WPU on GP0 & GP1 so wpu=3)
I have posted flowchart that enables WPU on pin 6 and included the above text as a reminder.

Martin.
Attachments
12F675GP3 port Test with GP1 WPU.fcf
(8.5 KiB) Downloaded 395 times
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Thank you Martin so much for constructive response. Your help is much appreciated. It is hard to account for all possible options and configuration settings within Flowcode, so learning a bit of C coding and/or Assembly sure helps to fill this void ;-).
As always, the more questions I ask the more come to mind... And, since we are talking about this particular chip, could you tell on how to enable sleep mode and wake on interrupt? I would be interested to know if there is an elegant way within Flowcode to achieve this, additionally to set up a pre-determined time to go into power saving mode.
I also noticed that not all chips are supported even with the latest V5. Is there a way to create/edit/re-name existing configuration files to introduce a new chip into menu?
I definitely need a good resource to study syntax and format of writing custom C boxes... to stop bugging people of this forum with silly questions :D
Thanks again!
Best.

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Hello again,
@Martin:
A little correction here. Somehow, when I tested interrupts, the compiler would not compile and complain about missing semicolon (112 or 119, not sure what this means, possibly line in the code) if all interrupts are masked out except GP3. The same chart would compile fine if INT on GP3 port is OFF. I believe this was something to do with the 12F675 config file you supplied, since I replaced the original with it.
Also, I was unable to see any pull up effect by using the C Code box. Can binary be used in place of decimal in a format like:
wpu=0b111111; ?
Could you double check, please?
Thanks.
Best.

User avatar
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: Timer 1 for 12F675

Post by Benj »

Hello,

This should work correctly but I think you need 8-digits after the 0b instead of 6.

wpu=0b11111100;

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer 1 for 12F675

Post by medelec35 »

Hi 1Handypal,
1Handypal wrote: I tested interrupts, the compiler would not compile and complain about missing semicolon (112 or 119, not sure what this means, possibly line in the code)
Yes it is my mistake, sorry about that.
I did a search an replace, and that caused an issue with some of the IOC sections.
So the semicolon is due to IOC and not weak pull-ups register.

Here is a corrected file for you, which should work a lot better.
After replacing file, If Flowcode is already open you will need to close and re-open.

Martin
Attachments
12F675.fcd
(7.14 KiB) Downloaded 384 times
Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer 1 for 12F675

Post by medelec35 »

Hi forgot to mention:
As for weak pull-ups. As you probably be aware, if pin is set as an o/p then WPU will be automatically disabled for that pin.

Also WPU is not available for GP3, So you will require a pull-up resistor its that's the port your referring to

I have tested for WPU an that does appear to be working OK.

Martin
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Has thanked: 8 times
Contact:

Re: Timer 1 for 12F675

Post by 1Handypal »

Hello all,
@Martin:
Thank you. I will test this out tonight, if my little one spares me some time to do it...;-)
@Ben: Thanks for pointing this out. I believe binary looks more readable and visually appealing. One question here, do the MSB relate to the the highest port#, and, since there's only six, two of the MSB are not implemented, but need to be shown as 1s or 0s? So if I blindly enable all, then whichever ports are set to outputs will be automatically omitted, respectively pull-ups disabled, correct?
I still have one question unanswered, which would be great to have an answer to. If I do not see a chip in the list of supported, when starting a project, how do I make it happen, or is there a way to duplicate/edit/customize existing descriptor file?
Thanks again.

User avatar
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: Timer 1 for 12F675

Post by Benj »

Hello,
One question here, do the MSB relate to the the highest port#, and, since there's only six, two of the MSB are not implemented, but need to be shown as 1s or 0s? So if I blindly enable all, then whichever ports are set to outputs will be automatically omitted, respectively pull-ups disabled, correct?
Yes that's right the upper two bits will be effectively ignored by the chip as there are no I/O connected to these pins.
If I do not see a chip in the list of supported, when starting a project, how do I make it happen, or is there a way to duplicate/edit/customize existing descriptor file?
Let us know which device your after and we can always see how tricky it is to generate the definition file for you. The main limiting factor is the chip support in the compiler.

Post Reply