CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

have an problem with unsigned integer division

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mthornton



Joined: 22 Jan 2008
Posts: 4
Location: Canal Flats BC

View user's profile Send private message

have an problem with unsigned integer division
PostPosted: Fri Aug 29, 2008 10:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 29, 2008 11:50 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 02, 2008 7:44 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group