CMCON problem

General discussion on mikroC.
Post Reply
Author
Message
run_margaret
Posts: 2
Joined: 27 Feb 2011 19:42

CMCON problem

#1 Post by run_margaret » 27 Feb 2011 19:46

I'm using MikroC Pro and i'm facing a problem right now with CMCON, using PIC16F877A

I use CMCON = 0x07;

but when i debugged it, it says "42 324 Undeclared identifier 'CMCON' in expression LCD_spi.c"

and I don't know how to fix it, I never have this problem before, please help me !!

thank you so much

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: CMCON problem

#2 Post by tihomir.losic » 28 Feb 2011 12:03

Hello,

please, tell me, which version of compiler are you using,
and attach me your project where this error appears.

Thank you.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

run_margaret
Posts: 2
Joined: 27 Feb 2011 19:42

Re: CMCON problem

#3 Post by run_margaret » 01 Mar 2011 16:15

mikroC pro fro pic, 1.65

thank you
Attachments
LCD_spi.rar
(29.44 KiB) Downloaded 270 times

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: CMCON problem

#4 Post by tihomir.losic » 02 Mar 2011 11:01

Hello,

ADCON1 Configure all pins as digital inputs.
So, replace CMCON register with

Code: Select all

ADCON1 = 0x06;
Best regards,

Losic Tihomir
mikroElektronika [Support team]

aliaj00
Posts: 2
Joined: 01 May 2011 02:44

Re: CMCON problem

#5 Post by aliaj00 » 01 May 2011 02:55

HI All,

this is the only place where i could find something about the "17 324 Undeclared identifier 'CMCON' in expression serial.c" i have a simple code i found on the net and i created a project for the pic16F887 and copy paste it to the c file i added all the library files and now the only error is the above. please can someone help me, i got the laptop from a friend to learn and i am new to this

code bellow:

Code: Select all

/*
Lab 8: Hardware UART
MCU: PIC16F628A
External 4MHz Crystal, MCLR Enabled, PWRT Enabled, WDT OFF
Copyright @ Rajendra Bhatt
Dec 12, 2010
*/

void newline(){
 UART1_Write(13); // Carriage Return
 UART1_Write(10); // Line Feed
}

void main() {
 unsigned char MyError, Temp;
 CMCON = 0x07 ;   // Disable Comparators
 TRISB = 0b00000010;
 UART1_Init(10417);
 Delay_ms(100);
 UART1_Write_Text("Testing UART! ");
 newline();

 do {
  UART1_Write_Text("Type in a Number: ");
  while(!UART1_Data_Ready());
  Temp = UART1_Read();
  newline();
  UART1_Write_Text("You entered: ");
  UART1_Write(Temp);
  newline();
 } while(1);
}  // End main()
thanks to all

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: CMCON problem

#6 Post by tihomir.losic » 04 May 2011 13:53

Hello,

CMCON is register for enabling pins for I/O functions, and PIC16F887 has ANSEL.
The ANSEL register must be initialized to configure an analog channel as a digital input.
Pins configured as analog inputs will read ‘0’.
So, try this code:

Code: Select all

void newline(){
UART1_Write(13); // Carriage Return
UART1_Write(10); // Line Feed
}

void main() {
unsigned char MyError, Temp;
ANSEL = 0;
TRISB = 0b00000010;
UART1_Init(10417);
Delay_ms(100);
UART1_Write_Text("Testing UART! ");
newline();

do {
  UART1_Write_Text("Type in a Number: ");
  while(!UART1_Data_Ready());
  Temp = UART1_Read();
  newline();
  UART1_Write_Text("You entered: ");
  UART1_Write(Temp);
  newline();
} while(1);
}  // End main()
Best regards,

Losic Tihomir
mikroElektronika [Support team]

aliaj00
Posts: 2
Joined: 01 May 2011 02:44

Re: CMCON problem

#7 Post by aliaj00 » 06 May 2011 10:31

Hi,

thanks a lot :) ,

i have been with flu all week so i didnt played with PC. thanks again for the prompt support :P.


BR's

Shpetim Aliaj

Post Reply

Return to “mikroC General”