Timing issues using HitechC as a compiler

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
MW
Posts: 38
Joined: Mon Feb 26, 2007 2:04 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Timing issues using HitechC as a compiler

Post by MW »

Hi,

I have developed an application in Flowcode, set to the default compiler options, utilising a 16F876 and an external 20MHz oscillator. This application relies on reasonably accurate timing and it is working well. By reasonably accurate I mean that the delay icons have been sufficient.

I am now attempting to port it to a 16F1936 utilising the internal oscillator and HitechC as the compiler. The program compiled and programmed as expected but the application didn't work.

As a fault finding measure I programmed the device to output a square wave on the C port, high for 1 second then low for 1 second. The oscillator was set to INTOSC and the clock speed in project options was set to 20MHz. This resulted in the C port going high for around 5 seconds and then low for 5. I then found that be changing nothing but the clock speed (which I lowered) the output got closer to what I expected but still nothing like 1 second pulses . Using another chip and the default BoostC the delays times seem to be accurate irrespective of the clock speed.

Is there an issue with the delay function when using HitechC and if so can you reccomend a work around?

Thanks as always
MW

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: Timing issues using HitechC as a compiler

Post by medelec35 »

I believe these chips will require a C box with OSCCON set for correct internal osc speed I think it will be osccon = 0x3E;. Only problem is the max internal osc speed is 16MHz. So the clock speed in flowcode must also be set for 16MHz, not 20 MHz hence timing issues. So I'm surprised the timing was correct with boostc. Maybe best to look at datasheet to confirm details, As I could be wrong.
Martin

MW
Posts: 38
Joined: Mon Feb 26, 2007 2:04 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: Timing issues using HitechC as a compiler

Post by MW »

You are right on all counts and as a result I have things working well now @ 8MHz.

Thanks very much and apologies for the late response, I have been off line for a bit.

MW

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: Timing issues using HitechC as a compiler

Post by medelec35 »

Your welcome, and glad you have successfully got your application working 8) .
Martin

Post Reply