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.

[PIC] Problem with identifiers!

Status
Not open for further replies.

manojkl

Newbie level 5
Joined
Aug 16, 2015
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
143
i am using pic16f877a.i wrote a simple code as below.
getting a identifiers error for "CMCON"
Screenshot (26).png

Screenshot (26).png

.help pls:)


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
unsigned int temp_res;
                     void main()
                      {
 ADCON1 = 8;
       CMCON=0x07;           // Configure other AN pins as digital I/O
  TRISA  = 0xFF;              // PORTA is input
  TRISC  = 0;                 // PORTC is output
  TRISB  = 0;                 // PORTB is output  do {
    temp_res = ADC_Read(2);   // Get 10-bit results of AD conversion
    PORTB = temp_res;         // Send lower 8 bits to PORTB
    PORTC = temp_res >> 8;    // Send 2 most significant bits to RC1, RC0
  } while(1);}

 
Last edited by a moderator:

You have mismatched brackets so I would fix that first, it could be that it is seeing CMCON as part of an earlier expression instead of a line in it's own right. The other odd thing is the indentation, the instuction is out of line with the others, is it possible you have a 'non printable' character between the start of the line and the 'CMCON'. Try placing the cursor at the start of the word and backspacing to remove anything that shouldn't be there.

Brian.
 

still got the error!!
"CMCON" Identifiers error


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
unsigned int adc;     // Variable to save ADC value
 void main()      // Start of Main function
{
    CMCON = 0x07;     // Disable Comparators
 
         ADCON1 = 0x80;    // For ADC Module configuration
          TRISA = 0xFF;    // PORTA is input (ADC Input)
           TRISB = 0x00;    // PORTB is output
            TRISC = 0x00;    // PORTC is Output
      do
     {
       adc = ADC_Read(1);  // Get 10-bit results of AD conversion of channel 1
       PORTB = adc;        // Send lower 8 bits to PORTB
        PORTC = adc >> 2;   // Send 2 most significant bits to RC7, RC6
     }
        while(1);
}

 

Attachments

  • Screenshot (28).png
    Screenshot (28).png
    163.6 KB · Views: 45
Last edited by a moderator:

Much against my better judgement, I copied your code into MicroC v6.6.1 and compiled it without any errors.

Check you have the 16F877A selected as the target processor, if you have, either the compiler is corrupted or the "CMCON" entry is missing from the "\Defs\16F877A.c" file. It should read:
"sfr unsigned short volatile CMCON absolute 0x009C;"

Brian.
 

Re: solved

got it.
Thk u :)
:smile:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top