View previous topic :: View next topic |
Author |
Message |
mvliege
Joined: 05 Aug 2014 Posts: 7 Location: Turkey
|
function used but not defined |
Posted: Tue Aug 05, 2014 7:17 am |
|
|
Hi,
I used internal oscillator with PIC18F46K22 but, I have faced this problem (it's delay problem in the lcd.c, it appears when I complied. )
"function used but not defined delay_ms 609 SRC=1356"
problem is about using internal oscillator?
Code: | #include <main.h>
#FUSES INTRC_IO
#include <lcd.c>
int a=0;
#use delay(internal=64MHz)
#INT_TIMER0
void TIMER0_isr(void)
{
set_timer0(15536);
if(a==1)
output_low(pin_c0);
output_toggle(pin_c1);
printf(lcd_putc,"\f ERROR \n PLC CHECK");
}
#INT_EXT
void EXT_isr(void)
{
if(input(pin_b0)==1)
a=1;
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Aug 05, 2014 7:55 am |
|
|
What happens if you put this line
Code: | #use delay(internal=64MHz) |
ahead of this one?
Mike |
|
![](templates/subSilver/images/spacer.gif) |
mvliege
Joined: 05 Aug 2014 Posts: 7 Location: Turkey
|
|
Posted: Tue Aug 05, 2014 8:11 am |
|
|
hi mike,
thank you for your reply,
here is you can find picture about this problem. Problem is about in "lcd.c"
thank you so much for your help
BS,
https://yadi.sk/i/ULRIdr74Z7zkJ
https://yadi.sk/i/gLGDV7PyZ82dc
https://yadi.sk/i/lCG3mpypZ82iM |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Tue Aug 05, 2014 9:20 am |
|
|
He is trying to tell you, SWAP the two lines in your code.
Move #use delay up and move #include <lcd.c> down....
You cannot use the delay_ms() function before the #use delay line. _________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Aug 05, 2014 3:14 pm |
|
|
This line
Code: | #use delay(internal=64MHz) | tells the compiler how to handle the 'delay_us(xx)' and 'delay_ms(xx)' instructions.
To process this line
the compiler needs to know how to deal with one or both of the 'delay_yy(xx)' instructions.
(There are delay_yy(xx) instructions buried within 'lcd.c'.)
The compiler is complaining because you are presenting it with code in the wrong sequence.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
mvliege
Joined: 05 Aug 2014 Posts: 7 Location: Turkey
|
SOLVED!!! |
Posted: Wed Aug 06, 2014 2:52 am |
|
|
SOLVED!!!
Thank you guys, I found out how to use "delay"
This code solved the problem below,
Code: | #use delay(internal) |
thank you,
BS |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Aug 06, 2014 9:45 am |
|
|
So, what is your complete code?
Mike |
|
![](templates/subSilver/images/spacer.gif) |
mvliege
Joined: 05 Aug 2014 Posts: 7 Location: Turkey
|
|
Posted: Wed Aug 06, 2014 11:55 pm |
|
|
Hi Mike,
these are my full codes:
PS the problem is that Altough I have already mentioned frequency with pwm (495Hz) but when I run the program on the PIC, I could see frequency is 990Hz. Where is the problem?
Code: | #include <main.h>
int1 a=0;
int16 b=0;
float v=0;
#INT_TIMER0
void TIMER0_isr(void)
{
set_timer0(3036);
if(a==1)
{
output_low(pin_c0);
output_high(pin_c1);
printf(lcd_putc,"\f ERROR");
}
}
#INT_EXT
void EXT_isr(void)
{
if(input(pin_b0)==1)
a=1;
}
void main()
{
set_tris_c(0xf0);
lcd_init();
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_2);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); //52,4 ms overflow
enable_interrupts(INT_TIMER0);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(TRUE)
{
//TODO: User Code
if(a==0)
{
output_high(pin_c0);
set_adc_channel(0);
delay_us(20);
b=read_adc();
v=0.0048828125*b;
printf(lcd_putc,"\f VALUE v:%1.2f",v);
}
delay_ms(500);
if(input(pin_b0)==0)
a=0;
}
} |
and it is head file:
Code: | #include <18F46K22.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16)
#FUSES NOXINST //Extended set extension
#use delay(internal=8MHz)
#include <lcd.c>
#use pwm(CCP1,TIMER=2,FREQUENCY=495,DUTY=50)
|
|
|
![](templates/subSilver/images/spacer.gif) |
|