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: 97
Joined: Fri Oct 10, 2014 11:15 am
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 84 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8873
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Dave Squibb
Flowcode v5 User
Posts: 97
Joined: Fri Oct 10, 2014 11:15 am
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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8873
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Post Reply