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

undefined identifier sin

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



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

undefined identifier sin
PostPosted: Fri Mar 08, 2013 6:03 pm     Reply with quote

I use in my compiler PCWHD V4.130 with PIC16F1936
in main.c
Code:

#include <16F1936_prog_v3.h>
#include <math.h>
void main()
{
For;;{
for(faza=0; faza<2*3.141596; faza+=0.01)
Var1=sin((faza)+1) ;
}}

and in main.h
Code:

#include <16F1936.h>
#device *=16
#device adc=10

#use delay(int=8M)

//#FUSES WDT           //Watch Dog Timer
//#FUSES NOWDT         //No Watch Dog Timer
//#FUSES WDT_NOSL      //Watch Dog Timer, disabled during SLEEP
#FUSES INTRC_IO      //Internal RC Osc, no CLKOUT
#FUSES PROTECT       //Code protected from reads
#FUSES CPD           //Data EEPROM Code Protected
#FUSES WRT           //Program Memory Write Protected
#FUSES PLL_SW        //4X HW PLL disabled, 4X PLL enabled/disabled in software
#FUSES NOSTVREN      //Stack full/underflow will not cause reset
#FUSES NOLVP         //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOMCLR        //No MCLR
#FUSES NOPUT         //No Power Up Timer

int16 faza;
int32 Var1,Var2;


and now I have error "undefined identifier sin" Error12.
Thank you.
temtronic



Joined: 01 Jul 2010
Posts: 9167
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 08, 2013 7:53 pm     Reply with quote

First obvious error is that you've declared the variable 'faza' as an integer16 bit while the help file says it's supposed to be a float.
2nd is that your loop
...for(faza=0; faza<2*3.141596; faza+=0.01) ...

again faza is an integer(whole numbers) but you try to code as if ti was a floating point number...

3rd.
in 'main.c' you never include 'main.h'....

4th. we have no idea what's inside '16F1936_prog_v3.h'...


just a start...

as shown , your program cannot compile.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 3:33 am     Reply with quote

First of all thank you temtronic for your quick response.
I solved the problem with your help.

#1 works well with integer 16 or 32 bit (what I need it's okay).
#2 the loop is bigger but I try to make simplest way to read/understand code.
#3 math.h I moved back in main.h.
#4 16F1936_prog_v3.h is equivalent for main.h

if I put this code in main.h:
Code:
#include <16F1936.h>
#include <math.h>
#device *=16
#device adc=10

Is bad, I have a lot of error, at beginning.

I try to put math.h in main.c file and error was little Razz

and this code was good and works well.
Code:
#include <16F1936.h>
#device *=16
#device adc=10
#include <math.h>

Thank you and best regards, Iulian.
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