16F883 Timer 1 problem

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

Post Reply
bwynne
Posts: 6
Joined: Sat May 08, 2010 10:27 pm
Contact:

16F883 Timer 1 problem

Post by bwynne »

Hello, please can you help me.
I have attached my flowcode 4 file that i cant get to work with timer1.
I am trying to initialise timer1 to be free running, then read timer 1 value and make it into an integer ( SHORT ) value, then use an If statement to check if it has exceeded a value.
I have not had any luck so far ! please can you help.Attachments
inj_drive1b.fcf
Attachments
inj_drive1b.fcf
(6 KiB) Downloaded 289 times

medelec35
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: 16F883 Timer 1 problem

Post by medelec35 »

Hello bwynne.
The problem is with your configuration settings which cam be accessed via 'Chip', 'Configure...' menu. then 'switch to Expert Config Screen'
I have changed watchdog to off (since was switched on, with no clear watchdog commands your program would be permanently resetting if osc type was correct)
Osc type to HS,
Disabled low voltage programming.
Now to your coding.
After changing your settings, program is working OK.
Leaving timer 1 with the settings you have, means timer increments by 1 approx every 1.63uS. so 1.63 x10-6 x 8000 = 13ms therefore C5 will toggle every 13mS, so it will look like port is permanently on, since frequency is approx 1/(13x10-3 * 2) = 38 HZ

Is there a reason your not using the interrupt components, then putting the decision branch within the interrupt macro?
I am asking because it is so much easier than C.
But if you want to keep using C, or leaning C then I can totally understand.

Another thing, I noticed that you will need to activate your license. When you do that it is best to right click on Flowcode and Run as administrator.

Also you are using 16F883 target. They are good value for money since have two pwm channels and EEPROM etc, but thet can be very fussy when programming. A few time after I send program to chip, I get a 'cannot ID target' (it is much more fussy with pickit2, if you want a good ICSP, then Asix presto programs those chips 100% first time)
Hope this helps.
Attachments
inj_drive1b_Modidfied.fcf
(6 KiB) Downloaded 286 times
Martin

bwynne
Posts: 6
Joined: Sat May 08, 2010 10:27 pm
Contact:

Re: 16F883 Timer 1 problem

Post by bwynne »

hello medelec35,
Many thanks for your help.
I have still not managed to get the software to compile the code !

Please see the error below:
File name: C:\Users\barry\inj_drive1b_Modidfied.c
Generated by: Flowcode v4.2.3.58
Date: Monday, August 02, 2010 23:07:54
Licence: Professional

***UNREGISTERED***


http://www.matrixmultimedia.com


Launching the compiler...
C:\Program Files\Matrix Multimedia\Flowcode V4\BoostC\boostc.pic16.flowcode.exe -v -t PIC16F883 "inj_drive1b_Modidfied.c"
BoostC Optimizing C Compiler Version 6.95 (for PIC16 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2009 Pavel Baranov
Copyright(C) 2004-2009 David Hobday

Compiler can not be started without a host program (code 120)


Return code = 120

Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.

FINISHED


I have run in admin mode, and also tried to register my professional version of flowcode 4, without sucess.

The flowcode security seems to be very tight and difficult to enable your code even though you have bought the software from Matrix !

i a just getting frustrated !

i have a working Diesel injector software that i wrote in C. I need to convert it to flowcode 4 !

Best Regards
Barry.

medelec35
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: 16F883 Timer 1 problem

Post by medelec35 »

Hello Barry. it compiled for me ok, and was running it on my EB006 programmer.

I did get same error as you once. Re-booted pc, and then worked ok form then on.

You tried re-booting?

I believe you only get a temporary time limited code sent until actual full normal code arrives, maybe your passed the date deadline.
If benj or steve at matrix read this then hopefully they would be able to assist you further.

I have downloaded the attachment just to check, and it compiles with no errors.
I have attached the hex code for you to upload to chip, not sure if you will find it helpful.
Hope it gets sorted soon.
Attachments
inj_drive1b_Modidfied from dl.hex
(1.01 KiB) Downloaded 259 times
Martin

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: 16F883 Timer 1 problem

Post by DavidA »

Hello Barry,

Could you either PM me or fill out a web contact form here:

http://www.matrixmultimedia.com/contact2.php

So I can help you with this via email.

bwynne
Posts: 6
Joined: Sat May 08, 2010 10:27 pm
Contact:

Re: 16F883 Timer 1 problem

Post by bwynne »

Hello medelec35 ,
i finallty managed to register my flowcode 4, and compile correctly .
My target system, is a Diesel Injector Drive PCB, that i designed. I have working C code, that i wrote and download and run OK, using my ICD2 from microchip.

The Flowcode 4 exapmple, that you have looked at, i have now compiler OK to Hex and then programmed with my ICD2, BUT it does not appear to run on my target. ( swap to my C code, and all runs OK ).

The flowcode 4, does not seem to have simulation support for the timer1 ?

Also, there is a problem with the 16F883 part, please see attached note from Microchip. My PCB is OK with this microchip errata.

Not sure why i cannot run the software on my target ?

Barry
Attachments
16f883 debug errata.txt
(5.8 KiB) Downloaded 265 times

medelec35
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: 16F883 Timer 1 problem

Post by medelec35 »

medelec35 wrote: but thet can be very fussy when programming. A few time after I send program to chip, I get a 'cannot ID target' (it is much more fussy with pickit2, if you want a good ICSP, then Asix presto programs those chips 100% first time)
Hope this helps.
I have raised a ticket with microchip out using there PICkit programmer (and other programmers including EB006) not able to successfully program these chips. After a while you think the chip is damaged due to constantly not recognising target etc, but then when use presto programmer it then always programs. If it does not program then I would assume there would be a problem running ICD.
you are correct about Timer 2 not simulating, it can be a headache. Normally I would suggest ICD with EB006, bit if target not recognised you will struggle. Only other thing i can suggest is to compile to hex and use a different simulator.

Re: Flowcode version not running. Would you like to post verison not working, along with the hex file?

@Wizards in Matrix Multimedia. Not blaming programmer since it programs all other chips without any issues and pickit2 has same problem. Would you have any ideas on getting around this please?
I have read pulling RB3 down via 10K resistor could solve issue, but does not.
Thank you
Martin

medelec35
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: 16F883 Timer 1 problem

Post by medelec35 »

Thank you bwynne.
What you have posted is very useful information, and I have forward it on to microchip.
With the 16F883, if you use internal osc, then it does not go into programming mode with some programmers, if MCLR is not external!
Any luck with running your code?
Martin

medelec35
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: 16F883 Timer 1 problem

Post by medelec35 »

Update:
Received a message from Microchip
Yes internal MCLR and internal OSC is a known issue with some of the Microchip programmers. Personally I don't know why some programmers have the limitation and others don't. So from that point of view I can send a request to the development tools group to update the firmware, if possible. The problem is I think the priority will be for newer tools such as PICKit3 so I wouldn't expect a quick fix for PICKit2. The current "workaround" for using internal MCLR and internal OSC is to place a delay at the start of the code, approx. 20ms. For example you will probably notice if you program in the config settings only with program memory blank you will not see the issue.
The worst offender is PICkit 2. This problem can also show with EB0006.

Not had anymore programming issues since added delay before OSCCON, so fix appears to work sofar.
Martin

Post Reply