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
Timing issues using HitechC as a compiler
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Timing issues using HitechC as a compiler
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
Re: Timing issues using HitechC as a compiler
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
Thanks very much and apologies for the late response, I have been off line for a bit.
MW
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Timing issues using HitechC as a compiler
Your welcome, and glad you have successfully got your application working
.

Martin