View previous topic :: View next topic |
Author |
Message |
nailuy
Joined: 21 Sep 2010 Posts: 159
|
undefined identifier sin |
Posted: Fri Mar 08, 2013 6:03 pm |
|
|
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: 9225 Location: Greensville,Ontario
|
|
Posted: Fri Mar 08, 2013 7:53 pm |
|
|
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
|
|
Posted: Sat Mar 09, 2013 3:33 am |
|
|
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
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. |
|
|
|