Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] compilation failed. syntax error?

Status
Not open for further replies.

bhan1992

Member level 1
Joined
Feb 25, 2012
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,511
i duno why but when i compile this piece of code, the compiler says that there is a syntax error at line 11
can any1 tell me whats wrong with my code?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <p18f452.h>
#include <adc.h>
#include <stdlib.h>
#include <delays.h>
 
int result, increment;
 
void main (void)
{
    OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_2_TAD & ADC_8ANA_0REF & ADC_INT_OFF )
    TRISB = 0;
 
    while(1)
    {
        SetChanADC(ADC_CH0);
        ConvertADC();
        while(BusyADC());
        result = ReadADC();
 
        if (result < 250)
        {
            PORTB = 0;  //off the buzzer
        }
        else if (result >= 250 && result < 600) // slow beep
        {
            PORTB = 1; 
            for(increment = 0; increment < 4; increment ++) //0.25 sec total delay
            {   
                Delay10KTCYx(40);   //0.1 seconds
            }
            PORTB = ~PORTB;
        }
        else if (result >= 600 && result < 850) // medium beep
        {
            PORTB = 1; 
            for(increment = 0; increment < 4; increment ++) //0.25 sec total delay
            {   
                Delay10KTCYx(20);   //0.05 seconds
            }
            PORTB = ~PORTB;
        }
        else if (result >= 600 && result < 1025)    // fast beep
        {
            PORTB = 1; 
            for(increment = 0; increment < 2; increment ++) //0.15 sec total delay
            {   
                Delay10KTCYx(20);   //0.05 seconds
            }
            PORTB = ~PORTB;
        }
    }
    CloseADC();
}

 
Last edited by a moderator:

While there maybe other issues, the following statement/routine call highlighted is missing the terminating semicolon and is certainly in the ballpark of the indicated line number:

Code:
OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_2_TAD & ADC_8ANA_0REF & ADC_INT_OFF )[COLOR="#FF0000"];[/COLOR]


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <p18f452.h>
#include <adc.h>
#include <stdlib.h>
#include <delays.h>
 
int result, increment;
 
void main (void)
{
    OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_2_TAD & ADC_8ANA_0REF & ADC_INT_OFF )        // Add Semicolon
    TRISB = 0;
 
    while(1)
    {
        SetChanADC(ADC_CH0);
        ConvertADC();
        while(BusyADC());
        result = ReadADC();
 
        if (result < 250)
        {
            PORTB = 0;  //off the buzzer
        }
        else if (result >= 250 && result < 600) // slow beep
        {
            PORTB = 1; 
            for(increment = 0; increment < 4; increment ++) //0.25 sec total delay
            {   
                Delay10KTCYx(40);   //0.1 seconds
            }
            PORTB = ~PORTB;
        }
        else if (result >= 600 && result < 850) // medium beep
        {
            PORTB = 1; 
            for(increment = 0; increment < 4; increment ++) //0.25 sec total delay
            {   
                Delay10KTCYx(20);   //0.05 seconds
            }
            PORTB = ~PORTB;
        }
        else if (result >= 600 && result < 1025)    // fast beep
        {
            PORTB = 1; 
            for(increment = 0; increment < 2; increment ++) //0.15 sec total delay
            {   
                Delay10KTCYx(20);   //0.05 seconds
            }
            PORTB = ~PORTB;
        }
    }
    CloseADC();
}



BigDog
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top