Timer problem with 16F877

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Has thanked: 3 times
Been thanked: 3 times
Contact:

Timer problem with 16F877

Post by cobra1 »

Hi

Im having a bit of a problem with the timer on the 16f877.

i have an old project i built with using the 16f877 and used the timer for a built in clock function. I used a 4x20 display. This worked perfectly.

This time round im using a ks0108 type LCD, and i cant get the timer to work correctly (if at all)

Basically whats happening is when the timer should start to count it scrambles the LCD display, it looks like the text has been typed over and over(text overlapping and random pixelation) then the program appears to stop and is unresponsive to any buttons or sensors.
This happens without the timer actually doing anything, just trying to activate it causes this problem, without the timer the program runs flawlessly.

I am wondering if any external pin connections can cause a problem??
If not is there anything else i can try because i could really do with the timer being active in my project.

Any help is appreciated.

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: Timer problem with 16F877

Post by medelec35 »

Hiya cobra1.
Sounds like it could be a stack issue?
Compile your code and look out for warnings like:
Serious Warning: Call stack usage exceeds:8!
Or
Serious Warning: Possible sw stack corruption
If you do get a warning it will help to seer in the right direction.

Could the port connected to display be controlled by a different routine?
If you are using the same flowchart for both devices and one only works, then that’s unlikely.
Martin

cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: Timer problem with 16F877

Post by cobra1 »

Ok im making progress

i have narrowed it downt to the PRINT NUMBER function

if the timer is running and i use the PRINT NUMBER function, the program jams up.
if the timer is not running all is good, i can use the timer with any other function in the LCD list apart from PRINT NUMBER

Guessing there is a clash somewhere.

there is no serious warnings etc

cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: Timer problem with 16F877

Post by cobra1 »

ok, more progress

it seems that there is an interupt used in the print number function, this interupt must be clashing with the timer0 interupt.

if i disable the timer interupt just before using the print number function then all works well. but i cannot have the timer just running continuously while the print number function is being used.

Is this normal or can t be fixed??

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 problem with 16F877

Post by Benj »

Hello,

It could be simply that the print number function uses all of the layers of the hardware stack due to the nature of the way the code was written. Probably aimed at code size rather then stack efficiency. You should be able to enable the software stack which will allow you to carry on using the interrupt while the print number routine is running.

http://www.matrixmultimedia.com/mmforum ... =21&t=6356

Post Reply