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.

ADC problem in mikroC

Status
Not open for further replies.

swapan

Full Member level 4
Full Member level 4
Joined
Feb 20, 2009
Messages
204
Helped
27
Reputation
54
Reaction score
24
Trophy points
1,298
Location
Kolkata
Visit site
Activity points
2,839
Hi friends,

I am trying to implement ADC module of 16F676 in MikroC. Please see the code below. A LED, connected to RA5 of MCU is made ON/OFF depending on the value of analogue input to AN4 of MCU. I have tested the hardware developing the code in assembly. But when I try to develop the code in MikroC, it does not work. No effect is seen in output (RA5) while varying the input analogue voltage at AN4. Please suggest an way out.


swapan


Code:
int g_volt;

void main() {

     TRISC    =   0x00;
     TRISA    =   0x7;

     ANSEL    =   0x30;
     CMCON    =   0x7;
     do {

     g_volt = ADC_Read (4);       // Take adc at channel AN4

     if  (g_volt > 108)
     PORTA= 00100000;             // Turn ON LED at RA5
else
     PORTA= 00000000;             // Turn OFF LED at RA5
     }  
     while (1);
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top