Joined: 22 Jan 2008 Posts: 4 Location: Canal Flats BC
have an problem with unsigned integer division
Posted: Fri Aug 29, 2008 10:54 pm
I have an issue with unsigned integer division, using a 16F88, job is a frequency generator.
problems with the result in half_period
frequency is a value from 1-1000, determined from a scan of bcd switches.
it works fine so long as freq is <256, then it messes up.
unsigned int16 freq;
unsigned int32 half_period
half_period = 500000/freq;
help!
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Fri Aug 29, 2008 11:50 pm
Show the printf statement that you're using to display the result.
Post your compiler version.
mthornton
Joined: 22 Jan 2008 Posts: 4 Location: Canal Flats BC
Posted: Tue Sep 02, 2008 7:44 am
Compiler version : PCM 3.241
didn't use a printf statements, as the output is the signal out
I found the problem, which was my misunderstanding of the type conversion in the routine used to create the "frequency" variable (unsigned 16 bit) from 3 - 8-bit bcd switches. Won't get bitten by this again.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum