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 CCS Technical Support

LOG10 library function problem

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



Joined: 12 Feb 2007
Posts: 2

View user's profile Send private message

LOG10 library function problem
PostPosted: Mon Feb 12, 2007 3:48 pm     Reply with quote

Hi all - I have done some C programming a while ago, so I combined my
interests in PICs with some exercises to refresh C in my mind as well as
hopefully allow me to do some things I would like to with PICs.

All has gone well (several working projects - simple but working) _UNTIL_
I sez self why don't you add a 'simple' calculation of dB(W) to that
display? I can't seem to get it (log10())to do the most basic of
calculations. I get WILDly errant answers. Here's the latest (boiled down
to DEAD simple): The display output follows.

MPLAB 7.51
CCS C PCM 4.023
PIC16F877
ICD2 (as programmer)
Development board - DHMicro 40pin generic breadboard

Code sample:

#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)

#include <math.h>
#include <lcd.c>


void main() {
float fwd, pf;

lcd_init();

while(TRUE)
{
pf = 120.0;
fwd = log10(pf);

lcd_gotoxy(1,1);
printf(lcd_putc,"%3.0g lg%7.3g",pf, fwd);
delay_ms(50);

pf = 10.0;
fwd = log10(pf);
printf(lcd_putc,"\n%3.0g lg%7.3g",pf, fwd);
delay_ms(50);

}
}

LCD Display shows (16X2):

120 lg 0.172
10 lg -32.942

The LCD is a generic 16X2 that I have been using successfully for a while.
(it seems to work fine with the 'canned' driver)

I searched the forem and couldn't find anyone else complaining that the
log() or LOG10() is completely busted so I'm sure its me! I can't see what
I'm doin wrong to save me... PLEASE help!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 12, 2007 4:06 pm     Reply with quote

Here is a thread on it. This one will help:
http://www.ccsinfo.com/forum/viewtopic.php?t=29740&highlight=log
aclamb



Joined: 12 Feb 2007
Posts: 2

View user's profile Send private message

PostPosted: Mon Feb 12, 2007 4:25 pm     Reply with quote

AWSOME! Thanks!

Gotta make an editorial comment - sorry!
Quality Control is expensive! (regression testing for example)
I worked at a VERY large computer / software company.
The budget / manpower required for the QC group nearly
equalled the compiler group (not to mention how thankless a
job it is). Unfortunately, QC and customer services are
early on the list for downsizing and low on the list for
increases come budget time. As a customer, I'm not
pleased when I get stung. As a business man, I'm afraid
I understand the issues.
In my limited experience, I like the PCM compiler very much.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 12, 2007 4:40 pm     Reply with quote

Report the bug to CCS support. I'm not sure if anyone has done that yet.
Ttelmah
Guest







PostPosted: Tue Feb 13, 2007 3:35 am     Reply with quote

Reasonably comprehensive 'QA', is hard. However basic functionality testing for a compiler should be very easy indeed. The chip can do a lot of it 'itself'. All that is needed is a small suite of programs. A typical one, would comprise a simple set of maths operations, together with a constant declaration of the input values, and output values. It simply runs through the input values, and checks that the value returned by the function is 'as expected'. Similar programs can test the operation of many 'core' parts of the compiler. Quite a while ago, there were complaints about some other functions being wrong in some versions, and it was said that CCS were improving such 'self testing', and going to apply these to new releases. Obviously these 'good intentions', went 'by the board' at some point...
A a user, I have written several such programs to test 'core bits' that I need to work. Currently, serial I/O, pointer operations, array accesses, some arithmetic, basic looping and control flow. I recently added some for pointers to functions, constant string handling, typemod/addressmod. Now the 4.xxx compilers, are just starting to show signs of being able to pass many of these tests. a few though (like the arithmetic), have gone 'backwards'. However as has been said many times here before, the 'best' compiler at present, unless you 'need' something offered by V4, is 3.249...

Best Wishes
thomasj50



Joined: 23 Aug 2006
Posts: 19

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 14, 2007 10:33 pm     Reply with quote

One last message - I reported the float problem to CCS and they sent me a new math.h - but it is still wrong ! Using the corrections I got from this forum works fine though. CCS used a cast of (int8), but the correct one should be (int8*).
Best regards,
Thomas Johansson
thomasj50



Joined: 23 Aug 2006
Posts: 19

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 14, 2007 10:35 pm     Reply with quote

The LOG problem, sorry.
thomasj
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