LED DISPLAY REFRESH AND TMR0

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times

LED DISPLAY REFRESH AND TMR0

Post by PIC-ER »

Hello Guys,
I have built a circuit in which an output is switched on at the press of a button. The on/off rate of this out put is settable. At the same time i have a counter display the count every time the output comes on. I use a TMR0 for this. At lower output rates the count is accurate, at higher rates the count displayed on the 3 digit 7 Segment display goes crazy.
i have read every thread in these forums on this case , but am still unable to fix this problem. i have also tried different clock speeds and prescaler rates to no avail.
Any help to fix this is much appreciated.

Thanks,
PIC-ER
Attachments
7seg4-display refresh.fcf
(61.49 KiB) Downloaded 315 times
Last edited by PIC-ER on Fri Jan 25, 2013 11:00 pm, edited 1 time in total.

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: ANYONE ??LED DISPLAY REFRESH AND TMR0

Post by Benj »

Hello,

I think you need to call the clear seg macro before you call another show digit macro. So you need to do something like this.

showseg0

clearseg0
showseg1

clearseg1
showseg2

As part of the main Flowcode examples download there should be some good examples of how to drive the 7-seg displays using a timer interrupt.

PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times

Re: ANYONE ??LED DISPLAY REFRESH AND TMR0

Post by PIC-ER »

Hi Benj,
Thanks for the reply . Had already tried that, even put in a dwell between each one.
All credit to Medelec he caught it. I had a MOD in the interrupt macro.

Thanks to all,
Regards,
PIC-ER

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

Re: ANYONE ??LED DISPLAY REFRESH AND TMR0

Post by medelec35 »

Best to treat MOD as you would with delays.
If you have MOD in any of you macros including Main:
If MOD is then placed within an interrupt macro, corruption will occur.
It might be best to avoid MOD in interrupt macros altogether (even if not using MOD anywhere else)

Martin
Martin

Post Reply