Problem with ULONG variable?

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

Moderator: Benj

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

Problem with ULONG variable?

Postby Dave Squibb » Mon Jun 29, 2015 10:21 am

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 63 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Problem with ULONG variable?

Postby medelec35 » Mon Jun 29, 2015 10:47 am

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.
These users thanked the author medelec35 for the post (total 3):
Dave Squibb (Mon Jun 29, 2015 11:02 am) • LeighM (Mon Jun 29, 2015 1:12 pm) • Benj (Tue Jun 30, 2015 9:37 am)
Rating: 15.79%
 
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
Has thanked: 27 times
Been thanked: 22 times
Contact:

Re: Problem with ULONG variable?

Postby Dave Squibb » Mon Jun 29, 2015 11:07 am

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: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Problem with ULONG variable?

Postby medelec35 » Mon Jun 29, 2015 10:37 pm

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.