MicroC ADC syntax problem

Status
Not open for further replies.

zulkifliaziz

Junior Member level 1
Joined
Mar 27, 2008
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,409
Hi, i'm having a problem where i got syntax error for the following code. Can anyone help.


void main()
{
unsigned long Vin_value;

TRISB=0;
TRISA=0xFF;
ADCON1=0x80;
do {
Vin_value = Adc_Read(0);

} while(1);
}

the problem saying that "Undeclared identifier 'Adc_Read' in expression"

Can anyone help. thanks
 

Hi,
Copy the code, close the project. Create a new project, paste the code and build it. See what happens. This problem shouldn't happen.

Hope this helps.
Tahmid.
 

Hi,
Copy the code, close the project. Create a new project, paste the code and build it. See what happens. This problem shouldn't happen.

Hope this helps.
Tahmid.

Hi Tahmid,

i tried to do what you said, but it doesn't work. Not sure what else need to do..
 

Wait, I'm having a look.

---------- Post added at 15:49 ---------- Previous post was at 15:46 ----------

I'm having no problems.

On the right, there's an option "Library Manager". There check if ADC is checked. If not check it.




Hope this helps.
Tahmid.
 

    V

    Points: 2
    Helpful Answer Positive Rating
Thank you. it does work. But i try to move on using the library for USART. It failed. I follow exactly as they said in the microC but not success. Can you help

Code:
unsigned short i;
void main() {
// Initialize USART module (8 bit, 2400 baud rate, no parity bit..)
UART_Init(2400);
do {
if (UART_Data_Ready()) { // If data is received
i = UART_Read(); // Read the received data
UART_Write(i); // Send data via USART
{
} while (1);
}

Here below is the error code

0 125 All files Preprocessed in 16 ms
0 121 Compilation Started X-BAND Serial.c
4 324 Undeclared identifier 'UART_Init' in expression X-BAND Serial.c
6 324 Undeclared identifier 'UART_Data_Ready' in expression X-BAND Serial.c
6 309 Invalid statement X-BAND Serial.c
7 324 Undeclared identifier 'UART_Read' in expression X-BAND Serial.c
8 324 Undeclared identifier 'UART_Write' in expression X-BAND Serial.c
12 315 Invalid expression X-BAND Serial.c
11 400 ; expected, but '' found X-BAND Serial.c
12 422 '}' expected '' found X-BAND Serial.c
12 409 while expected, but '' found X-BAND Serial.c
12 403 '(' expected, but '' found X-BAND Serial.c
12 315 Invalid expression X-BAND Serial.c
12 404 ')' expected, but '' found X-BAND Serial.c
12 400 ; expected, but '' found X-BAND Serial.c
12 422 '}' expected '' found X-BAND Serial.c
0 102 Finished (with errors): 05 Jan 2011, 14:57:33 X-BAND Serial.mcppi
 
Last edited:

Hi,
In every instance where you wrote UART, change it to UART1, like:
Code:
unsigned short i;
void main() {
// Initialize USART module (8 bit, 2400 baud rate, no parity bit..)
   UART1_Init(2400);
   do {
      if (UART1_Data_Ready()) { // If data is received
         i = UART1_Read(); // Read the received data
         UART1_Write(i); // Send data via USART
      }
   } while (1);
}

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…