Problem with ULONG variable?

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

Moderator: Benj

Post Reply
Dave Squibb
Flowcode v5 User
Posts: 104
Joined: Fri Oct 10, 2014 11:15 am
Has thanked: 27 times
Been thanked: 22 times
Contact:

Problem with ULONG variable?

Post by Dave Squibb »

Hi all,

I have a simple program which counts pulses on PORTB,0 (using the interrupt) and outputs the count to an LCD via a variable Count1. Count1 is set as type ULONG. However, when the count reaches 32768 it rolls over to -32768 and counts downwards. In the C code the definition is MX_GLOBAL MX_UINT32 FCV_COUNT1 = (0x0);

Code attached,

Thanks,

Dave
Attachments
PulseCounter.fcfx
(5.6 KiB) Downloaded 186 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: Problem with ULONG variable?

Post by medelec35 »

Hi Dave.
Instead of using LCD PrintNumber
Use LCD PrintFormattedNumber.
You will also need to enter 1 in the Format for unsigned Number.
You may also require a small delay within main loop.

Martin.
Martin

Dave Squibb
Flowcode v5 User
Posts: 104
Joined: Fri Oct 10, 2014 11:15 am
Has thanked: 27 times
Been thanked: 22 times
Contact:

Re: Problem with ULONG variable?

Post by Dave Squibb »

medelec35 wrote:Hi Dave.
Instead of using LCD PrintNumber
Use LCD PrintFormattedNumber.
You will also need to enter 1 in the Format for unsigned Number.
You may also require a small delay within main loop.

Martin.
Hi Martin,

All now working fine.Thanks once again for your invaluable help.

Dave.

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: Problem with ULONG variable?

Post by medelec35 »

Your welcome Dave.
Glad all is working as expected.

Thanks for letting us know.

Martin
Martin

Post Reply